Skip to content

Commit 9411237

Browse files
author
Felix Igelbrink
committed
- enabled header embedding for editable installs
- added new embedding option to updated README
1 parent 0d4fb7c commit 9411237

File tree

2 files changed

+44
-17
lines changed

2 files changed

+44
-17
lines changed

README.md

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,58 @@
22

33
Python wrapper for the OptiX 7 raytracing engine.
44

5-
Python-OptiX wraps the OptiX C++ API using Cython and provides a simplified
6-
interface to the original C-like API using the
7-
[CuPy](https://cupy.dev) package.
5+
Python-OptiX wraps the original OptiX C-like API using Cython while aiming to provide a more
6+
pythonic, object-oriented interface using the [CuPy](https://cupy.dev) package.
87

98
### Supported Platforms
109

1110
Only Linux is officially supported at the moment. Experimental windows support is available.
1211

1312
### OptiX Versions
1413

15-
Python-OptiX currently supports the OptiX releases 7.3.0, 7.4.0 and 7.5.0
14+
Python-OptiX always supports the most recent version of the OptiX SDK.
15+
The current version therefore supports OptiX 7.6.0
1616

1717
## Installation
1818

1919
### Dependencies
2020

2121
Install a recent version of the [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads)
22-
and the [OptiX 7.5.0 SDK](https://developer.nvidia.com/optix/downloads/7.5.0/linux64-x86_64)
22+
and the [OptiX 7.6.0 SDK](https://developer.nvidia.com/optix/downloads/7.6.0/linux64-x86_64)
2323

24-
Make sure the CUDA header files are installed as well.
24+
Make sure the CUDA header files are installed as well.
2525

26-
Add the locations of CUDA and OptiX to the system `PATH` variable if necessary.
26+
Note, that for some variants of the CUDA Toolkit,
27+
like the one installed by the `conda` package manager, these are not installed by default.
28+
`conda`-environments require the additional `cudatoolkit-dev` package.
29+
30+
### Environment
31+
32+
`python-optix` requires both the OptiX as well as the CUDA include path during setup as well as runtime
33+
to compile the CUDA kernels. Therefore, it is necessary to either add both locations to the system `PATH`
34+
or set the `CUDA_PATH` and `OPTIX_PATH` variables to the respective locations.
35+
36+
The setup additionally has the option to embed the OptiX header files into the `python-optix` installation.
37+
If the variable `OPTIX_EMBED_HEADERS` is set to `1`, the setup will copy the headers from the
38+
OptiX SDK directory into the generated wheel.
39+
40+
If this option was chosen during setup, setting the `OPTIX_PATH` is no longer required as the
41+
embedded headers will be utilized then.
2742

2843
### Using pip
2944
```
30-
pip install python-optix
45+
export OPTIX_PATH=/path/to/optix
46+
export CUDA_PATH=/path/to/cuda_toolkit
47+
export OPTIX_EMBED_HEADERS=1 # embed the optix headers into the package
48+
python -m pip install python-optix
3149
```
3250

3351
### From source
3452
```
3553
git clone https://github.com/mortacious/python-optix.git
3654
cd python-optix
37-
python setup.py install
55+
export OPTIX_PATH=/path/to/optix
56+
export CUDA_PATH=/path/to/cuda_toolkit
57+
export OPTIX_EMBED_HEADERS=1 # embed the optix headers into the package
58+
python -m pip install [-e] .
3859
```

setup.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ def import_module_from_path(path):
3030

3131

3232
util = import_module_from_path('optix/path_utility.py')
33-
cuda_include_path = util.get_cuda_include_path()
34-
optix_include_path = util.get_optix_include_path()
33+
cuda_include_path = util.get_cuda_include_path(environment_variable='CUDA_PATH')
34+
optix_include_path = util.get_optix_include_path(environement_variable='OPTIX_PATH')
3535
print("Found cuda includes at", cuda_include_path)
3636
print("Found optix includes at", optix_include_path)
3737
if cuda_include_path is None:
38-
raise RuntimeError("CUDA not found in the system, but is required to build this package.")
38+
raise RuntimeError("CUDA not found in the system, but is required to build this package. Consider setting"
39+
"CUDA_PATH to the location of the local cuda toolkit installation.")
3940
if optix_include_path is None:
40-
raise RuntimeError("OptiX not found in the system, but is required to build this package.")
41+
raise RuntimeError("OptiX not found in the system, but is required to build this package. Consider setting "
42+
"OPTIX_PATH to the location of the optix SDK.")
4143

4244
optix_version_re = re.compile(r'.*OPTIX_VERSION +(\d{5})') # get the optix version from the header
4345
with open(Path(optix_include_path) / "optix.h", 'r') as f:
@@ -83,7 +85,7 @@ def glob_fix(package_name, glob):
8385
for path in package_path.glob(glob)]
8486

8587
from setuptools.command.install import install as _install
86-
88+
from setuptools.command.develop import develop as _develop
8789

8890
class EmbeddHeadersCommandMixin:
8991
def update_package_data(self):
@@ -94,7 +96,7 @@ def update_package_data(self):
9496
self.distribution.package_data)
9597

9698
def run(self):
97-
embedd = os.getenv("OPTIX_ADD_HEADERS")
99+
embedd = os.getenv("OPTIX_EMBED_HEADERS")
98100
if embedd:
99101
# create the path for the internal headers
100102
# due to optix license restrictions those headers
@@ -106,15 +108,19 @@ def run(self):
106108

107109
self.update_package_data()
108110

109-
110111
super().run()
111112

112113

113114
class CustomInstallCommand(EmbeddHeadersCommandMixin, _install):
114115
pass
115116

116117

117-
cmd_classes = {'install': CustomInstallCommand}
118+
class CustomDevelopCommand(EmbeddHeadersCommandMixin, _develop):
119+
pass
120+
121+
122+
cmd_classes = {'install': CustomInstallCommand,
123+
'develop': CustomDevelopCommand}
118124

119125
try:
120126
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel

0 commit comments

Comments
 (0)