-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathsetup.py
More file actions
132 lines (114 loc) · 3.68 KB
/
setup.py
File metadata and controls
132 lines (114 loc) · 3.68 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
"""Setup RayNet"""
from itertools import dropwhile
from os import path
from setuptools import find_packages, setup
from setuptools.extension import Extension
from subprocess import Popen
def collect_docstring(lines):
"""Return document docstring if it exists"""
lines = dropwhile(lambda x: not x.startswith('"""'), lines)
doc = ""
for line in lines:
doc += line
if doc.endswith('"""\n'):
break
return doc[3:-4].replace("\r", "").replace("\n", " ")
def collect_metadata():
meta = {}
with open(path.join("raynet","__init__.py")) as f:
lines = iter(f)
meta["description"] = collect_docstring(lines)
for line in lines:
if line.startswith("__"):
key, value = map(lambda x: x.strip(), line.split("="))
meta[key[2:-2]] = value[1:-1]
return meta
def is_cuda_on_the_machine():
try:
p = Popen([
"nvidia-smi",
"--query-gpu=index,uuid,utilization.gpu,memory.total,memory.used,memory.free,driver_version,name,gpu_serial,display_active,display_mode",
"--format=csv,noheader,nounits"
])
return True
except OSError:
# There is no GPU on the machine
return False
def setup_package():
extensions = [
Extension(
"raynet.utils.fast_utils",
["raynet/utils/fast_utils.pyx"]
),
Extension(
"raynet.ray_marching.ray_tracing",
["raynet/ray_marching/ray_tracing.pyx"]
)
]
requirements = [
"Cython",
"backports.functools_lru_cache",
"keras>=2",
"tensorflow",
"numpy",
"scikit-learn",
"matplotlib",
"imageio",
"oauth2client",
"google-api-python-client"
]
try:
import tensorflow
except ImportError:
if is_cuda_on_the_machine():
requirements.append("tensorflow-gpu")
else:
requirements.append("tensorflow")
try:
import pycuda
except ImportError:
if is_cuda_on_the_machine():
requirements.append("pycuda")
with open("README.rst") as f:
long_description = f.read()
meta = collect_metadata()
setup(
name="raynet",
version=meta["version"],
description=meta["description"],
long_description=long_description,
maintainer=meta["maintainer"],
maintainer_email=meta["email"],
url=meta["url"],
license=meta["license"],
classifiers=[
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Topic :: Scientific/Engineering",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7"
],
packages=find_packages(exclude=["docs", "tests", "scripts", "config"]),
setup_requires=[
"setuptools>=18.0",
"Cython"
],
install_requires=requirements,
ext_modules=extensions,
entry_points={
"console_scripts": [
"raynet_compute_metrics = raynet.scripts.compute_metrics:main",
"raynet_to_pcl = raynet.scripts.convert_to_pointcloud:main",
"raynet_forward = raynet.scripts.forward_pass:main",
"raynet_pretrain = raynet.scripts.pretrain_network:main",
"raynet_train = raynet.scripts.train_raynet:main"
]
},
package_data={
"": ["*.cu", "*.pyx"]
}
)
if __name__ == "__main__":
setup_package()