Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
- name: Lint scikit-build
run: pipx run nox -s 'lint(skbuild)'

- name: Lint meson-python
run: pipx run nox -s 'lint(mesonpy)'

- name: Lint poetry
run: pipx run nox -s 'lint(poetry)'

Expand Down Expand Up @@ -117,6 +120,13 @@ jobs:
if: matrix.python-version != 'pypy-3.7'
run: nox -s 'native(pdm)'

- name: Activate MSVC for Meson
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Test meson-python
run: nox -s 'tests(mesonpy)'

nox:
name: Check included Noxfile
runs-on: ubuntu-latest
Expand Down Expand Up @@ -179,6 +189,16 @@ jobs:
pipx run nox -s 'nox(setuptools621)'
pipx run nox -s 'nox(setuptools621)' -- docs

- name: Activate MSVC for Meson
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Test meson-python
run: |
pipx run nox -s 'nox(mesonpy)'
pipx run nox -s 'nox(mesonpy)' -- docs


dist:
name: Distribution build
runs-on: ubuntu-latest
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ templates for Python packages?
- Designed from the [Scikit-HEP developer guidelines][]: Every decision is
clearly documented and every tool described.
- Template generation tested in GitHub Actions using nox.
- Eleven different backends to choose from for building packages.
- Twelve different backends to choose from for building packages.
- Includes several compiled backends using pybind11, with wheels produced for
all platforms using cibuildwheel.
- Follows PyPA best practices.
Expand All @@ -34,15 +34,16 @@ During generation you can select from the following backends for your package:
standardized configuration. Python 3.7+.
4. [pybind11][]: This is setuptools but with an C++ extension written in
[pybind11][] and wheels generated by [cibuildwheel][].
5. [scikit-build][]: A scikit-build (CMake) project also using pybind11, wraps
setuptools currently. **(Recommended for C++ projects)**
5. [scikit-build][]: A scikit-build (CMake) project also using pybind11, using
scikit-build-core. **(Recommended for C++ projects)**
6. [meson-python][]: A Meson project also using pybind11.
6. [poetry][]: An all-in-one solution to pure Python projects. Replaces
setuptools, venv/pipenv, pip, wheel, and twine. Higher learning curve, but is
all-in-one. Makes some bad default assumptions for libraries.
7. [flit][]: A modern, lightweight [PEP 621][] build system for pure Python
projects. Replaces setuptools, no MANIFEST.in, setup.py, or setup.cfg. Low
learning curve. Easy to bootstrap into new distributions. Difficult to get
the right files included, little dynamic metadata support.
the right files included, little dynamic metadata support.
8. [pdm][]: A modern, less opinionated all-in-one solution to pure Python
projects supporting standards. Replaces setuptools, venv/pipenv, pip, wheel,
and twine. Supports [PEP 621][], and also the unaccepted [PEP 582][].
Expand Down Expand Up @@ -169,5 +170,6 @@ not use pre-commit properly. It also has quite a bit of custom code.
[maturin]: https://maturin.rs
[hypermodern]: https://github.com/cjolowicz/cookiecutter-hypermodern-python
[hatch]: https://github.com/ofek/hatch
[meson-python]: https://meson-python.readthedocs.io
[pep 582]: https://www.python.org/dev/peps/pep-0582
[pep 621]: https://www.python.org/dev/peps/pep-0621
1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"setuptools621",
"pybind11",
"skbuild",
"mesonpy",
"poetry",
"flit",
"pdm",
Expand Down
2 changes: 1 addition & 1 deletion hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

project_name = "{{ cookiecutter.project_name }}"
project_type = "{{ cookiecutter.project_type }}"
project_types = {"setuptools", "pybind11", "skbuild", "poetry", "flit", "trampolim", "whey", "pdm", "maturin", "hatch", "setuptools621"}
project_types = {"setuptools", "pybind11", "skbuild", "mesonpy", "poetry", "flit", "trampolim", "whey", "pdm", "maturin", "hatch", "setuptools621"}
other_project_types = project_types - {project_type}

project_underscore_name = project_name.replace("-", "_")
Expand Down
8 changes: 7 additions & 1 deletion {{cookiecutter.project_name}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{%- set compiled = cookiecutter.project_type in ["pybind11", "maturin", "skbuild"] -%}
{%- set compiled = cookiecutter.project_type in ["pybind11", "maturin", "skbuild", "mesonpy"] -%}
name: CI

on:
Expand Down Expand Up @@ -64,6 +64,12 @@ jobs:
with:
python-version: {% raw %}${{ matrix.python-version }}{% endraw %}

{%- if cookiecutter.project_type == "mesonpy" %}
- name: Activate MSVC for Meson
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
{%- endif %}

- name: Install package
run: python -m pip install .[test]

Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ repos:

{%- endif %}

{%- if cookiecutter.project_type in ["pybind11", "skbuild"] %}
{%- if cookiecutter.project_type in ["pybind11", "skbuild", "mesonpy"] %}

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v14.0.6"
Expand Down
34 changes: 34 additions & 0 deletions {{cookiecutter.project_name}}/meson-mesonpy.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
project(
'{{ cookiecutter.project_name.replace("-", "_") }}',
'cpp',
version: '0.1.0',
license: '{{ cookiecutter.license }}',
meson_version: '>= 0.64.0',
default_options: [
'buildtype=debugoptimized',
'cpp_std=c++11',
],
)
name = '{{ cookiecutter.project_name.replace("-", "_") }}'

py_mod = import('python')
py = py_mod.find_installation(pure: false)

pybind11_config = find_program('pybind11-config')
pybind11_config_ret = run_command(pybind11_config, ['--includes'], check: true)
pybind11 = declare_dependency(
include_directories: [pybind11_config_ret.stdout().split('-I')[-1].strip()],
)

install_subdir('src' / name, install_dir: py.get_install_dir() / name, strip_directory: true)

py.extension_module('_core',
'src/main.cpp',
subdir: '{{ cookiecutter.project_name.replace("-", "_") }}',
install: true,
dependencies : [pybind11],
link_language : 'cpp',
override_options: [
'cpp_rtti=true',
]
)
3 changes: 3 additions & 0 deletions {{cookiecutter.project_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ build-backend = "setuptools.build_meta"
{%- elif cookiecutter.project_type == "skbuild" %}
requires = ["pybind11", "scikit-build-core"]
build-backend = "scikit_build_core.build"
{%- elif cookiecutter.project_type == "mesonpy" %}
requires = ["pybind11", "meson-python"]
build-backend = "mesonpy"
{%- elif cookiecutter.project_type == "poetry" %}
requires = ["poetry_core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Expand Down