Skip to content

Commit

Permalink
feat: add vcs versioning (#251)
Browse files Browse the repository at this point in the history
* feat: add vcs versioning

Signed-off-by: Henry Schreiner <[email protected]>

* fix: work around bug in PDM-backend version writing

Signed-off-by: Henry Schreiner <[email protected]>

* fixup! feat: add vcs versioning

* ci: fix windows RO error

Signed-off-by: Henry Schreiner <[email protected]>

---------

Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Aug 8, 2023
1 parent 0b1ecf3 commit 8ecc29c
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 120 deletions.
105 changes: 38 additions & 67 deletions .github/workflows/reusable-cookie.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,8 @@ jobs:
steps:
- uses: actions/checkout@v3

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

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

- 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)'

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

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

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

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

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

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

checks:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
Expand All @@ -71,47 +41,48 @@ jobs:
run: pip install nox

- name: Test setuptools
run: nox -s 'tests(setuptools)'
run: nox -s 'tests(setuptools, novcs)' -s 'tests(setuptools, vcs)'

- name: Test pybind11
run: nox -s 'tests(pybind11)'
run: nox -s 'tests(pybind11, novcs)' -s 'tests(pybind11, vcs)'

- name: Test scikit-build
run: nox -s 'tests(skbuild)'
run: nox -s 'tests(skbuild, novcs)' -s 'tests(skbuild, vcs)'

- name: Test poetry
run: nox -s 'tests(poetry)'
run: nox -s 'tests(poetry, novcs)' -s 'tests(poetry, vcs)'

- name: Test flit
run: nox -s 'tests(flit)'
run: nox -s 'tests(flit, novcs)' -s 'tests(flit, vcs)'

- name: Test pdm
run: nox -s 'tests(pdm)'
run: nox -s 'tests(pdm, novcs)' -s 'tests(pdm, vcs)'

- name: Test whey
run: nox -s 'tests(whey)'
run: nox -s 'tests(whey, novcs)'

- name: Test maturin
run: nox -s 'tests(maturin)'
run: nox -s 'tests(maturin, novcs)'

- name: Test hatch
run: nox -s 'tests(hatch)'
run: nox -s 'tests(hatch, novcs)' -s 'tests(hatch, vcs)'

- name: Test setuptools PEP 621
run: nox -s 'tests(setuptools621)'
run: nox -s 'tests(setuptools621, novcs)' -s 'tests(setuptools621, vcs)'

- name: Native poetry tooling
run: nox -s 'native(poetry)'
run: nox -s 'native(poetry, novcs)' -s 'native(poetry, vcs)'

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

run: nox -s 'native(pdm, novcs)' -s 'native(pdm, vcs)'

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

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

- name: Compare copier template generation
run: nox -s compare_copier
Expand All @@ -128,62 +99,62 @@ jobs:

- name: Test setuptools
run: |
pipx run nox -s 'nox(setuptools)'
pipx run nox -s 'nox(setuptools)' -- docs
pipx run nox -s 'nox(setuptools, vcs)'
pipx run nox -s 'nox(setuptools, vcs)' -- docs
- name: Test pybind11
run: |
pipx run nox -s 'nox(pybind11)'
pipx run nox -s 'nox(pybind11)' -- docs
pipx run nox -s 'nox(pybind11, vcs)'
pipx run nox -s 'nox(pybind11, vcs)' -- docs
- name: Test scikit-build
run: |
pipx run nox -s 'nox(skbuild)'
pipx run nox -s 'nox(skbuild)' -- docs
pipx run nox -s 'nox(skbuild, vcs)'
pipx run nox -s 'nox(skbuild, vcs)' -- docs
- name: Test poetry
run: |
pipx run nox -s 'nox(poetry)'
pipx run nox -s 'nox(poetry)' -- docs
pipx run nox -s 'nox(poetry, novcs)'
pipx run nox -s 'nox(poetry, novcs)' -- docs
- name: Test flit
run: |
pipx run nox -s 'nox(flit)'
pipx run nox -s 'nox(flit)' -- docs
pipx run nox -s 'nox(flit, novcs)'
pipx run nox -s 'nox(flit, novcs)' -- docs
- name: Test pdm
run: |
pipx run nox -s 'nox(pdm)'
pipx run nox -s 'nox(pdm)' -- docs
pipx run nox -s 'nox(pdm, vcs)'
pipx run nox -s 'nox(pdm, vcs)' -- docs
- name: Test whey
run: |
pipx run nox -s 'nox(whey)'
pipx run nox -s 'nox(whey)' -- docs
pipx run nox -s 'nox(whey, novcs)'
pipx run nox -s 'nox(whey, novcs)' -- docs
- name: Test maturin
run: |
pipx run nox -s 'nox(maturin)'
pipx run nox -s 'nox(maturin)' -- docs
pipx run nox -s 'nox(maturin, novcs)'
pipx run nox -s 'nox(maturin, novcs)' -- docs
- name: Test hatch
run: |
pipx run nox -s 'nox(hatch)'
pipx run nox -s 'nox(hatch)' -- docs
pipx run nox -s 'nox(hatch, vcs)'
pipx run nox -s 'nox(hatch, vcs)' -- docs
- name: Test setuptools PEP 621
run: |
pipx run nox -s 'nox(setuptools621)'
pipx run nox -s 'nox(setuptools621)' -- docs
pipx run nox -s 'nox(setuptools621, vcs)'
pipx run nox -s 'nox(setuptools621, vcs)' -- 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
pipx run nox -s 'nox(mesonpy, novcs)'
pipx run nox -s 'nox(mesonpy, novcs)' -- docs
dist:
name: Distribution build
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ templates for Python packages?
- Lives with the [Scientific-Python Development Guide][]: Every decision is
clearly documented and every tool described, and everything is kept in sync.
- Eleven different backends to choose from for building packages.
- Optional VCS versioning for most backends.
- Template generation tested in GitHub Actions using nox.
- Supports generation with [copier][], [cookiecutter][], and [cruft][].
- Supports GitHub Actions if targeting a `github.com` url (the default), and
Expand Down Expand Up @@ -46,7 +47,7 @@ During generation you can select from the following backends for your package:
projects supporting standards. Replaces setuptools, venv/pipenv, pip, wheel,
and twine. Supports [PEP 621][].
4. [whey][]: A modern [PEP 621][] builder with some automation options for Trove
classifiers. Development seems to be stalled, possibly.
classifiers. Development seems to be stalled, possibly. (No VCS versioning)
5. [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. The only one
Expand All @@ -59,9 +60,9 @@ During generation you can select from the following backends for your package:
[pybind11][] and wheels generated by [cibuildwheel][].
9. [scikit-build][]: A scikit-build (CMake) project also using pybind11, using
scikit-build-core. **(Recommended for C++ projects)**
10. [meson-python][]: A Meson project also using pybind11.
11. [maturin][]: A [PEP 621][] builder for Rust binary extensions.
**(Recommended for Rust projects)**
10. [meson-python][]: A Meson project also using pybind11. (No VCS versioning)
11. [maturin][]: A [PEP 621][] builder for Rust binary extensions. (No VCS
versioning) **(Recommended for Rust projects)**

Currently, the best choice is probably hatch for pure Python projects, and
setuptools (such as the pybind11 choice) for binary projects.
Expand Down
4 changes: 3 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"mesonpy",
"maturin"
],
"vcs": true,
"__year": "{% now 'utc', '%Y' %}",
"__project_slug": "{{ cookiecutter.project_name | lower | replace('-', '_') | replace('.', '_') }}",
"__type": "{{ 'compiled' if cookiecutter.backend in ['pybind11', 'skbuild', 'mesonpy', 'maturin'] else 'pure' }}",
Expand All @@ -45,6 +46,7 @@
"skbuild": "Scikit-build-core - Compiled C++ (recommended)",
"mesonpy": "Meson-python - Compiled C++ (also good)",
"maturin": "Maturin - Compiled Rust (recommended)"
}
},
"vcs": "Use version control for versioning"
}
}
7 changes: 7 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ backend:
"Maturin - Compiled Rust (recommended)": maturin
# [[[end]]]

# [[[cog print(cc.vcs.yaml()) ]]]
vcs:
type: bool
help: Use version control for versioning
# [[[end]]]
when: "{{ backend not in ['whey', 'maturin', 'mesonpy'] }}"

_templates_suffix: ""

_subdirectory: "{% raw %}{{cookiecutter.project_name}}{% endraw %}"
Expand Down
6 changes: 5 additions & 1 deletion helpers/cog_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ def __init__(self, filename: str):
name,
value,
prompt,
"str" if isinstance(value, str) else "",
"str"
if isinstance(value, str)
else "bool"
if isinstance(value, bool)
else "",
choices=choices,
),
)
Loading

0 comments on commit 8ecc29c

Please sign in to comment.