Skip to content

Commit 82a80b5

Browse files
committed
Support building wheels (using scikit-build-core)
Also renames panda3d.interrogatedb module to interrogatedb
1 parent c1c3d06 commit 82a80b5

File tree

9 files changed

+94
-11
lines changed

9 files changed

+94
-11
lines changed

cmake/macros/Python.cmake

+9-5
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,20 @@ function(add_python_target target)
2222
return()
2323
endif()
2424

25-
string(REGEX REPLACE "^.*\\." "" basename "${target}")
2625
set(sources)
27-
set(component "Python")
28-
set(export "Python")
26+
set(component "python_modules")
27+
set(export "python_modules")
28+
set(module_name "${target}")
2929
foreach(arg ${ARGN})
3030
if(arg STREQUAL "COMPONENT")
3131
set(keyword "component")
3232

3333
elseif(arg STREQUAL "EXPORT")
3434
set(keyword "export")
3535

36+
elseif(arg STREQUAL "MODULE_NAME")
37+
set(keyword "module_name")
38+
3639
elseif(keyword)
3740
set(${keyword} "${arg}")
3841
unset(keyword)
@@ -43,7 +46,8 @@ function(add_python_target target)
4346
endif()
4447
endforeach(arg)
4548

46-
string(REGEX REPLACE "\\.[^.]+$" "" namespace "${target}")
49+
string(REGEX REPLACE "^.*\\." "" basename "${module_name}")
50+
string(REGEX REPLACE "\\.[^.]+$" "" namespace "${module_name}")
4751
string(REPLACE "." "/" slash_namespace "${namespace}")
4852

4953
if(CMAKE_VERSION VERSION_LESS "3.26")
@@ -57,7 +61,7 @@ function(add_python_target target)
5761
endif()
5862
endif()
5963

60-
if(BUILD_SHARED_LIBS)
64+
if(NOT MODULE_TYPE STREQUAL "STATIC")
6165
set(_outdir "${PANDA_OUTPUT_DIR}/${slash_namespace}")
6266

6367
set_target_properties(${target} PROPERTIES

pyproject.toml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[build-system]
2+
requires = [
3+
"scikit-build-core>=0.9",
4+
]
5+
build-backend = "scikit_build_core.build"
6+
7+
[project]
8+
name = "panda3d-interrogate"
9+
version = "0.0.1"
10+
description = "Binding generator designed for Panda3D"
11+
readme = "README.md"
12+
requires-python = ">=3.2"
13+
license = { "file" = "LICENSE" }
14+
classifiers = [
15+
"Development Status :: 5 - Production/Stable",
16+
"Intended Audience :: Developers",
17+
"License :: OSI Approved :: BSD License",
18+
"Operating System :: OS Independent",
19+
"Programming Language :: C++",
20+
]
21+
22+
[project.urls]
23+
Source = "https://github.com/panda3d/interrogate"
24+
Tracker = "https://github.com/panda3d/interrogate/issues"
25+
Funding = "https://opencollective.com/panda3d"
26+
27+
[project.scripts]
28+
interrogate = "interrogate:main"
29+
interrogate_module = "interrogate_module:main"
30+
31+
[tool.scikit-build]
32+
cmake.version = ">=3.13"
33+
cmake.args = ["-DBUILD_SHARED_LIBS=OFF", "-DHAVE_PYTHON=ON", "-DPYTHON_ARCH_INSTALL_DIR=."]
34+
wheel.py-api = "cp32"
35+
install.components = ["tools", "python_modules"]
36+
37+
[tool.scikit-build.wheel.packages]
38+
interrogate = "python/interrogate"
39+
interrogate_module = "python/interrogate_module"

python/interrogate/__init__.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os
2+
import subprocess
3+
import sys
4+
5+
6+
def _get_executable(name):
7+
return os.path.join(os.path.dirname(__file__), name)
8+
9+
def _run(name):
10+
executable = _get_executable(name)
11+
return subprocess.call([executable] + sys.argv[1:])
12+
13+
def main():
14+
raise SystemExit(_run("interrogate"))

python/interrogate/__main__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import main
2+
3+
main()

python/interrogate_module/__init__.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os
2+
import subprocess
3+
import sys
4+
5+
6+
def _get_executable(name):
7+
return os.path.join(os.path.dirname(__file__), name)
8+
9+
def _run(name):
10+
executable = _get_executable(name)
11+
return subprocess.call([executable] + sys.argv[1:])
12+
13+
def main():
14+
raise SystemExit(_run("interrogate_module"))

python/interrogate_module/__main__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import main
2+
3+
main()

src/LocalSetup.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if(BUILD_SHARED_LIBS)
3636

3737
else()
3838
set(LINK_ALL_STATIC ON)
39-
set(MODULE_TYPE "STATIC"
39+
set(MODULE_TYPE "MODULE"
4040
CACHE INTERNAL "" FORCE)
4141

4242
endif()

src/interrogate/CMakeLists.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,10 @@ else()
119119

120120
endif()
121121

122-
install(TARGETS interrogate interrogate_module DESTINATION ${CMAKE_INSTALL_BINDIR})
123-
install(FILES ${INTERROGATE_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d)
122+
if(SKBUILD)
123+
install(TARGETS interrogate COMPONENT tools DESTINATION interrogate)
124+
install(TARGETS interrogate_module COMPONENT tools DESTINATION interrogate_module)
125+
else()
126+
install(TARGETS interrogate interrogate_module COMPONENT tools DESTINATION ${CMAKE_INSTALL_BINDIR})
127+
install(FILES ${INTERROGATE_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d)
128+
endif()

src/interrogatedb/CMakeLists.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ add_custom_command(
5959
COMMAND host_interrogate
6060
-D EXPCL_INTERROGATEDB=
6161
-nodb -python -promiscuous
62-
-module panda3d.interrogatedb
62+
-module interrogatedb
6363
-library interrogatedb
6464
-string -true-names -do-module
6565
-srcdir "${CMAKE_CURRENT_SOURCE_DIR}"
@@ -69,6 +69,7 @@ add_custom_command(
6969
DEPENDS host_interrogate ${INTERROGATEDB_IGATE}
7070
COMMENT "Interrogating interrogatedb")
7171

72-
add_python_target(panda3d.interrogatedb
72+
add_python_target(interrogatedb_module
73+
MODULE_NAME interrogatedb
7374
"${CMAKE_CURRENT_BINARY_DIR}/interrogatedb_module.cxx")
74-
target_link_libraries(panda3d.interrogatedb PRIVATE interrogatedb)
75+
target_link_libraries(interrogatedb_module PRIVATE interrogatedb)

0 commit comments

Comments
 (0)