From 15ee98919fa4341ca8f38ac8eaef6a49a043e5e6 Mon Sep 17 00:00:00 2001 From: Tim Paine <3105306+timkpaine@users.noreply.github.com> Date: Sun, 12 Jan 2025 19:45:47 -0500 Subject: [PATCH] Reenable cpp template with hatch-cpp --- cpp/.github/workflows/build.yml | 482 ------------------ cpp/.github/workflows/build.yml.jinja | 138 +++++ cpp/.gitignore.jinja | 151 ++++++ cpp/CMakeLists.txt | 324 ------------ cpp/MANIFEST.in | 40 -- cpp/Makefile | 80 --- cpp/Makefile.jinja | 139 +++++ cpp/cmake/config/CppTemplate.pc.in | 10 - cpp/cmake/config/CppTemplateConfig.cmake.in | 12 - cpp/cmake/modules/FindColor.cmake | 14 - cpp/cmake/modules/FindCppTemplate.cmake | 30 -- cpp/cmake/modules/FindNumPy.cmake | 30 -- cpp/cmake/modules/FindPythonHeaders.cmake | 270 ---------- cpp/cpp/cpp-template/cpp-template.hpp | 5 - cpp/cpp/cpp-template/exports.hpp | 22 - .../{cpp-template.cpp => extension.cpp} | 2 +- .../cpp-template/{python => }/extension.hpp | 3 +- cpp/cpp/cpp-template/python/extension.cpp | 1 - cpp/pyproject.toml | 133 ----- cpp/pyproject.toml.jinja | 147 ++++++ cpp/setup.py | 25 - cpp/{cpp_template => {{module}}}/__init__.py | 2 +- .../tests/test_all.py.jinja} | 2 +- js/pyproject.toml.jinja | 1 - js/setup.py | 1 - jupyter/pyproject.toml.jinja | 1 - jupyter/setup.py | 1 - python/pyproject.toml.jinja | 1 - python/setup.py | 1 - rust/pyproject.toml.jinja | 1 - rust/setup.py | 1 - 31 files changed, 580 insertions(+), 1490 deletions(-) delete mode 100644 cpp/.github/workflows/build.yml create mode 100644 cpp/.github/workflows/build.yml.jinja create mode 100644 cpp/.gitignore.jinja delete mode 100644 cpp/CMakeLists.txt delete mode 100644 cpp/MANIFEST.in delete mode 100644 cpp/Makefile create mode 100644 cpp/Makefile.jinja delete mode 100644 cpp/cmake/config/CppTemplate.pc.in delete mode 100644 cpp/cmake/config/CppTemplateConfig.cmake.in delete mode 100644 cpp/cmake/modules/FindColor.cmake delete mode 100644 cpp/cmake/modules/FindCppTemplate.cmake delete mode 100644 cpp/cmake/modules/FindNumPy.cmake delete mode 100644 cpp/cmake/modules/FindPythonHeaders.cmake delete mode 100644 cpp/cpp/cpp-template/cpp-template.hpp delete mode 100644 cpp/cpp/cpp-template/exports.hpp rename cpp/cpp/cpp-template/{cpp-template.cpp => extension.cpp} (50%) rename cpp/cpp/cpp-template/{python => }/extension.hpp (83%) delete mode 100644 cpp/cpp/cpp-template/python/extension.cpp delete mode 100644 cpp/pyproject.toml create mode 100644 cpp/pyproject.toml.jinja delete mode 100644 cpp/setup.py rename cpp/{cpp_template => {{module}}}/__init__.py (100%) rename cpp/{cpp_template/tests/test_all.py => {{module}}/tests/test_all.py.jinja} (71%) delete mode 100644 js/setup.py delete mode 100644 jupyter/setup.py delete mode 100644 python/setup.py delete mode 100644 rust/setup.py diff --git a/cpp/.github/workflows/build.yml b/cpp/.github/workflows/build.yml deleted file mode 100644 index 78f2428..0000000 --- a/cpp/.github/workflows/build.yml +++ /dev/null @@ -1,482 +0,0 @@ -name: Build Status - -on: - push: - branches: - - main - tags: - - v* - paths-ignore: - - LICENSE - - README.md - pull_request: - workflow_dispatch: - ci-full: - description: "Run Full CI Build" - required: false - type: boolean - default: false - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -permissions: - contents: read - checks: write - pull-requests: write - -#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# -#~~~~~~~~~ Build Matrix ~~~~~~~~~# -#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# -jobs: - ########################################################################################################################## - ########################################################################################################################## - ########################### - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~/##########\~~~~~~~# - #~~~~~|#|~~~~~~~|#|~~~~~~~# - #~~~~~|#|~~~~~~~|#|~~~~~~~# - #~~~~~|#|~~~~~~~|#|~~~~~~~# - #~~~~~|#|~~~~~~~|#|~~~~~~~# - #~~~~~|#|~~~~~~~|#|~~~~~~~# - #~~~~~\##########/~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - initialize: - runs-on: ubuntu-22.04 - outputs: - COMMIT_MESSAGE: ${{ steps.initialize.outputs.COMMIT_MSG }} - FULL_BUILD: ${{ steps.initialize.outputs.FULL_BUILD || steps.initialize.outputs.FULL_BUILD || steps.initialize.outputs.FULL_BUILD }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - # for pull_request so we can do HEAD^2 - fetch-depth: 2 - - - name: Initialize variables - uses: actions-ext/general/initialize-variables@v1 - id: initialize - with: - full: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ci-full }} - - ########################################################################################################################## - ########################################################################################################################## - ########################### - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~/#######|~~~~~~~~~# - #~~~~~~/########|~~~~~~~~~# - #~~~~~/###/~|###|~~~~~~~~~# - #~~~~~~~~~~~|###|~~~~~~~~~# - #~~~~~~~~~~~|###|~~~~~~~~~# - #~~~~~~~~~~~|###|~~~~~~~~~# - #~~~~~~~~~~~|###|~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - build_and_test: - needs: [initialize] - strategy: - matrix: - os: - - ubuntu-22.04 - python-version: - - '3.9' - fail-fast: false - runs-on: ${{ matrix.os }} - if: ${{ needs.initialize.outputs.FULL_BUILD == 'false' }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions-ext/python/setup@v1 - with: - version: ${{ matrix.python-version }} - - - name: Setup C++ - uses: actions-ext/cpp/setup@v1 - - - name: Install dependencies - run: make develop - - - name: Build project - run: make build - - - name: Test project - run: make tests-ci - - - name: Build wheels - run: make dist-wheel - - - name: Upload test results - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - check_name: Test Results - github_token: ${{ secrets.GITHUB_TOKEN }} - files: '**/junit.xml' - if: ${{ runner.os == 'Linux' }} - - - name: Upload coverage - uses: codecov/codecov-action@v3 - - ########################################################################################################################## - ########################################################################################################################## - ########################### - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~/########\~~~~~~~# - #~~~~~~|###|~~~\###\~~~~~~# - #~~~~~~~~~~~~~/###/~~~~~~~# - #~~~~~~~~~~~/###/~~~~~~~~~# - #~~~~~~~~~/###/~~~~~~~~~~~# - #~~~~~~~/###/~~~~~~~~~~~~~# - #~~~~~|#############|~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - build_cibuildwheel: - needs: [initialize] - strategy: - matrix: - os: - - ubuntu-22.04 - python-version: - - '3.9' - - '3.10' - - '3.11' - - '3.12' - fail-fast: false - runs-on: ${{ matrix.os }} - if: ${{ needs.initialize.outputs.FULL_BUILD == 'true' }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Run cibuildwheel - uses: actions-ext/python/run-cibuildwheel@v1 - with: - version: ${{ matrix.python-version }} - - - name: Upload wheels - uses: actions-ext/python/upload-dist@v1 - with: - kind: 'wheel' - - ########################################################################################################################## - ########################################################################################################################## - ########################### - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~/########\~~~~~~~# - #~~~~~~~|##|~~~~|##|~~~~~~# - #~~~~~~~~~~~~~~~|##|~~~~~~# - #~~~~~~~~~~~|######|~~~~~~# - #~~~~~~~~~~~~~~~|##|~~~~~~# - #~~~~~~~|##|~~~~|##|~~~~~~# - #~~~~~~~\#########/~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - build_wheel: - needs: [initialize] - strategy: - matrix: - os: - # - ubuntu-20.04 # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md - - ubuntu-22.04 # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md - # - macos-11 # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md - - macos-12 # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md - # - macos-13 # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md - # - windows-2019 # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md - - windows-2022 # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md - python-version: - - '3.9' - - '3.10' - - '3.11' - - '3.12' - fail-fast: false - runs-on: ${{ matrix.os }} - if: ${{ needs.initialize.outputs.FULL_BUILD == 'true' }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions-ext/python/setup@v1 - with: - version: ${{ matrix.python-version }} - - - name: Install dependencies - run: make develop - - - name: Run cibuildwheel - uses: actions-ext/python/run-cibuildwheel@v1 - with: - version: ${{ matrix.python-version }} - - - name: Upload wheels - uses: actions-ext/python/upload-dist@v1 - with: - version: ${{ matrix.python-version }} - kind: 'wheel' - - ########################################################################################################################## - ########################################################################################################################## - ########################### - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~|##|~~~~|##|~~~~~~~# - #~~~~~~|##|~~~~|##|~~~~~~~# - #~~~~~~|##|~~~~|##|~~~~~~~# - #~~~~~~|##########|~~~~~~~# - #~~~~~~~~~~~~~~|##|~~~~~~~# - #~~~~~~~~~~~~~~|##|~~~~~~~# - #~~~~~~~~~~~~~~|##|~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - build_sdist: - needs: [initialize] - strategy: - matrix: - os: - - ubuntu-22.04 - python-version: - - '3.9' - runs-on: ${{ matrix.os }} - if: ${{ needs.initialize.outputs.FULL_BUILD == 'true' }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions-ext/python/setup@v1 - with: - version: ${{ matrix.python-version }} - - - name: Install dependencies - run: make develop - - - name: Build sdist - run: make dist-sdist - - - name: Upload sdist - uses: actions-ext/python/upload-dist@v1 - with: - kind: "sdist" - - ########################################################################################################################## - ########################################################################################################################## - ########################### - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~|##########|~~~~~~# - #~~~~~~~|##|~~~~~~~~~~~~~~# - #~~~~~~~|##|~~~~~~~~~~~~~~# - #~~~~~~~|##########|~~~~~~# - #~~~~~~~~~~~~~~~|##|~~~~~~# - #~~~~~~~|##|~~~~|##|~~~~~~# - #~~~~~~~|##########|~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - - lint: - needs: [initialize] - strategy: - matrix: - os: - - ubuntu-22.04 - python-version: - - '3.9' - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions-ext/python/setup@v1 - with: - version: ${{ matrix.python-version }} - - - name: Install dependencies - run: make develop - - - name: Install clang-format - run: sudo apt install clang-format - - - name: Lint project - run: make lint - - ########################################################################################################################## - ########################################################################################################################## - ########################### - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~|##########|~~~~~~~# - #~~~~~~|##|~~~~~~~~~~~~~~~# - #~~~~~~|##|~~~~~~~~~~~~~~~# - #~~~~~~|##########|~~~~~~~# - #~~~~~~|##|~~~~|##|~~~~~~~# - #~~~~~~|##|~~~~|##|~~~~~~~# - #~~~~~~|##########|~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - test_wheel: - needs: [initialize, build_cibuildwheel, build_wheel] - strategy: - matrix: - os: - # - ubuntu-20.04 # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md - - ubuntu-22.04 # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md - # - macos-11 # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md - - macos-12 # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md - # - macos-13 # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md - # - windows-2019 # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md - - windows-2022 # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md - python-version: - - '3.9' - - '3.10' - - '3.11' - - '3.12' - fail-fast: false - runs-on: ${{ matrix.os }} - if: ${{ needs.initialize.outputs.FULL_BUILD == 'true' }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions-ext/python/setup@v1 - with: - version: ${{ matrix.python-version }} - - - name: Install dependencies - run: make develop - - - name: Download wheels - uses: actions-ext/python/download-dist@v1 - with: - version: ${{ matrix.python-version }} - kind: "wheel" - - - name: Test project - run: make tests-ci - - - name: Upload test results - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - check_name: Test Results - github_token: ${{ secrets.GITHUB_TOKEN }} - files: '**/junit.xml' - if: ${{ runner.os == 'Linux' }} - - - name: Upload coverage - uses: codecov/codecov-action@v3 - - ########################################################################################################################## - ########################################################################################################################## - ########################### - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~|#############|~~~~# - #~~~~~~|#|~~~~~~~/##/~~~~~# - #~~~~~~|#|~~~~~/##/~~~~~~~# - #~~~~~~~~~~~~/##/~~~~~~~~~# - #~~~~~~~~~~/##/~~~~~~~~~~~# - #~~~~~~~~/##/~~~~~~~~~~~~~# - #~~~~~~/##/~~~~~~~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - test_sdist: - needs: [initialize, build_sdist] - strategy: - matrix: - os: - # - ubuntu-20.04 # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md - - ubuntu-22.04 # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md - # - macos-11 # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md - - macos-12 # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md - # - macos-13 # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md - # - windows-2019 # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md - - windows-2022 # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md - python-version: - - '3.9' - - '3.10' - - '3.11' - - '3.12' - fail-fast: false - runs-on: ${{ matrix.os }} - if: ${{ needs.initialize.outputs.FULL_BUILD == 'true' }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions-ext/python/setup@v1 - with: - version: ${{ matrix.python-version }} - - - name: Install dependencies - run: make develop - - - name: Download wheels - uses: actions-ext/python/download-dist@v1 - with: - kind: "sdist" - - - name: Test project - run: make tests-ci - - - name: Upload test results - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - check_name: Test Results - github_token: ${{ secrets.GITHUB_TOKEN }} - files: '**/junit.xml' - if: ${{ runner.os == 'Linux' }} - - - name: Upload coverage - uses: codecov/codecov-action@v3 - - - ########################################################################################################################## - ########################################################################################################################## - ########################### - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~|#############|~~~~# - #~~~~~~|#|~~~~~~~~|##|~~~~# - #~~~~~~|#|~~~~~~~~|##|~~~~# - #~~~~~~|#############|~~~~# - #~~~~~~|#|~~~~~~~~|##|~~~~# - #~~~~~~|#|~~~~~~~~|##|~~~~# - #~~~~~~|#############|~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - - ########################################################################################################################## - ########################################################################################################################## - ########################### - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~|#############|~~~~# - #~~~~~~|#|~~~~~~~~|##|~~~~# - #~~~~~~|#|~~~~~~~~|##|~~~~# - #~~~~~~|#############|~~~~# - #~~~~~~~~~~~~~~~~~|##|~~~~# - #~~~~~~~~~~~~~~~~~|##|~~~~# - #~~~~~~|#############|~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# - - ########################################################################################################################## - ########################################################################################################################## - ########################### - #~~~~~~~~~~~~~~~~~~~~~~~~~# - #~~~~~\##\~~~~~~~/##/~~~~~# - #~~~~~~\##\~~~~~/##/~~~~~~# - #~~~~~~~\##\~~~/##/~~~~~~~# - #~~~~~~~~\##\~/##/~~~~~~~~# - #~~~~~~~~/##/~\##\~~~~~~~~# - #~~~~~~~/##/~~~\##\~~~~~~~# - #~~~~~~/##/~~~~~\##\~~~~~~# - #~~~~~/##/~~~~~~~\##\~~~~~# - #~~~~~~~~~~~~~~~~~~~~~~~~~# diff --git a/cpp/.github/workflows/build.yml.jinja b/cpp/.github/workflows/build.yml.jinja new file mode 100644 index 0000000..a1411f1 --- /dev/null +++ b/cpp/.github/workflows/build.yml.jinja @@ -0,0 +1,138 @@ +name: Build Status + +on: + push: + branches: + - main + tags: + - v* + paths-ignore: + - LICENSE + - README.md + pull_request: + branches: + - main + workflow_dispatch: + +concurrency: + group: {% raw %}${{ github.workflow }}-${{ github.head_ref || github.run_id }}{% endraw %} + cancel-in-progress: true + +permissions: + contents: read + checks: write + pull-requests: write + +jobs: + build: + runs-on: {% raw %}${{ matrix.os }}{% endraw %} + + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.9", "3.10", "3.11", "3.12"] + cibuildwheel: ["cp39", "cp310", "cp311", "cp312"] + exclude: + - python-version: "3.9" + cibuildwheel: "cp310" + - python-version: "3.9" + cibuildwheel: "cp311" + - python-version: "3.9" + cibuildwheel: "cp312" + - python-version: "3.10" + cibuildwheel: "cp39" + - python-version: "3.10" + cibuildwheel: "cp311" + - python-version: "3.10" + cibuildwheel: "cp312" + - python-version: "3.11" + cibuildwheel: "cp39" + - python-version: "3.11" + cibuildwheel: "cp310" + - python-version: "3.11" + cibuildwheel: "cp312" + - python-version: "3.12" + cibuildwheel: "cp39" + - python-version: "3.12" + cibuildwheel: "cp310" + - python-version: "3.12" + cibuildwheel: "cp311" + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python {% raw %}${{ matrix.python-version }}{% endraw %} + uses: actions/setup-python@v5 + with: + python-version: {% raw %}${{ matrix.python-version }}{% endraw %} + cache: 'pip' + cache-dependency-path: 'pyproject.toml' + + - name: Install dependencies + run: make develop + if: matrix.os != 'windows-latest' + + - name: Install dependencies + run: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + make develop + shell: cmd + if: matrix.os == 'windows-latest' + + - name: Lint + run: make lint + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' + + - name: Checks + run: make checks + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' + + - name: Install build dependencies + run: pip install cibuildwheel + + - name: Build (Linux) + run: make build-cibw + env: + CIBW_BUILD: {% raw %}"${{ matrix.cibuildwheel }}-manylinux*"{% endraw %} + CIBW_BUILD_VERBOSITY: 3 + if: matrix.os == 'ubuntu-latest' + + - name: Build (Macos) + run: make build-cibw + env: + CIBW_BUILD: {% raw %}"${{ matrix.cibuildwheel }}-macos*"{% endraw %} + CIBW_BUILD_VERBOSITY: 3 + if: matrix.os == 'macos-latest' + + - name: Build (Windows) + run: make build-cibw + env: + CIBW_BUILD: {% raw %}"${{ matrix.cibuildwheel }}-win_amd64"{% endraw %} + CIBW_BEFORE_ALL: call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + if: matrix.os == 'windows-latest' + + - name: Test + run: make coverage + + - name: Upload test results (Python) + uses: actions/upload-artifact@v4 + with: + name: {% raw %}test-results-${{ matrix.os }}-${{ matrix.python-version }}{% endraw %} + path: junit.xml + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + files: '**/junit.xml' + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' + + - name: Upload coverage + uses: codecov/codecov-action@v5 + with: + token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %} + + - uses: actions/upload-artifact@v4 + with: + name: {% raw %}dist-${{matrix.os}}-${{matrix.python-version}}{% endraw %} + path: dist diff --git a/cpp/.gitignore.jinja b/cpp/.gitignore.jinja new file mode 100644 index 0000000..10c2f7a --- /dev/null +++ b/cpp/.gitignore.jinja @@ -0,0 +1,151 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.a +*.so +*.obj +*.dll +*.exp +*.lib + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +junit.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# PyBuilder +target/ + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# Documentation +docs/_build/ +/site +docs/api +docs/index.md +_template/labextension + +# JS +js/node_modules +js/dist +{{module}}/extension + +# Jupyter +.ipynb_checkpoints +.autoversion + +# Mac +.DS_Store + +# Rust +target diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt deleted file mode 100644 index cb5cbd9..0000000 --- a/cpp/CMakeLists.txt +++ /dev/null @@ -1,324 +0,0 @@ -############################################################################################################### -# Project Configuration # -######################### -cmake_minimum_required(VERSION 3.20.0) -project(cpp-template VERSION "0.1.0") -set(CMAKE_CXX_STANDARD 20) - -############################################################################################################### -# CMake Dependencies # -###################### -include(CheckCCompilerFlag) - -############################################################################################################### -# CMake Policies # -################## -# option() should use new make behavior wrt variable clobbering -cmake_policy (SET CMP0077 NEW) - -# Allow dep roots from env vars -cmake_policy (SET CMP0074 NEW) - -# Set CMP0094 to NEW - find the first version that matches constraints, -# instead of the latest version installed -cmake_policy(SET CMP0094 NEW) - -############################################################################################################### -# Environment # -############### -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - set(WIN32 ON) - set(MACOS OFF) - set(LINUX OFF) -elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(WIN32 OFF) - set(MACOS ON) - set(LINUX OFF) -else() - set(WIN32 OFF) - set(MACOS OFF) - set(LINUX ON) -endif() - - -############################################################################################################### -# Paths # -######### -# Custom CMake modules -list(APPEND CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/modules") - -# Base includes -include_directories ("${CMAKE_SOURCE_DIR}/src") - -############################################################################################################### -# Build Configuration # -####################### -find_package (Color) - -if (NOT DEFINED CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Release/Debug build") -endif() -if (NOT DEFINED PYTHON_VERSION) - set(PYTHON_VERSION "3.9" CACHE STRING "Python version to build against") -endif() -option(BUILD_PYTHON "Build Python bindings" ON) -option(USE_CCACHE "Use CCache for build" OFF) -option(STATIC_PYTHON "Build against static python (no libraries)" OFF) -option(PYODIDE "Build against pyodide" OFF) - -# CCache setup -if(USE_CCACHE) - set(CMAKE_C_COMPILE_LAUNCHER ccache) - set(CMAKE_CXX_COMPILER_LAUNCHER ccache) -endif() - -if(MACOS) - # fix for threads on osx - # assume built-in pthreads on MacOS - set(CMAKE_THREAD_LIBS_INIT "-lpthread") - set(CMAKE_HAVE_THREADS_LIBRARY 1) - set(CMAKE_USE_WIN32_THREADS_INIT 0) - set(CMAKE_USE_PTHREADS_INIT 1) - set(THREADS_PREFER_PTHREAD_FLAG ON) - - # don't link against build python - # https://blog.tim-smith.us/2015/09/python-extension-modules-os-x/ - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup") - - # Support cross build - check_c_compiler_flag("-arch x86_64" x86_64Supported) - check_c_compiler_flag("-arch arm64" arm64Supported) - - if(x86_64Supported AND arm64Supported) - set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build universal architecture for OSX" FORCE) - elseif(x86_64Supported) - set(CMAKE_REQUIRED_LINK_OPTIONS "-arch;x86_64") - set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build universal architecture for OSX" FORCE) - elseif(arm64Supported) - set(CMAKE_REQUIRED_LINK_OPTIONS "-arch;arm64") - set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Build universal architecture for OSX" FORCE) - endif() -endif() - -if(WIN32) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - -############################################################################################################### -# Version # -########### -# Set version from cmake and extract latest hash if available -set(CPP_TEMPLATE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) -set(CPP_TEMPLATE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) -set(CPP_TEMPLATE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") - # Get latest commit - execute_process(COMMAND git rev-parse HEAD - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE CPP_TEMPLATE_VERSION_COMMIT_SHA) - # strip newline - string(REGEX REPLACE "\n$" "" CPP_TEMPLATE_VERSION_COMMIT_SHA "${CPP_TEMPLATE_VERSION_COMMIT_SHA}") -else() - set(CPP_TEMPLATE_VERSION_COMMIT_SHA "release") -endif() - -############################################################################################################### -# RPath # -######### -if(NOT WIN32) - set(CMAKE_SHARED_LIBRARY_SUFFIX .so) - - # Look for the binary using @loader_path (relative to binary location) - set(CMAKE_MACOSX_RPATH TRUE) - set(CMAKE_SKIP_BUILD_RPATH FALSE) - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - - # module_origin_path is the location of the binary - if(MACOS) - set(module_origin_path "@loader_path") - else() - set(module_origin_path "\$ORIGIN") - endif() -else() - set(CMAKE_SHARED_LIBRARY_PREFIX "lib") - set(CMAKE_STATIC_LIBRARY_PREFIX "lib") -endif() - -############################################################################################################### -# Flags # -######### -# Compiler version flags -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a") -endif() - -# Optimization Flags -if(WIN32) - if(CMAKE_BUILD_TYPE_LOWER STREQUAL debug) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DEBUG /Z7 /Zi /Zc:preprocessor") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Zc:preprocessor ") - endif() -else() - if(CMAKE_BUILD_TYPE_LOWER STREQUAL debug) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g3") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -g0") - endif() -endif() - -# Other Flags -if(WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") - foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd${warning}") - endforeach(warning) - add_compile_definitions(WIN32 _WIN32) - if (MSVC_VERSION GREATER_EQUAL 1920) - add_compile_options(/d2FH4-) # Because we don't want to link against VCRUNTIME140_1.dll (see https://cibuildwheel.readthedocs.io/en/stable/faq/#importerror-dll-load-failed-the-specific-module-could-not-be-found-error-on-windows) - endif() -else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-macro-redefined") -endif() - -############################################################################################################### -# Python # -########## -if(BUILD_PYTHON AND STATIC_PYTHON AND LINUX) - message("${Red}Manylinux build has no python shared libraries${ColorReset}") - find_package(Python ${PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter OPTIONAL_COMPONENTS Development.Module) -elseif(BUILD_PYTHON) - message("${Cyan}Use python shared libraries${ColorReset}") - if(PYODIDE) - find_package(Python ${PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter OPTIONAL_COMPONENTS Development.Module) - else() - find_package(Python ${PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development.Module) - endif() - link_directories(${Python_LIBRARY_DIRS}) -endif() - -if(BUILD_PYTHON) - message("${Cyan}Using Python ${Python_VERSION}, \nPython_INCLUDE_DIRS: ${Python_INCLUDE_DIRS}, \nPython_LIBRARIES: ${Python_LIBRARIES}, \nPython_EXECUTABLE: ${Python_EXECUTABLE} ${ColorReset}") - include_directories(${Python_INCLUDE_DIRS}) - add_definitions(-DBUILD_PYTHON) -endif() - -############################################################################################################### -# Messages # -############ -message("Building CPP Template version v${CPP_TEMPLATE_VERSION_MAJOR}.${CPP_TEMPLATE_VERSION_MINOR}.${CPP_TEMPLATE_VERSION_PATCH} [${CPP_TEMPLATE_VERSION_COMMIT_SHA}]") -string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) - -if(CMAKE_BUILD_TYPE_LOWER STREQUAL debug) - message("${Red}Building DEBUG${ColorReset}") -else() - message("${Cyan}Building RELEASE${ColorReset}") -endif() - -############################################################################################################### -# Configure asset output directories # -###################################### -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -############################################################################################################### -# Standalone C++ Binary # -######################### -set( - PROJECT_HDRS - "${PROJECT_SOURCE_DIR}/src/cpp-template/cpp-template.hpp" - "${PROJECT_SOURCE_DIR}/src/cpp-template/exports.hpp" -) -set( - PROJECT_SRCS - "${PROJECT_SOURCE_DIR}/src/cpp-template/cpp-template.cpp" -) - -add_library(cpp-template SHARED ${PROJECT_SRCS}) -add_library(cpp-template-static STATIC ${PROJECT_SRCS}) -set_target_properties(cpp-template PROPERTIES PUBLIC_HEADER "${PROJECT_HDRS}") - -# export symbols -if(WIN32) - target_compile_definitions(cpp-template PRIVATE LIB_EXPORTS) - target_compile_definitions(cpp-template-static PRIVATE LIB_EXPORTS) -endif() - -# install standalone library inside package -install(TARGETS cpp-template EXPORT CppTemplate LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include) -install(TARGETS cpp-template-static EXPORT CppTemplate LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include) - -############################################################################################################### -# Pybind Extension # -#################### -if(BUILD_PYTHON) - # Find Numpy - find_package(NumPy REQUIRED) - - # Find PyBind11 - find_package(pybind11 REQUIRED) - include_directories(${pybind11_INCLUDE_DIR}) - - set( - PYTHON_HDRS - "${PROJECT_SOURCE_DIR}/src/cpp-template/python/extension.hpp" - ) - set( - PYTHON_SRCS - "${PROJECT_SOURCE_DIR}/src/cpp-template/python/extension.cpp" - ) - - # Extension - pybind11_add_module(extension MODULE "${PYTHON_SRCS}") - set_target_properties(extension PROPERTIES PUBLIC_HEADER "${PYTHON_HDRS}") - - # Link to standalone library - target_link_libraries(extension PUBLIC cpp-template) - set_property(TARGET extension PROPERTY INSTALL_RPATH "${module_origin_path}/lib") - - # install in python module - install(TARGETS extension EXPORT CppTemplate LIBRARY DESTINATION . PUBLIC_HEADER DESTINATION include/python) -endif() - -############################################################################################################### -# C++ Discoverability # -####################### - -# Generate cmake config files for reuse by downstream packages -include(CMakePackageConfigHelpers) - -# generate the config file that is includes the exports -configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/config/CppTemplateConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/CppTemplateConfig.cmake - INSTALL_DESTINATION cmake -) -write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/CppTemplateConfigVersion.cmake - VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}" - COMPATIBILITY SameMajorVersion -) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/config/CppTemplate.pc.in - "${CMAKE_CURRENT_BINARY_DIR}/CppTemplate.pc" - @ONLY) - -# install the configuration file -install(EXPORT CppTemplate - FILE CppTemplateTargets.cmake - NAMESPACE CppTemplate:: - DESTINATION lib/cmake/CppTemplate -) -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/CppTemplateConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/CppTemplateConfigVersion.cmake - DESTINATION lib/cmake/CppTemplate -) - -# install the configuration file -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/CppTemplate.pc - DESTINATION lib/pkgconfig) - diff --git a/cpp/MANIFEST.in b/cpp/MANIFEST.in deleted file mode 100644 index cb1da56..0000000 --- a/cpp/MANIFEST.in +++ /dev/null @@ -1,40 +0,0 @@ -# Python -graft cpp_template - -# C++ -graft src -graft cmake -include CMakeLists.txt - -# Markdown / Text -include LICENSE -include README.md - -# Project files -include pyproject.toml -include setup.py - -# Remove IDE and CI/CD -prune .vscode -prune .github - -# Remove test and lint assets -prune .pytest_cache -prune .ruff_cache -prune .mypy_cache -prune _skbuild -exclude .clang-format - -# Remove VCS assets -exclude .bumpversion.cfg -exclude .gitignore -exclude .gitattributes -exclude Makefile - -# Patterns to exclude from any directory -global-exclude *~ -global-exclude *.pyc -global-exclude *.pyo -global-exclude .git -global-exclude .ipynb_checkpoints -global-exclude .DS_Store diff --git a/cpp/Makefile b/cpp/Makefile deleted file mode 100644 index 868c701..0000000 --- a/cpp/Makefile +++ /dev/null @@ -1,80 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help -# Thanks to Francoise at marmelab.com for this -help: - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' - -print-%: - @echo '$*=$($*)' - -OTHER_ARGS := - -.PHONY: develop-py develop-rust develop -develop-py: - pip install -U toml - pip install `python -c 'import toml; c = toml.load("pyproject.toml"); print(" ".join(c["project"]["optional-dependencies"]["develop"]))'` - -develop-cpp: - echo "C++ ready" - -develop: develop-py ## Setup project for development - -.PHONY: build-py build-cpp build -build-py: - python setup.py build build_ext --inplace - -build-cpp: - cmake -B build . -DBUILD_PYTHON=Off - cmake --build build -- -j8 - -build: build-cpp build-py ## Build the project - -.PHONY: lint-py lint-cpp lint -lint-py: - python -m ruff cpp_template - -lint-cpp: - clang-format --dry-run -Werror -i -style=file `find ./src -name "*.*pp"` - -lint: lint-cpp lint-py ## Run project linters - -.PHONY: fix-py fix-cpp fix -fix-py: - python -m ruff cpp_template --fix - -fix-cpp: - clang-format -i -style=file `find ./src -name "*.*pp"` - -fix: fix-cpp fix-py ## Run project autofixers - -.PHONY: tests-py tests-cpp tests test tests-ci -tests-py: - python -m pytest -v {{module}}/tests --cov={{module}} --cov-report term-missing --cov-report xml - -tests-cpp: - echo "TODO C++ tests" - -tests: tests-cpp tests-py ## Run the tests -test: tests - -tests-ci: tests-cpp tests-py - -.PHONY: dist-sdist dist-wheel dist publish - -dist-sdist: ## Create python source dist - python setup.py sdist - -dist-wheel: ## Create python wheel dist - python setup.py bdist_wheel $(OTHER_ARGS) - -dist-cibw: ## Create python wheel dist with cibuildwheel - python -m cibuildwheel --output-dir dist - -dist: build dist-sdist dist-wheel ## Create python dists - python -m twine check target/wheels/* - -publish: dist ## Dist assets to pypi - python -m twine upload target/wheels/* --skip-existing - -clean: ## Clean the repo - git clean -fdx diff --git a/cpp/Makefile.jinja b/cpp/Makefile.jinja new file mode 100644 index 0000000..cfaa521 --- /dev/null +++ b/cpp/Makefile.jinja @@ -0,0 +1,139 @@ +######### +# BUILD # +######### +.PHONY: develop +develop: ## setup project for development + python -m pip install -e .[develop] + +.PHONY: build-py build-cpp build +build-py: + python -m build -w -n + +build-cpp: + python -m hatchling build --hooks-only + +build-cibw: + python -m cibuildwheel --output-dir dist + +build: build-cpp build-py ## build the project + +.PHONY: install +install: ## install python library + python -m pip install . + +######### +# LINTS # +######### +.PHONY: lint-py lint-cpp lint lints +lint-py: ## run python linter with ruff + python -m ruff check {{module}} + python -m ruff format --check {{module}} + +lint-cpp: ## run cpp linter + clang-format --dry-run -Werror -i -style=file `find ./cpp -name "*.*pp"` + +lint: lint-cpp lint-py ## run project linters + +# alias +lints: lint + +.PHONY: fix-py fix-cpp fix format +fix-py: ## fix python formatting with ruff + python -m ruff check --fix {{module}} + python -m ruff format {{module}} + +fix-cpp: ## fix cpp formatting + clang-format -i -style=file `find ./cpp -name "*.*pp"` + +fix: fix-cpp fix-py ## run project autoformatters + +# alias +format: fix + +################ +# Other Checks # +################ +.PHONY: check-manifest checks check + +check-manifest: ## check python sdist manifest with check-manifest + check-manifest -v + +checks: check-manifest + +# alias +check: checks + +######### +# TESTS # +######### +.PHONY: test-py tests-py coverage-py +test-py: ## run python tests + python -m pytest -v {{module}}/tests + +# alias +tests-py: test-py + +coverage-py: ## run python tests and collect test coverage + python -m pytest -v {{module}}/tests --cov={{module}} --cov-report term-missing --cov-report xml + +.PHONY: test coverage tests +test: test-py ## run all tests +coverage: coverage-py ## run all tests and collect test coverage + +# alias +tests: test + +########### +# VERSION # +########### +.PHONY: show-version patch minor major + +show-version: ## show current library version + @bump-my-version show current_version + +patch: ## bump a patch version + @bump-my-version bump patch + +minor: ## bump a minor version + @bump-my-version bump minor + +major: ## bump a major version + @bump-my-version bump major + +######## +# DIST # +######## +.PHONY: dist dist-py dist-check publish + +dist-py: # build python dists + python -m build -w -s + +dist-check: ## run python dist checker with twine + python -m twine check dist/* + +dist: clean build dist-js dist-py dist-check ## build all dists + +publish: dist # publish python assets + +######### +# CLEAN # +######### +.PHONY: deep-clean clean + +deep-clean: ## clean everything from the repository + git clean -fdx + +clean: ## clean the repository + rm -rf .coverage coverage cover htmlcov logs build dist *.egg-info + +############################################################################################ + +.PHONY: help + +# Thanks to Francoise at marmelab.com for this +.DEFAULT_GOAL := help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +print-%: + @echo '$*=$($*)' diff --git a/cpp/cmake/config/CppTemplate.pc.in b/cpp/cmake/config/CppTemplate.pc.in deleted file mode 100644 index 4eb208e..0000000 --- a/cpp/cmake/config/CppTemplate.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix="@CMAKE_INSTALL_PREFIX@" -exec_prefix="${prefix}" -libdir="@CMAKE_INSTALL_FULL_LIBDIR@" -includedir="@CMAKE_INSTALL_FULL_INCLUDEDIR@" - -Name: @PROJECT_NAME@ -Description: @CMAKE_PROJECT_DESCRIPTION@ -Version: @PROJECT_VERSION@ -Cflags: -I${includedir} -Libs: -L${libdir} -lcpp-template diff --git a/cpp/cmake/config/CppTemplateConfig.cmake.in b/cpp/cmake/config/CppTemplateConfig.cmake.in deleted file mode 100644 index fb77b89..0000000 --- a/cpp/cmake/config/CppTemplateConfig.cmake.in +++ /dev/null @@ -1,12 +0,0 @@ -set(CPP_TEMPLATE_VERSION "@PROJECT_VERSION@") - -@PACKAGE_INIT@ - -include(${CMAKE_CURRENT_LIST_DIR}/CppTemplateTargets.cmake) - -set_and_check(CPP_TEMPLATE_BIN_DIR @CMAKE_INSTALL_FULL_BINDIR@) -set_and_check(CPP_TEMPLATE_INCLUDE_DIR @CMAKE_INSTALL_FULL_INCLUDEDIR@) -set_and_check(CPP_TEMPLATE_INCLUDE_DIRS @CMAKE_INSTALL_FULL_INCLUDEDIR@) -set_and_check(CPP_TEMPLATE_LIB_DIR @CMAKE_INSTALL_FULL_LIBDIR@) - -check_required_components(CppTemplate) diff --git a/cpp/cmake/modules/FindColor.cmake b/cpp/cmake/modules/FindColor.cmake deleted file mode 100644 index 2af8fc6..0000000 --- a/cpp/cmake/modules/FindColor.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# (c) Perspective Authors 2017 - Apache 2.0 -cmake_minimum_required(VERSION 3.7.2) - -if(NOT WIN32) - string(ASCII 27 Esc) - set(ColorReset "${Esc}[m") - set(Red "${Esc}[1;31m") - set(Green "${Esc}[1;32m") - set(Yellow "${Esc}[1;33m") - set(Blue "${Esc}[1;34m") - set(Magenta "${Esc}[1;35m") - set(Cyan "${Esc}[1;36m") - set(White "${Esc}[1;37m") -endif() \ No newline at end of file diff --git a/cpp/cmake/modules/FindCppTemplate.cmake b/cpp/cmake/modules/FindCppTemplate.cmake deleted file mode 100644 index 174cbfd..0000000 --- a/cpp/cmake/modules/FindCppTemplate.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# Find the CppTemplate package -# CPP_TEMPLATE_INCLUDE_DIR -# CPP_TEMPLATE_FOUND -# will be set by this script - -cmake_minimum_required(VERSION 3.7.2) - -find_package( PythonInterp ${PYTHON_VERSION} EXACT REQUIRED ) - -# Find out the include path -execute_process( - COMMAND "${Python_EXECUTABLE}" -c - "from __future__ import print_function;import cpp_template;print(cpp_template.include_path(), end='')" - OUTPUT_VARIABLE __cppt_path) -# And the version -execute_process( - COMMAND "${Python_EXECUTABLE}" -c - "from __future__ import print_function;import cpp_template;print(cpp_template.__version__, end='')" - OUTPUT_VARIABLE __cppt_version) - -find_path(CPP_TEMPLATE_INCLUDE_DIR cpp-template/cpp-template.hpp - HINTS "${__cppt_path}" "${PYTHON_INCLUDE_PATH}" NO_DEFAULT_PATH) - -if(CPP_TEMPLATE_INCLUDE_DIR) - set(CPP_TEMPLATE_FOUND 1 CACHE INTERNAL "Python cpp_template found") -endif(CPP_TEMPLATE_INCLUDE_DIR) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CppTemplate REQUIRED_VARS CPP_TEMPLATE_INCLUDE_DIR - VERSION_VAR __cppt_version) diff --git a/cpp/cmake/modules/FindNumPy.cmake b/cpp/cmake/modules/FindNumPy.cmake deleted file mode 100644 index ed9a1e3..0000000 --- a/cpp/cmake/modules/FindNumPy.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# Find the NumPy package -# NUMPY_INCLUDE_DIR -# NUMPY_FOUND -# will be set by this script - -cmake_minimum_required(VERSION 3.7.2) - -find_package( PythonInterp ${PYTHON_VERSION} EXACT REQUIRED ) - -# Find out the include path -execute_process( - COMMAND "${Python_EXECUTABLE}" -c - "from __future__ import print_function;import numpy;print(numpy.get_include(), end='')" - OUTPUT_VARIABLE __numpy_path) -# And the version -execute_process( - COMMAND "${Python_EXECUTABLE}" -c - "from __future__ import print_function;import numpy;print(numpy.__version__, end='')" - OUTPUT_VARIABLE __numpy_version) - -find_path(NUMPY_INCLUDE_DIR numpy/arrayobject.h - HINTS "${__numpy_path}" "${PYTHON_INCLUDE_PATH}" NO_DEFAULT_PATH) - -if(NUMPY_INCLUDE_DIR) - set(NUMPY_FOUND 1 CACHE INTERNAL "Python numpy found") -endif(NUMPY_INCLUDE_DIR) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(NumPy REQUIRED_VARS NUMPY_INCLUDE_DIR - VERSION_VAR __numpy_version) diff --git a/cpp/cmake/modules/FindPythonHeaders.cmake b/cpp/cmake/modules/FindPythonHeaders.cmake deleted file mode 100644 index 78b7b77..0000000 --- a/cpp/cmake/modules/FindPythonHeaders.cmake +++ /dev/null @@ -1,270 +0,0 @@ -cmake_minimum_required(VERSION 3.7.2) - -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindPythonHeaders --------------- - -.. deprecated:: 3.12 - - Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead. - -Find python libraries - -This module finds if Python is installed and determines where the -include files and libraries are. It also determines what the name of -the library is. This code sets the following variables: - -:: - - PYTHONLIBS_FOUND - have the Python libs been found - PYTHON_LIBRARIES - path to the python library - PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated) - PYTHON_INCLUDE_DIRS - path to where Python.h is found - PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated) - PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8) - - - -The Python_ADDITIONAL_VERSIONS variable can be used to specify a list -of version numbers that should be taken into account when searching -for Python. You need to set this variable before calling -find_package(PythonLibs). - -If you'd like to specify the installation of Python to use, you should -modify the following cache variables: - -:: - - PYTHON_LIBRARY - path to the python library - PYTHON_INCLUDE_DIR - path to where Python.h is found - -If calling both ``find_package(PythonInterp)`` and -``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to -get the currently active Python version by default with a consistent version -of PYTHON_LIBRARIES. -#]=======================================================================] - -# Use the executable's path as a hint -set(_Python_LIBRARY_PATH_HINT) -if(IS_ABSOLUTE "${Python_EXECUTABLE}") - if(WIN32) - get_filename_component(_Python_PREFIX "${Python_EXECUTABLE}" PATH) - if(_Python_PREFIX) - set(_Python_LIBRARY_PATH_HINT ${_Python_PREFIX}/libs) - endif() - unset(_Python_PREFIX) - else() - get_filename_component(_Python_PREFIX "${Python_EXECUTABLE}" PATH) - get_filename_component(_Python_PREFIX "${_Python_PREFIX}" PATH) - if(_Python_PREFIX) - set(_Python_LIBRARY_PATH_HINT ${_Python_PREFIX}/lib) - endif() - unset(_Python_PREFIX) - endif() -endif() - -include(CMakeFindFrameworks) -# Search for the python framework on Apple. -CMAKE_FIND_FRAMEWORKS(Python) - -# Save CMAKE_FIND_FRAMEWORK -if(DEFINED CMAKE_FIND_FRAMEWORK) - set(_PythonLibs_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK}) -else() - unset(_PythonLibs_CMAKE_FIND_FRAMEWORK) -endif() -# To avoid picking up the system Python.h pre-maturely. -set(CMAKE_FIND_FRAMEWORK LAST) - -set(_PYTHON1_VERSIONS 1.6 1.5) -set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) -set(_PYTHON3_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) - -if(PythonLibs_FIND_VERSION) - if(PythonLibs_FIND_VERSION_COUNT GREATER 1) - set(_PYTHON_FIND_MAJ_MIN "${PythonLibs_FIND_VERSION_MAJOR}.${PythonLibs_FIND_VERSION_MINOR}") - unset(_PYTHON_FIND_OTHER_VERSIONS) - if(PythonLibs_FIND_VERSION_EXACT) - if(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION) - set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}") - else() - set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}" "${_PYTHON_FIND_MAJ_MIN}") - endif() - else() - foreach(_PYTHON_V ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS}) - if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) - list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) - endif() - endforeach() - endif() - unset(_PYTHON_FIND_MAJ_MIN) - else() - set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS}) - endif() -else() - set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) -endif() - -# Set up the versions we know about, in the order we will search. Always add -# the user supplied additional versions to the front. -# If FindPythonInterp has already found the major and minor version, -# insert that version between the user supplied versions and the stock -# version list. -set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS}) -if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR) - list(APPEND _Python_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) -endif() -list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS}) - -unset(_PYTHON_FIND_OTHER_VERSIONS) -unset(_PYTHON1_VERSIONS) -unset(_PYTHON2_VERSIONS) -unset(_PYTHON3_VERSIONS) - -# Python distribution: define which architectures can be used -if (CMAKE_SIZEOF_VOID_P) - # In this case, search only for 64bit or 32bit - math (EXPR _PYTHON_ARCH "${CMAKE_SIZEOF_VOID_P} * 8") - set (_PYTHON_ARCH2 _PYTHON_PREFIX_ARCH}) -else() - if (Python_EXECUTABLE) - # determine interpreter architecture - execute_process (COMMAND "${Python_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)" - RESULT_VARIABLE _PYTHON_RESULT - OUTPUT_VARIABLE _PYTHON_IS64BIT - ERROR_VARIABLE _PYTHON_IS64BIT) - if (NOT _PYTHON_RESULT) - if (_PYTHON_IS64BIT) - set (_PYTHON_ARCH 64) - set (_PYTHON_ARCH2 64) - else() - set (_PYTHON_ARCH 32) - set (_PYTHON_ARCH2 32) - endif() - endif() - else() - # architecture unknown, search for both 64bit and 32bit - set (_PYTHON_ARCH 64) - set (_PYTHON_ARCH2 32) - endif() -endif() - -foreach(_CURRENT_VERSION ${_Python_VERSIONS}) - string(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION}) - if(WIN32) - find_library(PYTHON_DEBUG_LIBRARY - NAMES python${_CURRENT_VERSION_NO_DOTS}_d python - NAMES_PER_DIR - HINTS ${_Python_LIBRARY_PATH_HINT} - PATHS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs/Debug - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs/Debug - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs/Debug - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs/Debug - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs - ) - endif() - - set(PYTHON_FRAMEWORK_LIBRARIES) - if(Python_FRAMEWORKS AND NOT PYTHON_LIBRARY) - foreach(dir ${Python_FRAMEWORKS}) - list(APPEND PYTHON_FRAMEWORK_LIBRARIES - ${dir}/Versions/${_CURRENT_VERSION}/lib) - endforeach() - endif() - # Use the library's install prefix as a hint - set(_Python_INCLUDE_PATH_HINT) - # PYTHON_LIBRARY may contain a list because of SelectLibraryConfigurations - # which may have been run previously. If it is the case, the list can be: - # optimized;;debug; - foreach(lib ${PYTHON_LIBRARY} ${PYTHON_DEBUG_LIBRARY}) - if(IS_ABSOLUTE "${lib}") - get_filename_component(_Python_PREFIX "${lib}" PATH) - get_filename_component(_Python_PREFIX "${_Python_PREFIX}" PATH) - if(_Python_PREFIX) - list(APPEND _Python_INCLUDE_PATH_HINT ${_Python_PREFIX}/include) - endif() - unset(_Python_PREFIX) - endif() - endforeach() - - # Add framework directories to the search paths - set(PYTHON_FRAMEWORK_INCLUDES) - if(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR) - foreach(dir ${Python_FRAMEWORKS}) - list(APPEND PYTHON_FRAMEWORK_INCLUDES - ${dir}/Versions/${_CURRENT_VERSION}/include) - endforeach() - endif() - - find_path(PYTHON_INCLUDE_DIR - NAMES Python.h - HINTS - ${_Python_INCLUDE_PATH_HINT} - PATHS - ${PYTHON_FRAMEWORK_INCLUDES} - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/include - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/include - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/include - [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/include - PATH_SUFFIXES - python${_CURRENT_VERSION}mu - python${_CURRENT_VERSION}m - python${_CURRENT_VERSION}u - python${_CURRENT_VERSION} - ) - - # For backward compatibility, set PYTHON_INCLUDE_PATH. - set(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}") - - if(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h") - file(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" python_version_str - REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"") - string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1" - PYTHONLIBS_VERSION_STRING "${python_version_str}") - unset(python_version_str) - endif() - - if(PYTHON_INCLUDE_DIR) - break() - endif() -endforeach() - -unset(_Python_INCLUDE_PATH_HINT) -unset(_Python_LIBRARY_PATH_HINT) - -mark_as_advanced( - PYTHON_INCLUDE_DIR -) - -# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the -# cache entries because they are meant to specify the location of a single -# library. We now set the variables listed by the documentation for this -# module. -set(Python_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") -unset(PYTHON_FOUND) - -# Restore CMAKE_FIND_FRAMEWORK -if(DEFINED _PythonLibs_CMAKE_FIND_FRAMEWORK) - set(CMAKE_FIND_FRAMEWORK ${_PythonLibs_CMAKE_FIND_FRAMEWORK}) - unset(_PythonLibs_CMAKE_FIND_FRAMEWORK) -else() - unset(CMAKE_FIND_FRAMEWORK) -endif() - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonHeaders - REQUIRED_VARS Python_INCLUDE_DIRS - VERSION_VAR PYTHONLIBS_VERSION_STRING) diff --git a/cpp/cpp/cpp-template/cpp-template.hpp b/cpp/cpp/cpp-template/cpp-template.hpp deleted file mode 100644 index 8637319..0000000 --- a/cpp/cpp/cpp-template/cpp-template.hpp +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include -#include - -LIB_EXPORT int add(int i, int j); diff --git a/cpp/cpp/cpp-template/exports.hpp b/cpp/cpp/cpp-template/exports.hpp deleted file mode 100644 index 8b5987c..0000000 --- a/cpp/cpp/cpp-template/exports.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#ifdef WIN32 -#ifdef LIB_EXPORTS // DLL EXPORT -#define LIB_EXPORT __declspec(dllexport) -#ifdef FE_MPROTECT -#define LIB_MPROTECT_EXPORT __declspec(dllexport, align(4096)) -#else // NOT FE_MPROTECT -#define LIB_MPROTECT_EXPORT __declspec(dllexport) -#endif // FE_MPROTECT -#else // DLL IMPORT -#define LIB_EXPORT __declspec(dllimport) -#ifdef FE_MPROTECT -#define LIB_MPROTECT_EXPORT __declspec(dllimport, align(4096)) -#else // NOT FE_MPROTECT -#define LIB_MPROTECT_EXPORT __declspec(dllimport) -#endif // FE_MPROTECT -#endif // LIB EXPORTS -#else // NOT WIN32 -#define LIB_EXPORT __attribute__((visibility("default"))) -#define LIB_MPROTECT_EXPORT __attribute__((visibility("default"))) -#endif // WIN32 diff --git a/cpp/cpp/cpp-template/cpp-template.cpp b/cpp/cpp/cpp-template/extension.cpp similarity index 50% rename from cpp/cpp/cpp-template/cpp-template.cpp rename to cpp/cpp/cpp-template/extension.cpp index 5f01976..d42fa05 100644 --- a/cpp/cpp/cpp-template/cpp-template.cpp +++ b/cpp/cpp/cpp-template/extension.cpp @@ -1,3 +1,3 @@ -#include "cpp-template/cpp-template.hpp" +#include "cpp-template/extension.hpp" int add(int i, int j) { return i + j; } diff --git a/cpp/cpp/cpp-template/python/extension.hpp b/cpp/cpp/cpp-template/extension.hpp similarity index 83% rename from cpp/cpp/cpp-template/python/extension.hpp rename to cpp/cpp/cpp-template/extension.hpp index 21029d6..2ae782a 100644 --- a/cpp/cpp/cpp-template/python/extension.hpp +++ b/cpp/cpp/cpp-template/extension.hpp @@ -1,9 +1,10 @@ #pragma once #include -#include namespace py = pybind11; +int add(int i, int j); + PYBIND11_MODULE(extension, m) { m.doc() = "pybind11 example plugin"; diff --git a/cpp/cpp/cpp-template/python/extension.cpp b/cpp/cpp/cpp-template/python/extension.cpp deleted file mode 100644 index c92c319..0000000 --- a/cpp/cpp/cpp-template/python/extension.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "cpp-template/python/extension.hpp" diff --git a/cpp/pyproject.toml b/cpp/pyproject.toml deleted file mode 100644 index 99d38c0..0000000 --- a/cpp/pyproject.toml +++ /dev/null @@ -1,133 +0,0 @@ -[build-system] -requires = [ - "cmake", - "ninja", - "numpy", - "pybind11[global]", - "scikit-build", - "setuptools", - "wheel", -] -build-backend = "setuptools.build_meta" - -[project] -name = "cpp" -authors = [{name = "Tim Paine", email = "t.paine154@gmail.com"}] -description = "A Python/C++ project template" -version = "0.1.0" -readme = "README.md" -license = { file = "LICENSE" } -requires-python = ">=3.7" -classifiers = [ - "Development Status :: 3 - Alpha", - "Programming Language :: C++", - "Programming Language :: Python", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", -] -keywords = [] -dependencies = [] - -[project.optional-dependencies] -develop = [ - "black>=23", - "bump2version", - "check-manifest", - "cibuildwheel", - "numpy", - "pybind11[global]", - "pytest", - "pytest-cov", - "pytest-sugar", - "ruff", - "scikit-build", - "twine", - "wheel", -] -test = [ - "pytest", - "pytest-cov", - "pytest-sugar", -] - -[project.urls] -Repository = "https://github.com/python-project-templates/cpp" -Homepage = "https://github.com/python-project-templates/cpp" -Issues = "https://github.com/python-project-templates/cpp/issues" - -[tool.black] -color = true -line-length = 150 -target-version = ["py310"] -skip-string-normalization = true - -[tool.check-manifest] -ignore = [] - -[tool.cibuildwheel] -build = "cp38-* cp39-* cp310-* cp311-*" -before-all = "make develop" - -build-verbosity = "2" -environment = {STATIC_PYTHON="On"} - -test-command = "pytest -vvv {project}/cpp_template/tests" -test-requires = [ - "pytest", - "pytest-cov", - "pytest-sugar", -] - -[tool.cibuildwheel.linux] -archs = "x86_64 aarch64" -skip = "*musllinux* *i686" - -[tool.cibuildwheel.macos] -archs = "x86_64 arm64" -environment = {CFLAGS="-I/usr/local/include -L/usr/local/lib", CXXFLAGS="-I/usr/local/include -L/usr/local/lib", LDFLAGS="-L/usr/local/lib"} - -[tool.cibuildwheel.windows] -archs = "AMD64" -skip = "*win32 *arm_64" - -[tool.coverage.run] -branch = true -omit = [ - "{{module}}/tests/integration/", -] -[tool.coverage.report] -exclude_also = [ - "raise NotImplementedError", - "if __name__ == .__main__.:", - "@(abc\\.)?abstractmethod", -] -ignore_errors = true -fail_under = 50 - -[tool.pytest.ini_options] -addopts = ["-vvv", "--junitxml=junit.xml"] -asyncio_mode = "strict" -testpaths = "cpp_template/tests" - -[tool.ruff] -line-length = 150 - -[tool.ruff.lint] -extend-select = ["I"] - -[tool.ruff.lint.isort] -combine-as-imports = true -default-section = "third-party" -known-first-party = ["{{module}}"] -section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"] - -[tool.ruff.lint.per-file-ignores] -"__init__.py" = ["F401", "F403"] - -[tool.setuptools] -py-modules = ["cpp_template"] diff --git a/cpp/pyproject.toml.jinja b/cpp/pyproject.toml.jinja new file mode 100644 index 0000000..c30272b --- /dev/null +++ b/cpp/pyproject.toml.jinja @@ -0,0 +1,147 @@ +[build-system] +requires = [ + "hatchling", + "hatch-cpp", + "pybind11", +] +build-backend="hatchling.build" + +[project] +name = "{{project_name_formatted}}" +authors = [{name = "{{team}}", email = "{{email}}"}] +description = "{{project_description}}" +readme = "README.md" +license = { text = "Apache-2.0" } +version = "0.1.0" +requires-python = ">=3.9" +keywords = [] + +classifiers = [ + "Development Status :: 3 - Alpha", + "Programming Language :: Python", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] + +dependencies = [] + +[project.optional-dependencies] +develop = [ + "build", + "bump-my-version", + "check-manifest", + "cibuildwheel", + "hatch-cpp", + "hatchling", + "pytest", + "pytest-cov", + "ruff", + "twine", + "wheel", +] + +[project.scripts] + +[project.urls] +Repository = "https://github.com/{{github}}/{{project_name_formatted}}" +Homepage = "https://github.com/{{github}}/{{project_name_formatted}}" + +[tool.bumpversion] +current_version = "0.1.0" +commit = true +tag = true + +[[tool.bumpversion.files]] +filename = "{{module}}/__init__.py" +search = '__version__ = "{current_version}"' +replace = '__version__ = "{new_version}"' + +[[tool.bumpversion.files]] +filename = "pyproject.toml" +search = 'version = "{current_version}"' +replace = 'version = "{new_version}"' + +[tool.check-manifest] +ignore = [ + ".copier-answers.yml", + ".clang-format", + "Makefile", + "docs/**/*", +] + +[tool.cibuildwheel] +build = "cp39-* cp310-* cp311-* cp312-*" +test-command = "echo 'TODO'" +test-requires = [] + +[tool.cibuildwheel.linux] +skip = "*i686 musllinux*" + +[tool.cibuildwheel.macos] +environment = {MACOSX_DEPLOYMENT_TARGET="11.0"} +archs = "arm64" + +[tool.cibuildwheel.windows] +archs = "AMD64" +skip = "*win32 *arm_64" + +[tool.coverage.run] +branch = true +omit = [ + "{{module}}/tests/integration/", +] +[tool.coverage.report] +exclude_also = [ + "raise NotImplementedError", + "if __name__ == .__main__.:", + "@(abc\\.)?abstractmethod", +] +ignore_errors = true +fail_under = 50 + +[tool.hatch.build] +artifacts = [ + "project/*.dll", + "project/*.dylib", + "project/*.so", +] + +[tool.hatch.build.sources] +src = "/" + +[tool.hatch.build.hooks.hatch-cpp] +verbose = true +libraries = [ +{name = "{{module}}/extension", sources = ["cpp/cpp-template/extension.cpp"], include-dirs = ["cpp"], binding="pybind11"} +] + +[tool.hatch.build.targets.sdist] +packages = ["{{module}}", "cpp"] + +[tool.hatch.build.targets.wheel] +packages = ["{{module}}"] + +[tool.pytest.ini_options] +addopts = ["-vvv", "--junitxml=junit.xml"] +asyncio_mode = "strict" +testpaths = "{{module}}/tests" + +[tool.ruff] +line-length = 150 + +[tool.ruff.lint] +extend-select = ["I"] + +[tool.ruff.lint.isort] +combine-as-imports = true +default-section = "third-party" +known-first-party = ["{{module}}"] +section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"] + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F401", "F403"] diff --git a/cpp/setup.py b/cpp/setup.py deleted file mode 100644 index 4d693aa..0000000 --- a/cpp/setup.py +++ /dev/null @@ -1,25 +0,0 @@ -import os -import multiprocessing -import sys -from skbuild import setup - -python_version = f"{sys.version_info.major}.{sys.version_info.minor}" -cmake_args = [f"-DPYTHON_VERSION={python_version}"] - - -if "CMAKE_ARGS" in os.environ: - cmake_args.extend(os.environ["CMAKE_ARGS"].split(" ")) - -if "STATIC_PYTHON" in os.environ: - cmake_args.append("-DSTATIC_PYTHON=On") - -if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ: - os.environ["CMAKE_BUILD_PARALLEL_LEVEL"] = str(multiprocessing.cpu_count()) - -setup( - name="cpp_template", - version="0.1.0", - packages=["cpp_template"], - cmake_install_dir="cpp_template", - cmake_args=cmake_args, -) diff --git a/cpp/cpp_template/__init__.py b/cpp/{{module}}/__init__.py similarity index 100% rename from cpp/cpp_template/__init__.py rename to cpp/{{module}}/__init__.py index e38c2ae..f661b47 100644 --- a/cpp/cpp_template/__init__.py +++ b/cpp/{{module}}/__init__.py @@ -1,7 +1,7 @@ import os import os.path -from .extension import * +from .extension import * __version__ = "0.1.0" diff --git a/cpp/cpp_template/tests/test_all.py b/cpp/{{module}}/tests/test_all.py.jinja similarity index 71% rename from cpp/cpp_template/tests/test_all.py rename to cpp/{{module}}/tests/test_all.py.jinja index 54286d6..4097771 100644 --- a/cpp/cpp_template/tests/test_all.py +++ b/cpp/{{module}}/tests/test_all.py.jinja @@ -1,4 +1,4 @@ -from cpp_template import add +from {{module}} import add class TestAll: diff --git a/js/pyproject.toml.jinja b/js/pyproject.toml.jinja index 4396731..97509f4 100644 --- a/js/pyproject.toml.jinja +++ b/js/pyproject.toml.jinja @@ -74,7 +74,6 @@ ignore = [ ".copier-answers.yml", "js/pnpm-lock.yaml", "Makefile", - "setup.py", "{{module}}/extension/**/*", "docs/**/*", "js/dist/**/*", diff --git a/js/setup.py b/js/setup.py deleted file mode 100644 index aefdf20..0000000 --- a/js/setup.py +++ /dev/null @@ -1 +0,0 @@ -__import__("setuptools").setup() diff --git a/jupyter/pyproject.toml.jinja b/jupyter/pyproject.toml.jinja index 0ecb7fa..c5ef52d 100644 --- a/jupyter/pyproject.toml.jinja +++ b/jupyter/pyproject.toml.jinja @@ -76,7 +76,6 @@ ignore = [ ".copier-answers.yml", "js/pnpm-lock.yaml", "Makefile", - "setup.py", "{{module}}/labextension/**", "{{module}}/nbextension/**", "docs/**/*", diff --git a/jupyter/setup.py b/jupyter/setup.py deleted file mode 100644 index aefdf20..0000000 --- a/jupyter/setup.py +++ /dev/null @@ -1 +0,0 @@ -__import__("setuptools").setup() diff --git a/python/pyproject.toml.jinja b/python/pyproject.toml.jinja index eb3317e..644f7fb 100644 --- a/python/pyproject.toml.jinja +++ b/python/pyproject.toml.jinja @@ -64,7 +64,6 @@ replace = 'version = "{new_version}"' ignore = [ ".copier-answers.yml", "Makefile", - "setup.py", "docs/**/*", ] diff --git a/python/setup.py b/python/setup.py deleted file mode 100644 index aefdf20..0000000 --- a/python/setup.py +++ /dev/null @@ -1 +0,0 @@ -__import__("setuptools").setup() diff --git a/rust/pyproject.toml.jinja b/rust/pyproject.toml.jinja index d09fce3..39cc65c 100644 --- a/rust/pyproject.toml.jinja +++ b/rust/pyproject.toml.jinja @@ -76,7 +76,6 @@ replace = 'version = "{new_version}"' ignore = [ ".copier-answers.yml", "Makefile", - "setup.py", "docs/**/*", "rust/.config/*", "rust/Cargo.lock", diff --git a/rust/setup.py b/rust/setup.py deleted file mode 100644 index aefdf20..0000000 --- a/rust/setup.py +++ /dev/null @@ -1 +0,0 @@ -__import__("setuptools").setup()