Skip to content

Instantly share code, notes, and snippets.

@jimbaker
Last active December 24, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimbaker/6717525 to your computer and use it in GitHub Desktop.
Save jimbaker/6717525 to your computer and use it in GitHub Desktop.
clamped - setup.py for a project using clamp
# clamped/clamped/__init__.py
import java
from java.io import Serializable
from java.util.concurrent import Callable
from clamp import ClampProxyMaker
class BarClamp(Callable, Serializable):
__proxymaker__ = ClampProxyMaker(
"bar",
constants={ "fortytwo": (java.lang.Integer(42), java.lang.Integer.TYPE),
"str": ("A string", java.lang.String),
"serialVersionUID" : (java.lang.Long(99), java.lang.Long.TYPE),
})
def __init__(self):
print "Being init-ed", self
def call(self):
print "foo"
return 42
#clamped/setup.py
import ez_setup
ez_setup.use_setuptools()
from setuptools import setup, find_packages
setup(
name = "clamped",
version = "0.1",
packages = find_packages(),
install_requires = ["clamp>=0.1"],
clamp = ["clamped"],
)
// put this wherever you want - just need to ensure that the clamped-0.1.jar is on the CLASSPATH (or otherwise available)
// for both Python and Java
import bar.clamped.BarClamp;
public class UseClamped {
public static void main(String[] args) {
BarClamp barclamp = new BarClamp();
try {
System.out.println("BarClamp: " + barclamp.call());
} catch (Exception ex) {
System.err.println("Exception: " + ex);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment