Skip to content

Commit

Permalink
Merge pull request #166 from benson-basis/modern_osx_java
Browse files Browse the repository at this point in the history
Use the java from java_home on OSX.
  • Loading branch information
dessant committed Nov 3, 2015
2 parents 5b4378a + 267ca88 commit 51ebed9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@
library_dirs = ['libs/' + environ['ARCH']]
elif platform == 'darwin':
import subprocess
framework = subprocess.Popen('xcrun --sdk macosx --show-sdk-path',
framework = subprocess.Popen('/usr/libexec/java_home',
shell=True, stdout=subprocess.PIPE).communicate()[0].strip()
print('java_home: {0}\n'.format(framework));
if not framework:
raise Exception('You must install Java on your Mac OS X distro')
extra_link_args = ['-framework', 'JavaVM']
include_dirs = [join(framework, 'System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers')]
if '1.6' in framework:
extra_link_args = ['-framework', 'JavaVM']
include_dirs = [join(framework, 'System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers')]
else:
# TODO: This won't make a dylib that moves from one machine to another.
# TODO: it needs a switch to dlopen and a configuration of the path.
java_runtime_lib = '{0}/jre/lib/server'.format(framework)
extra_link_args = ['-L', java_runtime_lib, '-ljvm', '-rpath', java_runtime_lib]
include_dirs = ['{0}/include'.format(framework), '{0}/include/darwin'.format(framework)]
else:
import subprocess
# otherwise, we need to search the JDK_HOME
Expand Down

0 comments on commit 51ebed9

Please sign in to comment.