diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index f2c69a9..8612898 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: platform: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.8", "3.10"] + python-version: ["3.8", "3.11"] runs-on: ${{ matrix.platform }} diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 8c0c680..747c9d6 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: platform: [windows-latest, macos-latest, ubuntu-latest] - python-version: ["3.7", "3.11", "pypy-3.8"] + python-version: ["3.7", "3.12", "pypy-3.9"] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index bd058c8..55e9657 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -69,6 +69,9 @@ jobs: needs: [build_wheels, build_sdist] runs-on: ubuntu-latest if: github.event_name == 'release' && github.event.action == 'published' + environment: pypi + permissions: + id-token: write steps: - uses: actions/setup-python@v4 @@ -81,5 +84,3 @@ jobs: path: dist - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.pypi_password }} diff --git a/.gitignore b/.gitignore index 6d1889e..4172a9f 100644 --- a/.gitignore +++ b/.gitignore @@ -140,3 +140,4 @@ dmypy.json cython_debug/ _skbuild/ +.pyodide-xbuildenv/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 928b01d..a1791af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,26 @@ -cmake_minimum_required(VERSION 3.15...3.26) +# Require CMake 3.15+ (matching scikit-build-core) Use new versions of all +# policies up to CMake 3.27 +cmake_minimum_required(VERSION 3.15...3.27) +# Scikit-build-core sets these values for you, or you can just hard-code the +# name and version. project( ${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES CXX) +# Find the module development requirements (requires FindPython from 3.17 or +# scikit-build-core's built-in backport) find_package(Python REQUIRED COMPONENTS Interpreter Development.Module) find_package(pybind11 CONFIG REQUIRED) +# Add a library using FindPython's tooling (pybind11 also provides a helper like +# this) python_add_library(_core MODULE src/main.cpp WITH_SOABI) target_link_libraries(_core PRIVATE pybind11::headers) + +# This is passing in the version as a define just as an example target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION}) +# The install directory is the output (wheel) directory install(TARGETS _core DESTINATION scikit_build_example) diff --git a/README.md b/README.md index 64c1eb4..5a51b65 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -scikit_build_example -============== +# scikit_build_example [![Gitter][gitter-badge]][gitter-link] @@ -9,10 +8,8 @@ scikit_build_example | pip builds | [![Pip Actions Status][actions-pip-badge]][actions-pip-link] | - -An example project built with [pybind11](https://github.com/pybind/pybind11) -and scikit-build-core. Python 3.7+ (see older commits for older versions of -Python). +An example project built with [pybind11][] and [scikit-build-core][]. Python +3.7+ (see older commits for older versions of Python using [scikit-build (classic)][]). [gitter-badge]: https://badges.gitter.im/pybind/Lobby.svg @@ -25,34 +22,71 @@ Python). [actions-wheels-link]: https://github.com/pybind/scikit_build_example/actions?query=workflow%3AWheels [actions-wheels-badge]: https://github.com/pybind/scikit_build_example/workflows/Wheels/badge.svg -Installation ------------- +## Installation -- clone this repository +- Clone this repository - `pip install ./scikit_build_example` +## Test call + +```python +import scikit_build_example + +scikit_build_example.add(1, 2) +``` + +## Files + +This example has several files that are a good idea, but aren't strictly +necessary. The necessary files are: + +* `pyproject.toml`: The Python project file +* `CMakeLists.txt`: The CMake configuration file +* `src/main.cpp`: The source file for the C++ build +* `src/scikit_build_example/__init__.py`: The Python portion of the module. The root of the module needs to be ``, `src/`, or `python/` to be auto-discovered. + +These files are also expected and highly recommended: + +* `.gitignore`: Git's ignore list, also used by `scikit-build-core` to select files for the SDist +* `README.md`: The source for the PyPI description +* `LICENSE`: The license file -CI Examples ------------ +There are also several completely optional directories: + +* `.github`: configuration for [Dependabot][] and [GitHub Actions][] +* `conda.recipe`: Example recipe. Normally you should submit projects to conda-forge instead of building them yourself, but this is useful for testing the example. +* `docs/`: Documentation +* `tests/`: Tests go here + +And some optional files: + +* `.pre-commit-config.yaml`: Configuration for the fantastic static-check runner [pre-commit][]. +* `noxfile.py`: Configuration for the [nox][] task runner, which helps make setup easier for contributors. + +This is a simplified version of the recommendations in the [Scientific-Python +Development Guide][], which is a _highly_ recommended read for anyone +interested in Python package development (Scientific or not). The guide also +has a cookiecutter that includes scikit-build-core and pybind11 as a backend +choice. + +### CI Examples There are examples for CI in `.github/workflows`. A simple way to produces binary "wheels" for all platforms is illustrated in the "wheels.yml" file, -using [`cibuildwheel`][]. +using [cibuildwheel][]. -License -------- +## License pybind11 is provided under a BSD-style license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license. -Test call ---------- - -```python -import scikit_build_example - -scikit_build_example.add(1, 2) -``` - -[`cibuildwheel`]: https://cibuildwheel.readthedocs.io +[cibuildwheel]: https://cibuildwheel.readthedocs.io +[scientific-python development guide]: https://learn.scientific-python.org/development +[dependabot]: https://docs.github.com/en/code-security/dependabot +[github actions]: https://docs.github.com/en/actions +[pre-commit]: https://pre-commit.com +[nox]: https://nox.thea.codes +[pybind11]: https://pybind11.readthedocs.io +[scikit-build-core]: https://scikit-build-core.readthedocs.io +[scikit-build (classic)]: https://scikit-build.readthedocs.io diff --git a/pyproject.toml b/pyproject.toml index f3032cf..69dd018 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] [project.optional-dependencies] @@ -35,9 +36,9 @@ wheel.expand-macos-universal-tags = true minversion = "6.0" addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] xfail_strict = true +log_cli_level = "INFO" filterwarnings = [ "error", - "ignore:(ast.Str|Attribute s|ast.NameConstant|ast.Num) is deprecated:DeprecationWarning:_pytest", # Python 3.12 ] testpaths = ["tests"] @@ -77,9 +78,10 @@ extend-select = [ "PD", # pandas-vet ] ignore = [ - "PLR", # Design related pylint codes + "PLR09", # Too many X + "PLR2004", # Magic comparison ] isort.required-imports = ["from __future__ import annotations"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "tests/**" = ["T20"]