1- from setuptools import setup , Extension , find_packages
1+ from struct import pack
2+ from setuptools import setup , Extension , find_packages , find_namespace_packages
23from Cython .Build import cythonize
34import re
45import os
56from pathlib import Path
7+ import shutil
68
79
810# standalone import of a module (https://stackoverflow.com/a/58423785)
@@ -29,6 +31,8 @@ def import_module_from_path(path):
2931util = import_module_from_path ('optix/path_utility.py' )
3032cuda_include_path = util .get_cuda_include_path ()
3133optix_include_path = util .get_optix_include_path ()
34+ print ("Found cuda includes at" , cuda_include_path )
35+ print ("Found optix includes at" , optix_include_path )
3236if cuda_include_path is None or optix_include_path is None :
3337 raise RuntimeError ("Cuda or optix not found in the system" )
3438
@@ -65,6 +69,35 @@ def import_module_from_path(path):
6569
6670version = import_module_from_path ('optix/_version.py' ).__version__
6771
72+ package_data = {}
73+
74+ try :
75+ from wheel .bdist_wheel import bdist_wheel as _bdist_wheel
76+
77+ def glob_fix (package_name , glob ):
78+ # this assumes setup.py lives in the folder that contains the package
79+ package_path = Path (f'./{ package_name } ' ).resolve ()
80+ return [str (path .relative_to (package_path ))
81+ for path in package_path .glob (glob )]
82+
83+ class custom_bdist_wheel (_bdist_wheel ):
84+ def finalize_options (self ):
85+ _bdist_wheel .finalize_options (self )
86+
87+ # create the path for the internal headers
88+ # due to optix license restrictions those headers
89+ # cannot be distributed on pypi directly so we will add this headers dynamically
90+ # upon wheel construction to install them alongside the package
91+
92+ if not os .path .exists ('optix/include/optix.h' ):
93+ shutil .copytree (optix_include_path , 'optix/include' )
94+ self .distribution .package_data .update ({
95+ 'optix' : [* glob_fix ('optix' , 'include/**/*' )]
96+ })
97+
98+ except ImportError :
99+ custom_bdist_wheel = None
100+
68101setup (
69102 name = "python-optix" ,
70103 version = version ,
@@ -87,6 +120,7 @@ def import_module_from_path(path):
87120 classifiers = [
88121 "Programming Language :: Python :: 3.8" ,
89122 "Programming Language :: Python :: 3.9" ,
123+ "Programming Language :: Python :: 3.10" ,
90124 "License :: OSI Approved :: MIT License" ,
91125 "Operating System :: POSIX :: Linux" ,
92126 "Operating System :: Microsoft :: Windows" ,
@@ -101,5 +135,7 @@ def import_module_from_path(path):
101135 'examples' : ["pillow" , "pyopengl" , "pyglfw" , "pyimgui" ]
102136 },
103137 python_requires = ">=3.8" ,
104- zip_safe = False
138+ package_data = package_data ,
139+ zip_safe = False ,
140+ cmdclass = {'bdist_wheel' : custom_bdist_wheel }
105141)
0 commit comments