-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathsetup.py
227 lines (191 loc) · 7.63 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
from setuptools import setup, find_packages
from setuptools.command.develop import develop
from setuptools.command.install import install
import struct, os, platform, subprocess
def HandlePrerequisites(command_subclass):
base_run = command_subclass.run
def testPython64b(self):
if struct.calcsize("P") * 8 != 64:
print(80 * "*"); print(80 * "*")
print("Python 64-bit is required.")
print(80 * "*"); print(80 * "*")
raise ValueError
def findCuda(self, p, quiet):
cuda_major = -1
cuda_minor = -1
try:
try:
outp = subprocess.check_output(["nvcc", "--version"]).decode("utf-8").split(" ")
except FileNotFoundError:
if p == "Linux": outp = subprocess.check_output(["/usr/local/cuda/bin/nvcc", "--version"]).decode("utf-8").split(" ")
else: raise
idx = outp.index("release")
if idx + 1 < len(outp):
rel = outp[idx + 1].strip(" ,")
cuda_major = int(rel.split(".")[0])
cuda_minor = int(rel.split(".")[1])
print("OK: found CUDA %s" % rel)
else:
if not quiet: raise ValueError
except FileNotFoundError:
if not quiet:
print(80 * "*"); print(80 * "*")
print("Cannot access nvcc. Please check your CUDA installation and/or PATH variable.")
print(80 * "*"); print(80 * "*")
raise
except ValueError:
if not quiet:
print(80 * "*"); print(80 * "*")
print("CUDA release not recognized.")
print(80 * "*"); print(80 * "*")
raise
except Exception as e:
if not quiet:
print("Cannot verify CUDA installation: " + str(e))
raise
return cuda_major, cuda_minor
def prepareCudaLinux(self, cuda_major, cuda_minor, removing):
if hasattr(self, 'install_lib') and self.install_lib is not None: lib_path = self.install_lib
else: lib_path = os.getcwd()
src = os.path.join(lib_path, "plotoptix", "bin", "librndSharpOptiX_%s_%s.so" % (cuda_major, cuda_minor))
dst = os.path.join(lib_path, "plotoptix", "bin", "librndSharpOptiX.so")
if os.path.isfile(dst): os.remove(dst)
if not removing and os.path.isfile(src): os.symlink(src, dst)
def clearOptixCacheLinux(self):
import getpass, shutil
if 'SUDO_UID' in os.environ:
uname = os.environ['SUDO_USER']
else:
uname = getpass.getuser()
folder = os.path.join('/var/tmp/OptixCache_' + uname)
if os.path.isdir(folder):
print("Clear OptiX compilation chache...", folder)
shutil.rmtree(folder)
else:
folder = os.path.join('/tmp/OptixCache_' + uname)
if os.path.isdir(folder):
print("Clear OptiX compilation chache...", folder)
shutil.rmtree(folder)
else:
print("OptiX compilation chache not found yet.")
def clearOptixCacheWindows(self):
folder = os.path.join(os.environ['LOCALAPPDATA'], 'NVIDIA', 'OptixCache')
if os.path.isdir(folder):
print("Clear OptiX compilation chache...", folder)
import shutil
shutil.rmtree(folder)
else:
print("OptiX compilation chache not found yet.")
def subclass_run(self):
#print(self.user_options)
if hasattr(self, 'uninstall') and self.uninstall == 1: removing = True
else: removing = False
if hasattr(self, 'install_lib') and self.install_lib is not None: lib_path = self.install_lib
else: lib_path = os.getcwd()
testPython64b(self)
p = platform.system()
#cuda_major, cuda_minor = findCuda(self, p, removing)
if p == "Windows":
if not removing: clearOptixCacheWindows(self)
base_run(self)
elif p == "Linux":
if not removing: clearOptixCacheLinux(self)
base_run(self)
else:
raise NotImplementedError
print("All correct.")
command_subclass.run = subclass_run
return command_subclass
@HandlePrerequisites
class HandlePrerequisitesDevelop(develop):
pass
@HandlePrerequisites
class HandlePrerequisitesInstall(install):
pass
try:
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
class bdist_wheel(_bdist_wheel):
def finalize_options(self):
_bdist_wheel.finalize_options(self)
self.root_is_pure = False
def get_tag(self):
python, abi, plat = _bdist_wheel.get_tag(self)
python, abi = 'py3', 'none'
return python, abi, plat
except ImportError:
bdist_wheel = None
windows_files = [
"bin/OpenImageDenoise.dll",
"bin/OpenImageDenoise_core.dll",
"bin/OpenImageDenoise_device_cuda.dll",
"bin/rndSharpEncoder.dll",
"bin/rndSharpOptiX7.dll"
]
linux_files = [
"bin/librndSharpOptiX7.so",
"bin/librndSharpEncoder.so",
"bin/libOpenImageDenoise.so",
"bin/libOpenImageDenoise_core.so.2.3.1",
"bin/libOpenImageDenoise_device_cuda.so.2.3.1"
]
common_files = [
"bin/BitMiracle.LibTiff.NET.dll",
"bin/BitMiracle.LibTiff.NET.xml",
"bin/Newtonsoft.Json.dll",
"bin/Newtonsoft.Json.xml",
"bin/RnD.SharpEncoder.dll",
"bin/RnD.SharpOptiX.dll",
"bin/RnD.SharpOptiX.dll.config",
"bin/cuda/*.ir"
]
platform_specific_files = windows_files if platform.system() == "Windows" else linux_files
setup(name='plotoptix',
version='0.18.3',
url='https://rnd.team/plotoptix',
project_urls={
'Documentation': 'https://plotoptix.rnd.team',
'Examples': 'https://github.com/rnd-team-dev/plotoptix/tree/master/examples',
'Source': 'https://github.com/rnd-team-dev/plotoptix',
},
author='Robert Sulej, R&D Team',
author_email='[email protected]',
description='Data visualisation in Python based on NVIDIA OptiX ray tracing framework.',
keywords="gpu nvidia optix ray-tracing path-tracing visualisation generative plot animation real-time",
cmdclass={
'bdist_wheel': bdist_wheel,
'install': HandlePrerequisitesInstall,
'develop': HandlePrerequisitesDevelop
},
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Win32 (MS Windows)',
'Environment :: X11 Applications',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3 :: Only',
'Intended Audience :: Education',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Science/Research',
'License :: Free for non-commercial use',
'Natural Language :: English',
'Topic :: Multimedia :: Graphics :: 3D Rendering',
'Topic :: Scientific/Engineering :: Visualization',
'Topic :: Artistic Software'
],
packages=find_packages(exclude=['tests']),
install_requires=[
'enum34;python_version<="3.4"',
'packaging>=18.0',
'numpy>=1.0',
'Pillow>=5.3',
'python-dateutil>=2.7',
'matplotlib>=2.0',
'requests>=2.25'
],
long_description=open('README.rst').read(),
include_package_data=False,
package_data={ "plotoptix": platform_specific_files + common_files },
exclude_package_data={ '': ['README.rst', 'README.md'] },
test_suite='nose2.collector.collector',
tests_require=['nose2>=0.9'],
zip_safe=False)