Skip to content

Commit e74a817

Browse files
feat: update Poetry to 2.0+ and PEP 621 (#534)
* feat: update Poetry to 2.0+ and PEP 621 Signed-off-by: Henry Schreiner <[email protected]> * style: pre-commit fixes * fix: support Poetry 2's VIRTUAL_ENV change Signed-off-by: Henry Schreiner <[email protected]> * chore: bump schema-store Signed-off-by: Henry Schreiner <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 2c90b20 commit e74a817

File tree

4 files changed

+27
-89
lines changed

4 files changed

+27
-89
lines changed

docs/_includes/interactive_repo_review.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
deps={[
2323
"repo-review~=0.11.1",
2424
"sp-repo-review==2024.08.19",
25-
"validate-pyproject-schema-store==2024.08.19",
25+
"validate-pyproject-schema-store==2025.01.10",
2626
"validate-pyproject[all]~=0.19.0",
2727
]}
2828
/>,

docs/pages/guides/docs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ import importlib.metadata
8585
from typing import Any
8686

8787
project = "package"
88-
copyright = "2024, My Name"
88+
copyright = "2025, My Name"
8989
author = "My Name"
9090
version = release = importlib.metadata.version("package")
9191

noxfile.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ def native(session: nox.Session, backend: str, vcs: bool) -> None:
249249

250250
if backend == "hatch":
251251
session.run(backend, "run", "test")
252+
elif backend == "poetry":
253+
session.run(backend, "sync", env={"VIRTUAL_ENV": None})
254+
session.run(backend, "run", "pytest", env={"VIRTUAL_ENV": None})
252255
else:
253256
session.run(backend, "install")
254257
session.run(backend, "run", "pytest")

{{cookiecutter.project_name}}/pyproject.toml

Lines changed: 22 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -42,94 +42,18 @@ requires = ["meson-python", "pybind11"]
4242
build-backend = "mesonpy"
4343
{%- elif cookiecutter.backend == "poetry" %}
4444
{%- if cookiecutter.vcs %}
45-
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
45+
requires = ["poetry-core>=2.0.0", "poetry-dynamic-versioning"]
4646
build-backend = "poetry_dynamic_versioning.backend"
4747
{%- else %}
48-
requires = ["poetry_core>=1.0.0"]
48+
requires = ["poetry_core>=2.0.0"]
4949
build-backend = "poetry.core.masonry.api"
5050
{%- endif %}
5151
{%- endif %}
5252

5353

54-
{%- if cookiecutter.backend == "poetry" %}
55-
56-
57-
[tool.poetry]
58-
name = "{{ cookiecutter.project_name }}"
59-
{%- if cookiecutter.vcs %}
60-
version = "0.0.0"
61-
{%- else %}
62-
version = "0.1.0"
63-
{%- endif %}
64-
authors = [
65-
"{{ cookiecutter.full_name }} <{{ cookiecutter.email }}>",
66-
]
67-
{%- if cookiecutter.org == "scikit-hep" %}
68-
maintainers = [
69-
"The Scikit-HEP admins <[email protected]>",
70-
]
71-
{%- endif %}
72-
homepage = "{{ cookiecutter.url }}"
73-
repository = "{{ cookiecutter.url }}"
74-
{%- if cookiecutter.license == "BSD" %}
75-
license = "BSD-3-Clause"
76-
{%- elif cookiecutter.license == "Apache" %}
77-
license = "Apache-2.0"
78-
{%- elif cookiecutter.license == "MIT" %}
79-
license = "MIT"
80-
{%- endif %}
81-
description = "{{ cookiecutter.project_short_description }}"
82-
readme = "README.md"
83-
84-
classifiers = [
85-
"Development Status :: 1 - Planning",
86-
"Intended Audience :: Science/Research",
87-
"Intended Audience :: Developers",
88-
"Operating System :: OS Independent",
89-
"Topic :: Scientific/Engineering",
90-
"Typing :: Typed",
91-
]
92-
93-
[tool.poetry.dependencies]
94-
python = ">=3.9"
95-
96-
furo = { version = ">=2023.08.17", optional = true }
97-
myst_parser = { version = ">=0.13", optional = true }
98-
pytest = { version = ">=6", optional = true }
99-
pytest-cov = { version = ">=3", optional = true }
100-
sphinx = { version = ">=7.0", optional = true }
101-
sphinx_copybutton = { version = ">=0.3.0", optional = true }
102-
sphinx-autodoc-typehints = { version = "*", optional = true }
103-
docutils = { version = "!=0.21.post1", optional = true }
104-
105-
[tool.poetry.dev-dependencies]
106-
pytest = ">= 6"
107-
pytest-cov = ">= 3"
108-
109-
[tool.poetry.extras]
110-
test = ["pytest", "pytest-cov"]
111-
dev = ["pytest", "pytest-cov"]
112-
docs = [
113-
"furo",
114-
"myst_parser",
115-
"sphinx",
116-
"sphinx_autodoc_typehints",
117-
"sphinx_copybutton",
118-
"docutils",
119-
]
120-
121-
{%- if cookiecutter.vcs %}
122-
123-
[tool.poetry-dynamic-versioning]
124-
enable = true
125-
substitution.files = ["src/{{ cookiecutter.__project_slug }}/__init__.py"]
126-
{%- endif %}
127-
{%- else %}
128-
129-
13054
[project]
13155
name = "{{ cookiecutter.project_name }}"
132-
{%- if cookiecutter.backend in ['maturin', 'mesonpy'] or not cookiecutter.vcs and cookiecutter.backend in ['setuptools', 'pybind11', 'skbuild'] %}
56+
{%- if cookiecutter.backend in ['maturin', 'mesonpy'] or not cookiecutter.vcs and cookiecutter.backend in ['setuptools', 'pybind11', 'skbuild', 'poetry'] %}
13357
version = "0.1.0"
13458
{%- endif %}
13559
authors = [
@@ -196,7 +120,6 @@ Homepage = "{{ cookiecutter.url }}"
196120
"Bug Tracker" = "{{ cookiecutter.url }}/issues"
197121
Discussions = "{{ cookiecutter.url }}/discussions"
198122
Changelog = "{{ cookiecutter.url }}/releases"
199-
{%- endif %}
200123

201124

202125
{%- if cookiecutter.backend == "skbuild" %}
@@ -257,17 +180,32 @@ path = "src/{{ cookiecutter.__project_slug }}/__init__.py"
257180
[tool.pdm.dev-dependencies]
258181
devtest = ["pytest", "pytest-cov"]
259182

183+
{%- elif cookiecutter.backend == "poetry" %}
184+
{%- if cookiecutter.vcs %}
185+
[tool.poetry]
186+
version = "0.0.0"
187+
188+
[tool.poetry.requires-plugins]
189+
poetry-dynamic-versioning = { version = ">=1.0.0", extras = ["plugin"] }
190+
191+
[tool.poetry-dynamic-versioning]
192+
enable = true
193+
substitution.files = ["src/{{ cookiecutter.__project_slug }}/__init__.py"]
260194
{%- endif %}
261195

262-
{%- if cookiecutter.backend in ["pybind11", "poetry", "flit", "skbuild", "setuptools"] and cookiecutter.vcs %}
196+
[tool.poetry.group.test.dependencies]
197+
pytest = ">= 6"
198+
pytest-cov = ">= 3"
199+
{%- endif %}
200+
201+
202+
{%- if cookiecutter.backend in ["pybind11", "flit", "skbuild", "setuptools"] and cookiecutter.vcs %}
263203

264204

265205
[tool.setuptools_scm]
266206
write_to = "src/{{ cookiecutter.__project_slug }}/_version.py"
267-
{%- endif %}
268-
269207

270-
{%- if cookiecutter.backend != "poetry" %}
208+
{%- endif %}
271209

272210

273211
[tool.uv]
@@ -276,9 +214,6 @@ dev-dependencies = [
276214
]
277215

278216

279-
{%- endif %}
280-
281-
282217
{%- if cookiecutter.__type == "compiled" %}
283218

284219

0 commit comments

Comments
 (0)