-
Notifications
You must be signed in to change notification settings - Fork 0
Make this project a standard python project #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fa02687
made swigbind11 a python project
ramandeepjain c35487f
use relative paths in installations
ramandeepjain 0340794
changed installation path for config.cmake as per previous commit
ramandeepjain 91b9134
update example to install dependencies while building
ramandeepjain 62cf40b
added gitignore
ramandeepjain db56ffc
Update readme
ramandeepjain f3f7251
clean up
ramandeepjain 4eaa1f0
generate swigpyrun.h on fly
ramandeepjain 50e63b4
update version and display version number properly after finding the …
ramandeepjain 1037d01
minor corrections
ramandeepjain a232fcc
implemented suggestions from review
ramandeepjain 625afa8
trying github ci
ramandeepjain eec789c
include example/tests in ci
ramandeepjain 997c6d9
updated versioning and included maximum supported swig version
ramandeepjain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| name: Build and Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.10", "3.12"] | ||
|
|
||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install build dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| # scikit-build-core usually pulls these, but manual install ensures availability | ||
| python -m pip install cmake ninja build | ||
|
|
||
| - name: Build Wheel | ||
| run: python -m build | ||
|
|
||
| - name: Install swigbind11 project | ||
| run: | | ||
| # Install the generated wheel to test the actual build artifact | ||
| python -m pip install dist/*.whl | ||
|
|
||
| - name: Build and install | ||
| run: | | ||
| cd example | ||
| pip install . -v | ||
|
|
||
| - name: Run Pytest | ||
| run: | | ||
| cd example | ||
| pytest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| venv | ||
| build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,76 @@ | ||
| # See the file "LICENSE" for the full license governing this code. | ||
| cmake_minimum_required(VERSION 3.18) | ||
| project(swigbind11) | ||
| project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES CXX) | ||
|
|
||
| enable_language(CXX) | ||
| include(GNUInstallDirs) | ||
| include(CMakePackageConfigHelpers) | ||
|
|
||
| # Generate swigpyrun.h while installing swigbind11 | ||
| find_package(SWIG REQUIRED) | ||
| include(${SWIG_USE_FILE}) | ||
|
|
||
| set(BINARY_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include") | ||
| set(SWIGPYRUN_OUTPUT "${BINARY_INCLUDE_DIR}/swigpyrun.h") | ||
|
|
||
| file(MAKE_DIRECTORY ${BINARY_INCLUDE_DIR}) | ||
|
|
||
| add_custom_command( | ||
| OUTPUT ${SWIGPYRUN_OUTPUT} | ||
| COMMAND ${SWIG_EXECUTABLE} -python -external-runtime ${SWIGPYRUN_OUTPUT} | ||
| COMMENT "Generating swigpyrun.h" | ||
| VERBATIM | ||
| ) | ||
|
|
||
| add_custom_target(generate_swigpyrun ALL DEPENDS ${SWIGPYRUN_OUTPUT}) | ||
|
|
||
| # # Use relative paths for DESTINATION to ensure the package is relocatable. | ||
| set(swigbind11_REL_ROOT "swigbind11") | ||
|
|
||
| # --- Library Targets --- | ||
| add_library(swigbind11 INTERFACE) | ||
| add_library(swigbind11::swigbind11 ALIAS swigbind11) | ||
| add_library(swigbind11::headers ALIAS swigbind11) | ||
|
|
||
| include(GNUInstallDirs) | ||
|
|
||
| target_include_directories( | ||
| swigbind11 INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
| $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
| swigbind11 INTERFACE | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> | ||
| $<INSTALL_INTERFACE:${swigbind11_REL_ROOT}/include> | ||
| ) | ||
|
|
||
| target_compile_features(swigbind11 INTERFACE cxx_std_17) | ||
|
|
||
| install(TARGETS swigbind11) | ||
| set(swigbind11_INCLUDE_DIR "\$\{PACKAGE_PREFIX_DIR\}/swigbind11/include") | ||
| set(swigbind11_REL_CMAKE_DEST "${swigbind11_REL_ROOT}/share/cmake") | ||
|
|
||
| # --- Configuration Files --- | ||
| configure_package_config_file( | ||
| "tools/${PROJECT_NAME}Config.cmake.in" | ||
| "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | ||
| INSTALL_DESTINATION "${swigbind11_REL_CMAKE_DEST}" | ||
| ) | ||
|
|
||
| # --- Installation Logic --- | ||
|
|
||
| # 1. Install Python source files (the __init__.py and other scripts) | ||
| install(DIRECTORY "swigbind11/" | ||
| DESTINATION "${swigbind11_REL_ROOT}") | ||
|
|
||
| # 2. Install C++ Headers into swigbind11/include/ | ||
| install(DIRECTORY "include/swigbind11" | ||
| DESTINATION "${swigbind11_REL_ROOT}/include") | ||
|
|
||
| install(FILES ${SWIGPYRUN_OUTPUT} DESTINATION "${swigbind11_REL_ROOT}/include/swigbind11") | ||
|
|
||
| # 3. Install CMake Config into swigbind11/share/cmake/ | ||
| install(TARGETS swigbind11 EXPORT swigbind11Targets) | ||
|
|
||
| install(EXPORT swigbind11Targets | ||
| FILE swigbind11Targets.cmake | ||
| NAMESPACE swigbind11:: | ||
| DESTINATION "${swigbind11_REL_CMAKE_DEST}" | ||
| ) | ||
|
|
||
| install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | ||
| DESTINATION "${swigbind11_REL_CMAKE_DEST}") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| """ | ||
| Custom build backend for scikit-build-core. | ||
|
|
||
| This module acts as a wrapper around scikit-build-core to handle local | ||
| dependencies that are not yet available on PyPI. It specifically allows | ||
| the injection of 'swigbind11' from a relative path, bypassing the | ||
| limitation in scikit-build-core which disallows relative paths in | ||
| the 'build-system.requires' section of pyproject.toml. | ||
| """ | ||
| import os | ||
|
ramandeepjain marked this conversation as resolved.
|
||
| from scikit_build_core.build import * | ||
|
|
||
| def get_requires_for_build_wheel(config_settings=None): | ||
| """ | ||
| Return a list of dependencies required to build the wheel. | ||
|
|
||
| This dynamically locates 'swigbind11' relative to this | ||
| script's directory and appends it to the build requirements as absolute path. | ||
| """ | ||
| from scikit_build_core.build import get_requires_for_build_wheel as _get_reqs | ||
| reqs = _get_reqs(config_settings) | ||
|
|
||
| # Dynamically find the swigbind11 relative to this file | ||
| base_dir = os.path.dirname(os.path.abspath(__file__)) | ||
| local_dep = os.path.abspath(os.path.join(base_dir, "..")) | ||
|
|
||
| reqs.append(f"swigbind11 @ file://{local_dep}") | ||
| return reqs | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.