Skip to content

Commit f6983a7

Browse files
committed
Python - fixes for Linux
1 parent bf1d6fa commit f6983a7

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
project(PyRPR)
33
cmake_minimum_required(VERSION 3.18...3.22)
4-
find_package(Python 3.9 COMPONENTS Interpreter Development.Module REQUIRED)
4+
find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED)
55

66
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
77
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)

python/test/test_script_gltf.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,23 @@
1010
import os
1111

1212
binFolder = ""
13+
pluginFile = ""
1314
if sys.platform == "linux":
1415
binFolder = "binUbuntu20"
16+
pluginFile = "libNorthstar64.so"
1517
elif sys.platform == "win32":
1618
binFolder = "binWin64"
19+
pluginFile = "Northstar64.dll"
1720
else:
1821
binFolder = "binMacOS"
22+
pluginFile = "libNorthstar64.dylib"
1923

2024

2125
# add the RPR Python library folder in order to import the rpr,rprs,rprgltf modules.
2226
if sys.platform == "win32":
2327
sys.path.insert(1, '../../python/build/Release')
24-
28+
else:
29+
sys.path.insert(1, '../../python/build')
2530

2631
# we need to add the RPR DLLs
2732
if sys.platform == "win32":
@@ -48,7 +53,7 @@ def RPRCHECK(retCode):
4853

4954

5055

51-
plugin_id = rpr.RegisterPlugin((str("../../RadeonProRender/" + binFolder + "/Northstar64.dll")))
56+
plugin_id = rpr.RegisterPlugin((str("../../RadeonProRender/" + binFolder+"/"+pluginFile)))
5257
if ( plugin_id == -1 ):
5358
print(f"RPR ERROR: plugin not found.")
5459
exit()
@@ -64,6 +69,10 @@ def RPRCHECK(retCode):
6469
print("RPR context creating...");
6570
flagsCtx = 0
6671
flagsCtx |= int(rpr.CreationFlags.ENABLE_GPU0)
72+
73+
# with Northstar, add this flag to render with OpenCL instead of HIP :
74+
#flagsCtx |= int(rpr.CreationFlags.ENABLE_OPENCL)
75+
6776
newCtx = rpr.Context()
6877
ctxInfo1 = rpr.PyMalloc("../../hipbin")
6978
pluginLists__myarray = np.array([plugin_id], dtype=np.int32)

python/test/test_script_rpr.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,23 @@
1010
import os
1111

1212
binFolder = ""
13+
pluginFile = ""
1314
if sys.platform == "linux":
1415
binFolder = "binUbuntu20"
16+
pluginFile = "libNorthstar64.so"
1517
elif sys.platform == "win32":
1618
binFolder = "binWin64"
19+
pluginFile = "Northstar64.dll"
1720
else:
1821
binFolder = "binMacOS"
22+
pluginFile = "libNorthstar64.dylib"
1923

2024

2125
# add the RPR Python library folder in order to import the rpr,rprs,rprgltf modules.
2226
if sys.platform == "win32":
2327
sys.path.insert(1, '../../python/build/Release')
24-
28+
else:
29+
sys.path.insert(1, '../../python/build')
2530

2631
# we need to add the RPR DLLs
2732
if sys.platform == "win32":
@@ -47,7 +52,7 @@ def RPRCHECK(retCode):
4752

4853

4954

50-
plugin_id = rpr.RegisterPlugin((str("../../RadeonProRender/"+binFolder+"/Northstar64.dll")))
55+
plugin_id = rpr.RegisterPlugin((str("../../RadeonProRender/"+binFolder+"/"+pluginFile)))
5156
if ( plugin_id == -1 ):
5257
print(f"RPR ERROR: plugin not found.")
5358
exit()
@@ -63,6 +68,10 @@ def RPRCHECK(retCode):
6368
print("RPR context creating...");
6469
flagsCtx = 0
6570
flagsCtx |= int(rpr.CreationFlags.ENABLE_GPU0)
71+
72+
# with Northstar, add this flag to render with OpenCL instead of HIP :
73+
#flagsCtx |= int(rpr.CreationFlags.ENABLE_OPENCL)
74+
6675
newCtx = rpr.Context()
6776
ctxInfo1 = rpr.PyMalloc("../../hipbin")
6877
pluginLists__myarray = np.array([plugin_id], dtype=np.int32)

readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,18 @@ Build the RPR binding libraries:
8787
> cmake -Dnanobind_DIR=nanobind/cmake ..
8888
> cmake --build . --config Release
8989
```
90-
Those builds will be generated inside python/build/Release/ they are needed by the python script running RPR in order to execute the:
90+
Those builds will be generated inside python/build/ they are needed by the python script running RPR in order to execute the:
9191
```
9292
import rpr
9393
import rprs
9494
import rprgltf
9595
```
96+
Note that if you have several pythons installed on your system, you may need to define `Python_EXECUTABLE` in the first cmake instruction. Example:
97+
```
98+
cmake -Dnanobind_DIR=nanobind/cmake -DPython_EXECUTABLE=/usr/bin/python3 ..
99+
```
100+
The name of the compatible python version can be found in the name of the generated file. for example `rpr.cpython-38-x86_64-linux-gnu.so` means it's for python 3.8.
101+
96102

97103
Run some test scripts:
98104
```

0 commit comments

Comments
 (0)