From 7ae507518cf18fa2985b7ada31d7f131694e3d02 Mon Sep 17 00:00:00 2001 From: wpk Date: Tue, 6 Feb 2024 11:22:35 -0500 Subject: [PATCH] chore: update cruft --- .cruft.json | 2 +- .git_archival.txt | 4 ++++ .gitattributes | 1 + Makefile | 13 +++++++++++++ noxfile.py | 7 ++++++- pyproject.toml | 21 +++++++++++++++++++-- tools/projectconfig.py | 7 ++++++- 7 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 .git_archival.txt create mode 100644 .gitattributes diff --git a/.cruft.json b/.cruft.json index 240f5b4..3efcf7a 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/usnistgov/cookiecutter-nist-python.git", - "commit": "5c831aacaf85f4a0025a66074fd34fd056da7b22", + "commit": "acd5ad73b5144f5345586e258f0f5e3bd3191142", "checkout": "develop", "context": { "cookiecutter": { diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 0000000..8fb235d --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1,4 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ +ref-names: $Format:%D$ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..00a7b00 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.git_archival.txt export-subst diff --git a/Makefile b/Makefile index acf73f9..b05ea06 100644 --- a/Makefile +++ b/Makefile @@ -214,6 +214,19 @@ testrelease: ## test release on testpypi release: ## release to pypi, can pass posargs=... $(NOX) -s publish -- +p release +.PHONY: check-release check-wheel check-dist +check-release: ## run twine check on dist + $(NOX) -s publish -- +p check +check-wheel: ## Run check-wheel-contents (requires check-wheel-contents to be installed) + check-wheel-contents dist/*.whl +check-dist: check-release check-wheel ## Run check-release and check-wheel +.PHONY: list-wheel list-sdist list-dist +list-wheel: ## Cat out contents of wheel + unzip -vl dist/*.whl +list-sdist: ## Cat out contents of sdist + tar -tzvf dist/*.tar.gz +list-dist: list-wheel list-sdist ## Cat out sdist and wheel contents + # ** dist conda .PHONY: conda-recipe conda-build conda-recipe: ## build conda recipe can pass posargs=... diff --git a/noxfile.py b/noxfile.py index 4642908..127976a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -246,7 +246,9 @@ class SessionParams(DataclassParser): build_silent: bool = False # publish - publish: list[Literal["release", "test"]] | None = add_option("-p", "--publish") + publish: list[Literal["release", "test", "check"]] | None = add_option( + "-p", "--publish" + ) publish_run: RUN_ANNO = None # conda-recipe/grayskull @@ -986,6 +988,9 @@ def publish(session: nox.Session, opts: SessionParams) -> None: elif cmd == "release": session.run("twine", "upload", "dist/*") + elif cmd == "check": + session.run("twine", "check", "--strict", "dist/*") + # # ** Dist conda @nox.session(name="conda-recipe") diff --git a/pyproject.toml b/pyproject.toml index aec0ea2..104932d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -211,13 +211,30 @@ known-first-party = ["pyproject2conda"] [tool.ruff.format] docstring-code-format = true +[tool.check-wheel-contents] +toplevel = ["pyproject2conda"] +src_dir = ["src"] + # * Testing -------------------------------------------------------------------- [tool.pytest.ini_options] -addopts = "--doctest-modules --doctest-glob='*.md' --pyargs" -testpaths = ["pyproject2conda", "tests", "README.md"] +addopts = [ + "--doctest-modules", + "--doctest-glob=*.md", + "--pyargs", + "--cov-config=pyproject.toml", +] +testpaths = [ + "pyproject2conda", + "README.md", + "tests", +] + +[tool.coverage.run] +branch = true [tool.coverage.report] +show_missing = true exclude_also = ["if TYPE_CHECKING:", "@overload"] omit = ["*/vendored/*", "*/_typing.py", "*/__main__.py"] include = ["src/*"] diff --git a/tools/projectconfig.py b/tools/projectconfig.py index 73591ea..9ee00a2 100644 --- a/tools/projectconfig.py +++ b/tools/projectconfig.py @@ -14,7 +14,12 @@ from typing import TYPE_CHECKING, Any, Mapping if TYPE_CHECKING: - from typing_extensions import Self + import sys + + if sys.version_info < (3, 11): + from typing_extensions import Self + else: + from typing import Self class ProjectConfig: