-
Notifications
You must be signed in to change notification settings - Fork 12
/
setup.py
executable file
·78 lines (70 loc) · 2.95 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
import os.path
import time
from setuptools import setup
from setuptools.command.build_py import build_py
from subprocess import call
import re
with open("pyboof/version.txt", "r") as myfile:
pyboof_version = myfile.read()
def check_for_command(command):
try:
call([command], stdout=open(os.devnull, 'w'), stderr=open(os.devnull, 'w'))
return True
except:
return False
class MyBuild(build_py):
def run(self):
try:
if os.path.exists('pyboof/PyBoof-all.jar'):
print("*** Skipping java build since 'pyboof/PyBoof-all.jar' already exists ***")
print(" 'rm pyboof/PyBoof-all.jar' if this is not desired")
else:
# Create build date file. This is used to determine if the java jar and python code are
# compatible with each other
f = open('pyboof/build_date.txt', 'w')
f.write(str(int(round(time.time() * 1000))))
f.close()
# See if javac is available for compiling the java code
if check_for_command("javac"):
if call(["bash", "gradlew", "allJar"]) != 0:
print("Gradle build failed. ")
exit(1)
else:
print("javac cannot be found. Please install it or correct your path.")
if os.path.isfile('pyboof/PyBoof-all.jar'):
print(" Found a precompiled jar. Using that")
else:
exit(1)
except Exception as e:
print("Exception message:")
print(str(e))
print(e.message)
print()
if not os.path.isfile('pyboof/PyBoof-all.jar'):
print("Gradle build failed AND there is no PyBoof-all.jar")
print("")
print("Did you run build as a regular user first?")
print(" ./setup.py build")
print("Is Gradle and Java installed? Test by typing the following:")
print(" gradle allJar")
exit(1)
build_py.run(self)
setup(name='PyBoof',
cmdclass={'build_py': MyBuild},
version=pyboof_version,
description='Py4J Python wrapper for BoofCV',
long_description=open('README.md', 'r').read(),
long_description_content_type="text/markdown",
url='https://github.com/lessthanoptimal/PyBoof',
author="Peter Abeles",
author_email="[email protected]",
license="Apache 2.0",
classifiers=['Intended Audience :: Developers',
'Programming Language :: Python :: 3.5'],
python_requires='>=3',
eager_resources=['java'],
packages=['pyboof'],
package_data={'pyboof': ['PyBoof-all.jar', 'build_date.txt', 'version.txt']},
install_requires=['py4j>=0.10.9.2', 'numpy>=1.14.0', 'six>=1.11.0', 'transforms3d>=0.3.1'],
)