-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
47 lines (44 loc) · 1.81 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from setuptools import setup
import site
import os
from jpype._jvmfinder import getDefaultJVMPath, JVMNotFoundException, JVMNotSupportedException
from setuptools.command.install import install
import jdk
class PostInstallCommand(install):
"""Install a JRE if necessary."""
def run(self):
install.run(self)
try:
getDefaultJVMPath()
except (JVMNotFoundException, JVMNotSupportedException):
paths = site.getsitepackages()
paths.append(site.getusersitepackages())
has_jre = False
for path in paths:
if os.access(path, os.W_OK):
path = os.path.join(path, 'jre')
if os.path.exists(path):
os.environ['JAVA_HOME'] = path
try:
getDefaultJVMPath()
except (JVMNotFoundException, JVMNotSupportedException):
pass
else:
print("Found existing Java Runtime Environtment in:", path)
has_jre = True
break
print("Installing Java Runtime Environtment in:")
print(jdk.install('11', jre=True, path=path))
has_jre = True
break
if not has_jre: # very unlikely
print("Could not install a Java Runtime Environtment, you need to install one yourself.")
setup(name='efmtool_link',
packages=['efmtool_link', 'efmtool_link.lib'],
package_dir={'efmtool_link': 'efmtool_link'},
package_data={'efmtool_link': ['lib/*.jar']},
install_requires=['install-jdk>=1.1', 'jpype1'],
cmdclass={
'install': PostInstallCommand,
},
zip_safe=False)