Skip to content

Commit

Permalink
feat: adding PEP 621 setuptools (#72)
Browse files Browse the repository at this point in the history
* feat: adding PEP 621 setuptools

* fix: add explicit src dir

* fix: include wheel

* Add experimental auto-discovery for setuptools621

* feat: rely on setuptools auto-discovery for src-layout

* Update README.md

* docs: nicer numbering

* chore: use released setuptools

* fix: broken due to upper limit on sphinx causing bugs

Co-authored-by: Anderson Bravalheri <[email protected]>
  • Loading branch information
henryiii and abravalheri authored Mar 24, 2022
1 parent 8ff324c commit 88b5726
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
- name: Lint hatch
run: pipx run nox --forcecolor -s 'lint(hatch)'

- name: Lint setuptools PEP 621
run: pipx run nox --forcecolor -s 'lint(setuptools621)'


checks:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
Expand Down Expand Up @@ -93,6 +96,9 @@ jobs:
- name: Test hatch
run: nox --forcecolor -s 'tests(hatch)'

- name: Test setuptools PEP 621
run: nox --forcecolor -s 'tests(setuptools621)'

- name: Native poetry tooling
run: nox --forcecolor -s 'native(poetry)'

Expand Down Expand Up @@ -153,6 +159,11 @@ jobs:
pipx run nox --forcecolor -s 'nox(hatch)'
pipx run nox --forcecolor -s 'nox(hatch)' -- docs
- name: Test setuptools PEP 621
run: |
pipx run nox --forcecolor -s 'nox(setuptools621)'
pipx run nox --forcecolor -s 'nox(setuptools621)' -- docs
dist:
name: Distribution build
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,28 @@ During generation you can select from the following backends for your package:

1. [setuptools][]: The classic build system. Most powerful, but high learning curve
and lots of configuration required.
2. [pybind11][]: This is setuptools but with an C++ extension written in [pybind11][]
2. [setuptools621][setuptools]: The classic build system, but with the new standardized
configuration. EXPERIMENTAL.
3. [pybind11][]: This is setuptools but with an C++ extension written in [pybind11][]
and wheels generated by [cibuildwheel][].
3. [poetry][]: An all-in-one solution to pure Python projects. Replaces
4. [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.
4. [flit][]: A modern, lightweight [PEP 621][] build system for pure Python
5. [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.
5. [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][].
6. [trampolim][]: A modern [PEP 621][] builder with support for tasks, allowing
7. [trampolim][]: A modern [PEP 621][] builder with support for tasks, allowing
arbitrary Python to run during the build process if needed.
7. [whey][]: A modern [PEP 621][] builder with some automation options for Trove
8. [whey][]: A modern [PEP 621][] builder with some automation options for Trove
classifiers. Development seems to be stalled, possibly.
8. [maturin][]: A [PEP 621][] builder for Rust binary extensions.
9. [hatch][]: A package manager similar to Poetry/PDM. Hatchling (the backend) is
9. [maturin][]: A [PEP 621][] builder for Rust binary extensions.
10. [hatch][]: A package manager similar to Poetry/PDM. Hatchling (the backend) is
a modern builder with nice error messages.

Currently, the best choices are probalby flit, PDM, or hatch for pure python projects,
Currently, the best choices are probably flit, PDM, or hatch for pure python projects,
and setuptools (such as the pybind11 choice) for binary projects.

#### To use:
Expand Down
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"org": "Scikit-HEP",
"url": "https://github.com/{{ cookiecutter.org }}/{{ cookiecutter.project_name }}",
"full_name": "My Name",
"project_type": ["setuptools", "pybind11", "poetry", "flit", "pdm", "trampolim", "whey", "maturin", "hatch"],
"project_type": ["setuptools", "pybind11", "poetry", "flit", "pdm", "trampolim", "whey", "maturin", "hatch", "setuptools621"],
"email": "[email protected]",
"maintainer": "The Scikit-HEP admins",
"maintainer_email": "[email protected]",
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", "poetry", "flit", "trampolim", "whey", "pdm", "maturin", "hatch"}
project_types = {"setuptools", "pybind11", "poetry", "flit", "trampolim", "whey", "pdm", "maturin", "hatch", "setuptools621"}
other_project_types = project_types - {project_type}

project_underscore_name = project_name.replace("-", "_")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ build-backend = "maturin"
{%- elif cookiecutter.project_type == "hatch" %}
requires = ["hatchling>=0.7"]
build-backend = "hatchling.build"
{%- elif cookiecutter.project_type == "setuptools621" %}
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
{%- else %}
requires = ["flit_core >=3.4"]
build-backend = "flit_core.buildapi"
Expand Down Expand Up @@ -80,7 +83,7 @@ dev = [
"pytest >=6",
]
docs = [
"Sphinx~=3.0",
"Sphinx>=4.0",
"myst_parser>=0.13",
"sphinx-book-theme>=0.1.0",
"sphinx_copybutton",
Expand Down

0 comments on commit 88b5726

Please sign in to comment.