easybind 0.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- easybind-0.1.6/.clangd +2 -0
- easybind-0.1.6/.github/workflows/publish.yml +45 -0
- easybind-0.1.6/.gitignore +212 -0
- easybind-0.1.6/.vscode/tasks.json +16 -0
- easybind-0.1.6/CMakeLists.txt +331 -0
- easybind-0.1.6/LICENSE +201 -0
- easybind-0.1.6/NOTICE +91 -0
- easybind-0.1.6/PKG-INFO +139 -0
- easybind-0.1.6/README.md +111 -0
- easybind-0.1.6/RELEASING.md +39 -0
- easybind-0.1.6/cmake/easybindConfig.cmake.in +57 -0
- easybind-0.1.6/pyproject.toml +83 -0
- easybind-0.1.6/scripts/clangd-update.sh +18 -0
- easybind-0.1.6/src/easybind/__init__.cpp +5 -0
- easybind-0.1.6/src/easybind/bind.hpp +30 -0
- easybind-0.1.6/src/easybind/export.hpp +26 -0
- easybind-0.1.6/src/easybind/module/__init__.cpp +11 -0
- easybind-0.1.6/src/easybind/module/node.cpp +353 -0
- easybind-0.1.6/src/easybind/module/node.hpp +91 -0
- easybind-0.1.6/src/easybind/module/node__init__.cpp +35 -0
- easybind-0.1.6/src/easybind/module/ns_module.hpp +87 -0
- easybind-0.1.6/src/easybind/py.typed +1 -0
- easybind-0.1.6/src/easybind/sample/__init__.cpp +97 -0
- easybind-0.1.6/src/easybind/sample/sample.cpp +115 -0
- easybind-0.1.6/src/easybind/sample/sample.hpp +102 -0
- easybind-0.1.6/src/easybind/sample/test1.py +1 -0
- easybind-0.1.6/src/easybind/sample/test2/__init__.py +1 -0
- easybind-0.1.6/tests/test_sample.py +42 -0
easybind-0.1.6/.clangd
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Build sdist + manylinux_2_28 x86_64 wheels (cibuildwheel), upload to PyPI on tag v*.
|
|
2
|
+
# PyPA does not publish manylinux_2_27 images; manylinux_2_28 is the closest official policy.
|
|
3
|
+
# Requires repository secret: PYPI_API_TOKEN
|
|
4
|
+
|
|
5
|
+
name: Publish to PyPI
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
tags:
|
|
10
|
+
- "v*"
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
publish:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0
|
|
22
|
+
|
|
23
|
+
- uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.12"
|
|
26
|
+
|
|
27
|
+
- name: Install build tools
|
|
28
|
+
run: pip install --upgrade build twine
|
|
29
|
+
|
|
30
|
+
- name: Build sdist
|
|
31
|
+
run: python -m build --sdist
|
|
32
|
+
|
|
33
|
+
- name: Build manylinux wheels
|
|
34
|
+
uses: pypa/cibuildwheel@v3.4.0
|
|
35
|
+
|
|
36
|
+
- name: Stage wheels next to sdist
|
|
37
|
+
run: cp wheelhouse/*.whl dist/
|
|
38
|
+
|
|
39
|
+
- name: Check distributions
|
|
40
|
+
run: twine check dist/*
|
|
41
|
+
|
|
42
|
+
- name: Publish to PyPI
|
|
43
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
44
|
+
with:
|
|
45
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
**/*.pyi
|
|
2
|
+
|
|
3
|
+
# Generated by setuptools-scm at build time (see pyproject.toml).
|
|
4
|
+
src/easybind/_version.py
|
|
5
|
+
|
|
6
|
+
# Byte-compiled / optimized / DLL files
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[codz]
|
|
9
|
+
*$py.class
|
|
10
|
+
|
|
11
|
+
# C extensions
|
|
12
|
+
*.so
|
|
13
|
+
|
|
14
|
+
# Distribution / packaging
|
|
15
|
+
.Python
|
|
16
|
+
build/
|
|
17
|
+
develop-eggs/
|
|
18
|
+
dist/
|
|
19
|
+
downloads/
|
|
20
|
+
eggs/
|
|
21
|
+
.eggs/
|
|
22
|
+
lib/
|
|
23
|
+
lib64/
|
|
24
|
+
parts/
|
|
25
|
+
sdist/
|
|
26
|
+
var/
|
|
27
|
+
wheels/
|
|
28
|
+
share/python-wheels/
|
|
29
|
+
*.egg-info/
|
|
30
|
+
.installed.cfg
|
|
31
|
+
*.egg
|
|
32
|
+
MANIFEST
|
|
33
|
+
|
|
34
|
+
# PyInstaller
|
|
35
|
+
# Usually these files are written by a python script from a template
|
|
36
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
37
|
+
*.manifest
|
|
38
|
+
*.spec
|
|
39
|
+
|
|
40
|
+
# Installer logs
|
|
41
|
+
pip-log.txt
|
|
42
|
+
pip-delete-this-directory.txt
|
|
43
|
+
|
|
44
|
+
# Unit test / coverage reports
|
|
45
|
+
htmlcov/
|
|
46
|
+
.tox/
|
|
47
|
+
.nox/
|
|
48
|
+
.coverage
|
|
49
|
+
.coverage.*
|
|
50
|
+
.cache
|
|
51
|
+
nosetests.xml
|
|
52
|
+
coverage.xml
|
|
53
|
+
*.cover
|
|
54
|
+
*.py.cover
|
|
55
|
+
.hypothesis/
|
|
56
|
+
.pytest_cache/
|
|
57
|
+
cover/
|
|
58
|
+
|
|
59
|
+
# Translations
|
|
60
|
+
*.mo
|
|
61
|
+
*.pot
|
|
62
|
+
|
|
63
|
+
# Django stuff:
|
|
64
|
+
*.log
|
|
65
|
+
local_settings.py
|
|
66
|
+
db.sqlite3
|
|
67
|
+
db.sqlite3-journal
|
|
68
|
+
|
|
69
|
+
# Flask stuff:
|
|
70
|
+
instance/
|
|
71
|
+
.webassets-cache
|
|
72
|
+
|
|
73
|
+
# Scrapy stuff:
|
|
74
|
+
.scrapy
|
|
75
|
+
|
|
76
|
+
# Sphinx documentation
|
|
77
|
+
docs/_build/
|
|
78
|
+
|
|
79
|
+
# PyBuilder
|
|
80
|
+
.pybuilder/
|
|
81
|
+
target/
|
|
82
|
+
|
|
83
|
+
# Jupyter Notebook
|
|
84
|
+
.ipynb_checkpoints
|
|
85
|
+
|
|
86
|
+
# IPython
|
|
87
|
+
profile_default/
|
|
88
|
+
ipython_config.py
|
|
89
|
+
|
|
90
|
+
# pyenv
|
|
91
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
92
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
93
|
+
# .python-version
|
|
94
|
+
|
|
95
|
+
# pipenv
|
|
96
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
97
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
98
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
99
|
+
# install all needed dependencies.
|
|
100
|
+
#Pipfile.lock
|
|
101
|
+
|
|
102
|
+
# UV
|
|
103
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
104
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
105
|
+
# commonly ignored for libraries.
|
|
106
|
+
#uv.lock
|
|
107
|
+
|
|
108
|
+
# poetry
|
|
109
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
110
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
111
|
+
# commonly ignored for libraries.
|
|
112
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
113
|
+
#poetry.lock
|
|
114
|
+
#poetry.toml
|
|
115
|
+
|
|
116
|
+
# pdm
|
|
117
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
118
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
119
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
120
|
+
#pdm.lock
|
|
121
|
+
#pdm.toml
|
|
122
|
+
.pdm-python
|
|
123
|
+
.pdm-build/
|
|
124
|
+
|
|
125
|
+
# pixi
|
|
126
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
127
|
+
#pixi.lock
|
|
128
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
129
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
130
|
+
.pixi
|
|
131
|
+
|
|
132
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
133
|
+
__pypackages__/
|
|
134
|
+
|
|
135
|
+
# Celery stuff
|
|
136
|
+
celerybeat-schedule
|
|
137
|
+
celerybeat.pid
|
|
138
|
+
|
|
139
|
+
# SageMath parsed files
|
|
140
|
+
*.sage.py
|
|
141
|
+
|
|
142
|
+
# Environments
|
|
143
|
+
.env
|
|
144
|
+
.envrc
|
|
145
|
+
.venv
|
|
146
|
+
env/
|
|
147
|
+
venv/
|
|
148
|
+
ENV/
|
|
149
|
+
env.bak/
|
|
150
|
+
venv.bak/
|
|
151
|
+
|
|
152
|
+
# Spyder project settings
|
|
153
|
+
.spyderproject
|
|
154
|
+
.spyproject
|
|
155
|
+
|
|
156
|
+
# Rope project settings
|
|
157
|
+
.ropeproject
|
|
158
|
+
|
|
159
|
+
# mkdocs documentation
|
|
160
|
+
/site
|
|
161
|
+
|
|
162
|
+
# mypy
|
|
163
|
+
.mypy_cache/
|
|
164
|
+
.dmypy.json
|
|
165
|
+
dmypy.json
|
|
166
|
+
|
|
167
|
+
# Pyre type checker
|
|
168
|
+
.pyre/
|
|
169
|
+
|
|
170
|
+
# pytype static type analyzer
|
|
171
|
+
.pytype/
|
|
172
|
+
|
|
173
|
+
# Cython debug symbols
|
|
174
|
+
cython_debug/
|
|
175
|
+
|
|
176
|
+
# PyCharm
|
|
177
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
178
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
179
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
180
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
181
|
+
#.idea/
|
|
182
|
+
|
|
183
|
+
# Abstra
|
|
184
|
+
# Abstra is an AI-powered process automation framework.
|
|
185
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
186
|
+
# Learn more at https://abstra.io/docs
|
|
187
|
+
.abstra/
|
|
188
|
+
|
|
189
|
+
# Visual Studio Code
|
|
190
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
191
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
192
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
193
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
194
|
+
# .vscode/
|
|
195
|
+
|
|
196
|
+
# Ruff stuff:
|
|
197
|
+
.ruff_cache/
|
|
198
|
+
|
|
199
|
+
# PyPI configuration file
|
|
200
|
+
.pypirc
|
|
201
|
+
|
|
202
|
+
# Cursor
|
|
203
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
204
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
205
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
206
|
+
.cursorignore
|
|
207
|
+
.cursorindexingignore
|
|
208
|
+
|
|
209
|
+
# Marimo
|
|
210
|
+
marimo/_static/
|
|
211
|
+
marimo/_lsp/
|
|
212
|
+
__marimo__/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"label": "clangd: compile_commands (fallback cmake, no pip)",
|
|
6
|
+
"type": "shell",
|
|
7
|
+
"command": "bash",
|
|
8
|
+
"args": ["scripts/clangd-update.sh"],
|
|
9
|
+
"problemMatcher": [],
|
|
10
|
+
"presentation": {
|
|
11
|
+
"reveal": "always",
|
|
12
|
+
"panel": "shared"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.25)
|
|
2
|
+
|
|
3
|
+
project(easybind LANGUAGES CXX)
|
|
4
|
+
|
|
5
|
+
include(GNUInstallDirs)
|
|
6
|
+
include(FetchContent)
|
|
7
|
+
|
|
8
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
9
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
10
|
+
|
|
11
|
+
option(EASYBIND_SKIP_INSTALL "Skip installing easybind artifacts" OFF)
|
|
12
|
+
if(NOT PROJECT_IS_TOP_LEVEL)
|
|
13
|
+
set(EASYBIND_SKIP_INSTALL ON)
|
|
14
|
+
endif()
|
|
15
|
+
|
|
16
|
+
# Ensure Python development headers/targets are available for nanobind + modules.
|
|
17
|
+
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
|
|
18
|
+
|
|
19
|
+
# Prefer Python::Module (extension modules), fall back to Python::Python.
|
|
20
|
+
set(EASYBIND_PYTHON_TARGET "")
|
|
21
|
+
if(TARGET Python::Module)
|
|
22
|
+
set(EASYBIND_PYTHON_TARGET Python::Module)
|
|
23
|
+
elseif(TARGET Python::Python)
|
|
24
|
+
set(EASYBIND_PYTHON_TARGET Python::Python)
|
|
25
|
+
else()
|
|
26
|
+
message(FATAL_ERROR "Python imported target not found (expected Python::Module or Python::Python)")
|
|
27
|
+
endif()
|
|
28
|
+
|
|
29
|
+
# Nanobind - fetch so builds don't depend on a preinstalled CMake package.
|
|
30
|
+
FetchContent_Declare(
|
|
31
|
+
nanobind
|
|
32
|
+
GIT_REPOSITORY https://github.com/wjakob/nanobind.git
|
|
33
|
+
GIT_TAG v2.12.0
|
|
34
|
+
)
|
|
35
|
+
FetchContent_MakeAvailable(nanobind)
|
|
36
|
+
|
|
37
|
+
FetchContent_Declare(
|
|
38
|
+
magic_enum
|
|
39
|
+
GIT_REPOSITORY https://github.com/Neargye/magic_enum.git
|
|
40
|
+
GIT_TAG v0.9.7
|
|
41
|
+
)
|
|
42
|
+
FetchContent_MakeAvailable(magic_enum)
|
|
43
|
+
|
|
44
|
+
FetchContent_Declare(
|
|
45
|
+
reflect_cpp
|
|
46
|
+
GIT_REPOSITORY https://github.com/getml/reflect-cpp.git
|
|
47
|
+
GIT_TAG v0.24.0
|
|
48
|
+
)
|
|
49
|
+
FetchContent_MakeAvailable(reflect_cpp)
|
|
50
|
+
|
|
51
|
+
# Some nanobind configurations don't automatically attach Python include dirs.
|
|
52
|
+
foreach(_nb_tgt IN ITEMS nanobind nanobind_shared nanobind-static)
|
|
53
|
+
if(TARGET ${_nb_tgt})
|
|
54
|
+
target_link_libraries(${_nb_tgt} PRIVATE ${EASYBIND_PYTHON_TARGET})
|
|
55
|
+
set_target_properties(${_nb_tgt} PROPERTIES
|
|
56
|
+
CXX_VISIBILITY_PRESET default
|
|
57
|
+
VISIBILITY_INLINES_HIDDEN OFF
|
|
58
|
+
)
|
|
59
|
+
target_compile_options(${_nb_tgt} PRIVATE
|
|
60
|
+
$<$<CXX_COMPILER_ID:GNU,Clang>:-fvisibility=default>
|
|
61
|
+
)
|
|
62
|
+
endif()
|
|
63
|
+
endforeach()
|
|
64
|
+
|
|
65
|
+
function(easybind_add_extension target_name)
|
|
66
|
+
nanobind_add_module(${target_name} NB_SHARED ${ARGN})
|
|
67
|
+
target_link_libraries(${target_name} PRIVATE ${EASYBIND_PYTHON_TARGET})
|
|
68
|
+
if(APPLE)
|
|
69
|
+
set_target_properties(${target_name} PROPERTIES
|
|
70
|
+
BUILD_RPATH "@loader_path"
|
|
71
|
+
INSTALL_RPATH "@loader_path"
|
|
72
|
+
)
|
|
73
|
+
else()
|
|
74
|
+
set_target_properties(${target_name} PROPERTIES
|
|
75
|
+
BUILD_RPATH "$ORIGIN"
|
|
76
|
+
INSTALL_RPATH "$ORIGIN"
|
|
77
|
+
)
|
|
78
|
+
endif()
|
|
79
|
+
endfunction()
|
|
80
|
+
|
|
81
|
+
add_library(easybind__module__ SHARED
|
|
82
|
+
src/easybind/module/node.cpp
|
|
83
|
+
)
|
|
84
|
+
set_target_properties(easybind__module__ PROPERTIES
|
|
85
|
+
OUTPUT_NAME "easybind"
|
|
86
|
+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/easybind"
|
|
87
|
+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/easybind"
|
|
88
|
+
)
|
|
89
|
+
target_include_directories(easybind__module__ PRIVATE
|
|
90
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
91
|
+
)
|
|
92
|
+
target_compile_definitions(easybind__module__ PRIVATE EASYBIND_BUILD)
|
|
93
|
+
if(DEFINED nanobind_SOURCE_DIR)
|
|
94
|
+
target_include_directories(easybind__module__ PRIVATE
|
|
95
|
+
${nanobind_SOURCE_DIR}/include
|
|
96
|
+
)
|
|
97
|
+
endif()
|
|
98
|
+
target_link_libraries(easybind__module__ PRIVATE ${EASYBIND_PYTHON_TARGET})
|
|
99
|
+
if(TARGET nanobind)
|
|
100
|
+
target_link_libraries(easybind__module__ PRIVATE nanobind)
|
|
101
|
+
add_dependencies(easybind__module__ nanobind)
|
|
102
|
+
elseif(TARGET nanobind_shared)
|
|
103
|
+
target_link_libraries(easybind__module__ PRIVATE nanobind_shared)
|
|
104
|
+
add_dependencies(easybind__module__ nanobind_shared)
|
|
105
|
+
elseif(TARGET nanobind-static)
|
|
106
|
+
target_link_libraries(easybind__module__ PRIVATE nanobind-static)
|
|
107
|
+
target_compile_definitions(easybind__module__ PRIVATE NB_STATIC)
|
|
108
|
+
add_dependencies(easybind__module__ nanobind-static)
|
|
109
|
+
endif()
|
|
110
|
+
if(APPLE)
|
|
111
|
+
set_target_properties(easybind__module__ PROPERTIES
|
|
112
|
+
BUILD_RPATH "@loader_path"
|
|
113
|
+
INSTALL_RPATH "@loader_path"
|
|
114
|
+
)
|
|
115
|
+
else()
|
|
116
|
+
set_target_properties(easybind__module__ PROPERTIES
|
|
117
|
+
BUILD_RPATH "$ORIGIN"
|
|
118
|
+
INSTALL_RPATH "$ORIGIN"
|
|
119
|
+
)
|
|
120
|
+
endif()
|
|
121
|
+
set_target_properties(easybind__module__ PROPERTIES
|
|
122
|
+
CXX_VISIBILITY_PRESET hidden
|
|
123
|
+
VISIBILITY_INLINES_HIDDEN ON
|
|
124
|
+
)
|
|
125
|
+
target_compile_options(easybind__module__ PRIVATE
|
|
126
|
+
$<$<CXX_COMPILER_ID:GNU,Clang>:-fvisibility=hidden>
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
add_library(easybind_sample__module__ SHARED
|
|
130
|
+
src/easybind/sample/sample.cpp
|
|
131
|
+
)
|
|
132
|
+
set_target_properties(easybind_sample__module__ PROPERTIES
|
|
133
|
+
OUTPUT_NAME "easybind-sample"
|
|
134
|
+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/easybind/sample"
|
|
135
|
+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/easybind/sample"
|
|
136
|
+
)
|
|
137
|
+
target_include_directories(easybind_sample__module__ PRIVATE
|
|
138
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
139
|
+
)
|
|
140
|
+
if(TARGET magic_enum::magic_enum)
|
|
141
|
+
target_link_libraries(easybind_sample__module__ PRIVATE magic_enum::magic_enum)
|
|
142
|
+
target_include_directories(easybind_sample__module__ PRIVATE
|
|
143
|
+
${magic_enum_SOURCE_DIR}/include
|
|
144
|
+
)
|
|
145
|
+
else()
|
|
146
|
+
target_include_directories(easybind_sample__module__ PRIVATE
|
|
147
|
+
${magic_enum_SOURCE_DIR}/include
|
|
148
|
+
)
|
|
149
|
+
endif()
|
|
150
|
+
target_compile_definitions(easybind_sample__module__ PRIVATE EASYBIND_SAMPLE_BUILD)
|
|
151
|
+
if(APPLE)
|
|
152
|
+
set_target_properties(easybind_sample__module__ PROPERTIES
|
|
153
|
+
BUILD_RPATH "@loader_path"
|
|
154
|
+
INSTALL_RPATH "@loader_path"
|
|
155
|
+
)
|
|
156
|
+
else()
|
|
157
|
+
set_target_properties(easybind_sample__module__ PROPERTIES
|
|
158
|
+
BUILD_RPATH "$ORIGIN"
|
|
159
|
+
INSTALL_RPATH "$ORIGIN"
|
|
160
|
+
)
|
|
161
|
+
endif()
|
|
162
|
+
set_target_properties(easybind_sample__module__ PROPERTIES
|
|
163
|
+
CXX_VISIBILITY_PRESET hidden
|
|
164
|
+
VISIBILITY_INLINES_HIDDEN ON
|
|
165
|
+
)
|
|
166
|
+
target_compile_options(easybind_sample__module__ PRIVATE
|
|
167
|
+
$<$<CXX_COMPILER_ID:GNU,Clang>:-fvisibility=hidden>
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
easybind_add_extension(easybind_sample__init__
|
|
171
|
+
src/easybind/sample/__init__.cpp
|
|
172
|
+
)
|
|
173
|
+
target_link_libraries(easybind_sample__init__ PRIVATE
|
|
174
|
+
easybind__module__
|
|
175
|
+
easybind_sample__module__
|
|
176
|
+
)
|
|
177
|
+
set_target_properties(easybind_sample__init__ PROPERTIES
|
|
178
|
+
OUTPUT_NAME "__init__"
|
|
179
|
+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/easybind/sample"
|
|
180
|
+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/easybind/sample"
|
|
181
|
+
)
|
|
182
|
+
target_include_directories(easybind_sample__init__ PRIVATE
|
|
183
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
184
|
+
)
|
|
185
|
+
if(TARGET magic_enum::magic_enum)
|
|
186
|
+
target_link_libraries(easybind_sample__init__ PRIVATE magic_enum::magic_enum)
|
|
187
|
+
target_include_directories(easybind_sample__init__ PRIVATE
|
|
188
|
+
${magic_enum_SOURCE_DIR}/include
|
|
189
|
+
)
|
|
190
|
+
else()
|
|
191
|
+
target_include_directories(easybind_sample__init__ PRIVATE
|
|
192
|
+
${magic_enum_SOURCE_DIR}/include
|
|
193
|
+
)
|
|
194
|
+
endif()
|
|
195
|
+
if(DEFINED reflect_cpp_SOURCE_DIR)
|
|
196
|
+
target_include_directories(easybind_sample__init__ PRIVATE
|
|
197
|
+
${reflect_cpp_SOURCE_DIR}/include
|
|
198
|
+
)
|
|
199
|
+
endif()
|
|
200
|
+
# sample/__init__.so lives in easybind/sample/; it links libeasybind-sample.so (same
|
|
201
|
+
# dir), libeasybind.so + libnanobind.so (parent). RPATH needs BOTH $ORIGIN and
|
|
202
|
+
# $ORIGIN/.. or auditwheel cannot resolve libeasybind-sample.so (path null).
|
|
203
|
+
if(APPLE)
|
|
204
|
+
set_target_properties(easybind_sample__init__ PROPERTIES
|
|
205
|
+
BUILD_RPATH "@loader_path;@loader_path/.."
|
|
206
|
+
INSTALL_RPATH "@loader_path;@loader_path/.."
|
|
207
|
+
)
|
|
208
|
+
elseif(UNIX)
|
|
209
|
+
set_target_properties(easybind_sample__init__ PROPERTIES
|
|
210
|
+
BUILD_RPATH "$ORIGIN;$ORIGIN/.."
|
|
211
|
+
INSTALL_RPATH "$ORIGIN;$ORIGIN/.."
|
|
212
|
+
)
|
|
213
|
+
else()
|
|
214
|
+
set_target_properties(easybind_sample__init__ PROPERTIES
|
|
215
|
+
BUILD_RPATH "$ORIGIN"
|
|
216
|
+
INSTALL_RPATH "$ORIGIN"
|
|
217
|
+
)
|
|
218
|
+
endif()
|
|
219
|
+
|
|
220
|
+
if(NOT EASYBIND_SKIP_INSTALL)
|
|
221
|
+
install(TARGETS easybind_sample__module__
|
|
222
|
+
LIBRARY DESTINATION easybind/sample
|
|
223
|
+
RUNTIME DESTINATION easybind/sample
|
|
224
|
+
ARCHIVE DESTINATION easybind/sample
|
|
225
|
+
)
|
|
226
|
+
install(TARGETS easybind_sample__init__
|
|
227
|
+
LIBRARY DESTINATION easybind/sample
|
|
228
|
+
RUNTIME DESTINATION easybind/sample
|
|
229
|
+
ARCHIVE DESTINATION easybind/sample
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
# If nanobind is built as a shared library, ship it alongside extensions so
|
|
233
|
+
# `libnanobind.so` is resolvable at runtime.
|
|
234
|
+
if(TARGET nanobind)
|
|
235
|
+
install(TARGETS nanobind
|
|
236
|
+
LIBRARY DESTINATION easybind
|
|
237
|
+
RUNTIME DESTINATION easybind
|
|
238
|
+
ARCHIVE DESTINATION easybind
|
|
239
|
+
)
|
|
240
|
+
endif()
|
|
241
|
+
endif()
|
|
242
|
+
|
|
243
|
+
easybind_add_extension(easybind__init__
|
|
244
|
+
src/easybind/__init__.cpp
|
|
245
|
+
src/easybind/module/__init__.cpp
|
|
246
|
+
src/easybind/module/node__init__.cpp
|
|
247
|
+
)
|
|
248
|
+
target_link_libraries(easybind__init__ PRIVATE easybind__module__)
|
|
249
|
+
set_target_properties(easybind__init__ PROPERTIES
|
|
250
|
+
OUTPUT_NAME "__init__"
|
|
251
|
+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/easybind"
|
|
252
|
+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/easybind"
|
|
253
|
+
)
|
|
254
|
+
target_include_directories(easybind__init__ PRIVATE
|
|
255
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
256
|
+
)
|
|
257
|
+
if(TARGET magic_enum::magic_enum)
|
|
258
|
+
target_link_libraries(easybind__init__ PRIVATE magic_enum::magic_enum)
|
|
259
|
+
target_include_directories(easybind__init__ PRIVATE
|
|
260
|
+
${magic_enum_SOURCE_DIR}/include
|
|
261
|
+
)
|
|
262
|
+
else()
|
|
263
|
+
target_include_directories(easybind__init__ PRIVATE
|
|
264
|
+
${magic_enum_SOURCE_DIR}/include
|
|
265
|
+
)
|
|
266
|
+
endif()
|
|
267
|
+
if(DEFINED reflect_cpp_SOURCE_DIR)
|
|
268
|
+
target_include_directories(easybind__init__ PRIVATE
|
|
269
|
+
${reflect_cpp_SOURCE_DIR}/include
|
|
270
|
+
)
|
|
271
|
+
endif()
|
|
272
|
+
if(APPLE)
|
|
273
|
+
set_target_properties(easybind__init__ PROPERTIES
|
|
274
|
+
BUILD_RPATH "@loader_path"
|
|
275
|
+
INSTALL_RPATH "@loader_path"
|
|
276
|
+
)
|
|
277
|
+
else()
|
|
278
|
+
set_target_properties(easybind__init__ PROPERTIES
|
|
279
|
+
BUILD_RPATH "$ORIGIN"
|
|
280
|
+
INSTALL_RPATH "$ORIGIN"
|
|
281
|
+
)
|
|
282
|
+
endif()
|
|
283
|
+
|
|
284
|
+
# Build-time stub generation (package layout).
|
|
285
|
+
function(easybind_add_stub_package stub_target_prefix module_target)
|
|
286
|
+
foreach(module_name IN LISTS ARGN)
|
|
287
|
+
string(REPLACE "." "/" module_path "${module_name}")
|
|
288
|
+
set(output_path "${CMAKE_CURRENT_SOURCE_DIR}/src/${module_path}/__init__.pyi")
|
|
289
|
+
get_filename_component(output_dir "${output_path}" DIRECTORY)
|
|
290
|
+
file(MAKE_DIRECTORY "${output_dir}")
|
|
291
|
+
|
|
292
|
+
string(REPLACE "." "_" module_target_suffix "${module_name}")
|
|
293
|
+
set(stub_target "${stub_target_prefix}_${module_target_suffix}_stub")
|
|
294
|
+
|
|
295
|
+
nanobind_add_stub(${stub_target}
|
|
296
|
+
MODULE ${module_name}
|
|
297
|
+
OUTPUT ${output_path}
|
|
298
|
+
PYTHON_PATH $<TARGET_FILE_DIR:${module_target}>
|
|
299
|
+
DEPENDS ${module_target}
|
|
300
|
+
)
|
|
301
|
+
endforeach()
|
|
302
|
+
endfunction()
|
|
303
|
+
|
|
304
|
+
easybind_add_stub_package(easybind
|
|
305
|
+
easybind__init__
|
|
306
|
+
easybind
|
|
307
|
+
easybind.module)
|
|
308
|
+
easybind_add_stub_package(easybind_sample
|
|
309
|
+
easybind_sample__init__
|
|
310
|
+
easybind.sample)
|
|
311
|
+
|
|
312
|
+
if(NOT EASYBIND_SKIP_INSTALL)
|
|
313
|
+
install(TARGETS easybind__module__
|
|
314
|
+
LIBRARY DESTINATION easybind
|
|
315
|
+
RUNTIME DESTINATION easybind
|
|
316
|
+
ARCHIVE DESTINATION easybind
|
|
317
|
+
)
|
|
318
|
+
install(TARGETS easybind__init__
|
|
319
|
+
LIBRARY DESTINATION easybind
|
|
320
|
+
RUNTIME DESTINATION easybind
|
|
321
|
+
ARCHIVE DESTINATION easybind
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
install(DIRECTORY src/easybind
|
|
325
|
+
DESTINATION .
|
|
326
|
+
)
|
|
327
|
+
# Third-party licenses (nanobind, magic_enum, reflect-cpp): see NOTICE.
|
|
328
|
+
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/NOTICE"
|
|
329
|
+
DESTINATION easybind
|
|
330
|
+
)
|
|
331
|
+
endif()
|