From d5b2c7c84ab69565353b8f356301adc04c51715b Mon Sep 17 00:00:00 2001 From: Lee Kamentsky Date: Thu, 16 Nov 2017 08:56:43 -0500 Subject: [PATCH 1/9] Fix #121 - more permissive search for "openjdk" in java -version --- javabridge/locate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javabridge/locate.py b/javabridge/locate.py index b096881..1cbc45d 100644 --- a/javabridge/locate.py +++ b/javabridge/locate.py @@ -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, "..", "..") From 8b21dabfe1be8cd456fb975ab0d3d55b194d560e Mon Sep 17 00:00:00 2001 From: Lee Kamentsky Date: Fri, 17 Nov 2017 08:23:08 -0500 Subject: [PATCH 2/9] Hopefully fixes https://github.com/LeeKamentsky/python-javabridge/issues/28#issuecomment-345170493 --- _javabridge.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_javabridge.pyx b/_javabridge.pyx index f46d452..03ed2cf 100644 --- a/_javabridge.pyx +++ b/_javabridge.pyx @@ -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) From 34a4e8605187f790710c653db1384b2ee00688d7 Mon Sep 17 00:00:00 2001 From: Lee Kamentsky Date: Fri, 17 Nov 2017 09:01:13 -0500 Subject: [PATCH 3/9] Build CPython.class before building jars --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 965b163..ae54405 100644 --- a/setup.py +++ b/setup.py @@ -172,8 +172,6 @@ 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(): @@ -196,6 +194,8 @@ def run(self, *args, **kwargs): if dirty: result = _build_ext.run(self, *args, **kwargs) self.build_java2cpython() + result = build_cython() + self.build_java() return result def build_jar_from_sources(self, jar, sources): From 98f475d64d95c7c67137ce803a0ba0055421e652 Mon Sep 17 00:00:00 2001 From: Lee Kamentsky Date: Fri, 17 Nov 2017 09:10:37 -0500 Subject: [PATCH 4/9] Build _javabridge.pyx before CPython.class --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ae54405..10c415c 100644 --- a/setup.py +++ b/setup.py @@ -191,10 +191,10 @@ 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() - result = build_cython() self.build_java() return result From 4b59ea18ba0a6ed5f3edacb491e8a8a3fb65a3c2 Mon Sep 17 00:00:00 2001 From: Lee Kamentsky Date: Fri, 17 Nov 2017 09:32:30 -0500 Subject: [PATCH 5/9] Travis failing... some logging and sanity checks --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 10c415c..004862b 100644 --- a/setup.py +++ b/setup.py @@ -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] @@ -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''' From cd1ba7056819087aaa84864d65c923414ce0b3c1 Mon Sep 17 00:00:00 2001 From: Lee Kamentsky Date: Fri, 17 Nov 2017 09:46:06 -0500 Subject: [PATCH 6/9] Fix travis build: python setup.py develop --- setup.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 004862b..d400d2a 100644 --- a/setup.py +++ b/setup.py @@ -111,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() @@ -177,6 +177,9 @@ def run(self, *args, **kwargs): 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 \ @@ -255,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: @@ -387,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": [ From ec83def7ec4636d1c255a8639e934a20e20a6467 Mon Sep 17 00:00:00 2001 From: Lee Kamentsky Date: Mon, 20 Nov 2017 08:51:05 -0500 Subject: [PATCH 7/9] Test in Travis on 3 Java versions Test on Oracle JDK 8 and 9 and openjdk 7 as a regression test of #121 --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3248653..650337e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 From f951caef793fe3fcbba020eb560e6656ac367ec7 Mon Sep 17 00:00:00 2001 From: Lee Kamentsky Date: Mon, 20 Nov 2017 09:43:35 -0500 Subject: [PATCH 8/9] Fix #123 Oracle JDK no longer has .so in arch-specific directory --- javabridge/locate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javabridge/locate.py b/javabridge/locate.py index 1cbc45d..21b0420 100644 --- a/javabridge/locate.py +++ b/javabridge/locate.py @@ -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: From e42c6d6b75c2c3e8b4780d6c8a2253abbb019dec Mon Sep 17 00:00:00 2001 From: Lee Kamentsky Date: Mon, 20 Nov 2017 09:55:03 -0500 Subject: [PATCH 9/9] JRE 9 has different output for deprecated class --- javabridge/tests/test_jutil.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/javabridge/tests/test_jutil.py b/javabridge/tests/test_jutil.py index 150e39b..5293fa7 100644 --- a/javabridge/tests/test_jutil.py +++ b/javabridge/tests/test_jutil.py @@ -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')