Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #121 - more permissive search for "openjdk" in java -version #122

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ language: java
env:
- PYTHON_VERSION="2.7"
- PYTHON_VERSION="3.5"
jdk:
- oraclejdk8
- oraclejdk9
- openjdk7
before_install:
# Get the tag if it wasn't provided. Travis doesn't provide this if it isn't a tagged build.
- if [ -z $TRAVIS_TAG ]; then TRAVIS_TAG=`git tag --contains` ; fi
Expand Down
3 changes: 2 additions & 1 deletion _javabridge.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,8 @@ cdef class JB_Env:
'''
cdef:
jobject o
o = self.env[0].NewStringUTF(self.env, s.encode('utf-8'))
sutf8 = s.encode('utf-8')
o = self.env[0].NewStringUTF(self.env, sutf8)
if o == NULL:
raise MemoryError("Failed to allocate string")
jbo, e = make_jb_object(self, o)
Expand Down
4 changes: 2 additions & 2 deletions javabridge/locate.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def get_out(cmd):
java_bin = get_out(["bash", "-c", "type -p java"])
java_dir = get_out(["readlink", "-f", java_bin])
java_version_string = get_out(["bash", "-c", "java -version"])
if re.match('^openjdk', java_version_string) is not None:
if re.search('(?i)openjdk', java_version_string) is not None:
jdk_dir = os.path.join(java_dir, "..", "..", "..")
elif re.match('^java', java_version_string) is not None:
jdk_dir = os.path.join(java_dir, "..", "..")
Expand Down Expand Up @@ -209,7 +209,7 @@ def find_jre_bin_jdk_so():
for jre_home in (java_home, os.path.join(java_home, "jre")):
jre_bin = os.path.join(jre_home, 'bin')
jre_libexec = os.path.join(jre_home, 'bin' if is_win else 'lib')
arches = ('amd64', 'i386') if is_linux else ('',)
arches = ('amd64', 'i386', '') if is_linux else ('',)
lib_prefix = '' if is_win else 'lib'
lib_suffix = '.dll' if is_win else ('.dylib' if is_mac else '.so')
for arch in arches:
Expand Down
4 changes: 3 additions & 1 deletion javabridge/tests/test_jutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ def test_03_05_cw_get_annotations(self):
annotations = c.getAnnotations()
annotations = javabridge.get_env().get_object_array_elements(annotations)
self.assertEqual(len(annotations), 1)
self.assertEqual(javabridge.to_string(annotations[0]),'@java.lang.Deprecated()')
expected = '@java.lang.Deprecated'
self.assertEqual(
javabridge.to_string(annotations[0])[:len(expected)], expected)

def test_03_06_cw_get_constructors(self):
c = javabridge.get_class_wrapper('java.lang.String')
Expand Down
15 changes: 10 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def build_cython():
compile them.

"""
distutils.log.info("Building Cython extensions")
stems = ['_javabridge', '_javabridge_mac', '_javabridge_nomac']
pyx_filenames = [in_cwd(s + '.pyx') for s in stems]
c_filenames = [in_cwd(s + '.c') for s in stems]
Expand All @@ -62,6 +63,7 @@ def build_cython():
if len(nc_pyx_filenames) > 0:
cmd = ['cython'] + nc_pyx_filenames
subprocess.check_call(cmd)
assert all(map(os.path.exists, c_filenames))

def get_jvm_include_dirs():
'''Return a sequence of paths to include directories for JVM defs'''
Expand Down Expand Up @@ -109,7 +111,7 @@ def ext_modules():
# Build libjvm from jvm.dll on Windows.
# This assumes that we're using mingw32 for build
#
# generate the jvm.def file matching to the jvm.dll
# generate the jvm.def file matching to the jvm.dll
cmd = ["gendef", os.path.join(jdk_home,"jre\\bin\\server\\jvm.dll")]
p = subprocess.Popen(cmd)
p.communicate()
Expand Down Expand Up @@ -172,11 +174,12 @@ def package_path(relpath):
class build_ext(_build_ext):
java2cpython_sources = ["java/org_cellprofiler_javabridge_CPython.c"]
def run(self, *args, **kwargs):
self.build_java()
result = build_cython()
if self.inplace:
dirty = False
for source in self.get_source_files():
if not os.path.exists(source):
dirty = True
break
source_mtime = os.stat(source).st_mtime
for output in self.get_outputs():
if not os.path.isfile(output) or \
Expand All @@ -193,9 +196,11 @@ def run(self, *args, **kwargs):
dirty = True
else:
dirty = True
result = build_cython()
if dirty:
result = _build_ext.run(self, *args, **kwargs)
self.build_java2cpython()
self.build_java()
return result

def build_jar_from_sources(self, jar, sources):
Expand Down Expand Up @@ -253,7 +258,7 @@ def build_java2cpython(self):
output_dir=output_dir,
debug=self.debug,
library_dirs=library_dirs,
libraries=libraries,
libraries=libraries,
export_symbols=export_symbols,
extra_postargs=extra_postargs)
if needs_manifest:
Expand Down Expand Up @@ -385,7 +390,7 @@ def get_version():
install_requires=['numpy'],
tests_require="nose",
entry_points={'nose.plugins.0.10': [
'javabridge = javabridge.noseplugin:JavabridgePlugin'
'javabridge = javabridge.noseplugin:JavabridgePlugin'
]},
test_suite="nose.collector",
package_data={"javabridge": [
Expand Down