From f44359803dd554e4cb58e089d08a904f0f770033 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 29 Nov 2019 15:33:22 -0800 Subject: [PATCH 01/47] Fix initial ansi colors to stop this time --- regen-git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regen-git.py b/regen-git.py index 391a6ad..d552c23 100755 --- a/regen-git.py +++ b/regen-git.py @@ -79,7 +79,7 @@ def main(): subprocess.check_call(["git", "push", "origin", SKEL_BRANCH]) print( "Good luck, the first " - f"'\x1b[32mgit merge --allow-unrelated-histories {SKEL_BRANCH}\x1b0m' " + f"'\x1b[32mgit merge --allow-unrelated-histories {SKEL_BRANCH}\x1b[0m' " "is typically full of conflicts." ) else: From 3655392061cf4e7717f8f630aa0fadd51e4aa12a Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 29 Nov 2019 17:47:31 -0800 Subject: [PATCH 02/47] Sort requirements-dev, add wheel/twine and volatile wheel/twine are required for 'make release' and volatile has a better NamedTemporaryFile that works on Windows. --- requirements-dev.txt | 8 ++++++-- templates/requirements-dev.txt.in | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index a560191..0479c95 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,9 @@ +black==19.10b0 coverage==4.5.4 +flake8==3.7.9 isort==4.3.21 -black==19.10b0 +mypy==0.750 tox==3.14.1 -flake8==3.7.9 +twine==3.1.1 +volatile==2.1.0 +wheel==0.33.6 diff --git a/templates/requirements-dev.txt.in b/templates/requirements-dev.txt.in index 3215afb..0479c95 100644 --- a/templates/requirements-dev.txt.in +++ b/templates/requirements-dev.txt.in @@ -1,6 +1,9 @@ +black==19.10b0 coverage==4.5.4 +flake8==3.7.9 isort==4.3.21 -black==19.10b0 +mypy==0.750 tox==3.14.1 -flake8==3.7.9 -mypy==0.740 +twine==3.1.1 +volatile==2.1.0 +wheel==0.33.6 From 855d02ddb69ee7db43025c271a3f24101140ce7a Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Thu, 12 Mar 2020 20:19:38 -0700 Subject: [PATCH 03/47] With the default of py3.6+, don't specify universal. This causes py2.py3 wheels to be created, which is confusing for a project that doesn't support py2. --- templates/setup.cfg.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 8516a43..602ebe9 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -15,9 +15,6 @@ setup_requires = setuptools >= 38.3.0 python_requires = >=3.6 -[bdist_wheel] -universal = true - [check] metadata = true strict = true From ff8d3b9787488110e92b26fb94f2c0f6f31ceeda Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Thu, 12 Mar 2020 20:20:23 -0700 Subject: [PATCH 04/47] Move setup_requires to pyproject.toml --- templates/pyproject.toml.in | 2 ++ templates/setup.cfg.in | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 templates/pyproject.toml.in diff --git a/templates/pyproject.toml.in b/templates/pyproject.toml.in new file mode 100644 index 0000000..2754782 --- /dev/null +++ b/templates/pyproject.toml.in @@ -0,0 +1,2 @@ +[build-system] +requires = ["setuptools_scm", "setuptools >= 43.0.0", "wheel"] diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 602ebe9..1bd81d2 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -10,9 +10,6 @@ author_email = {author_email} [options] packages = {package} -setup_requires = - setuptools_scm - setuptools >= 38.3.0 python_requires = >=3.6 [check] From 45a0bb4aafb6ee6d0c1dcac578f34626734eb9aa Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 13 Mar 2020 06:42:31 -0700 Subject: [PATCH 05/47] Revert "Move setup_requires to pyproject.toml" This reverts commit ff8d3b9787488110e92b26fb94f2c0f6f31ceeda. --- templates/pyproject.toml.in | 2 -- templates/setup.cfg.in | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 templates/pyproject.toml.in diff --git a/templates/pyproject.toml.in b/templates/pyproject.toml.in deleted file mode 100644 index 2754782..0000000 --- a/templates/pyproject.toml.in +++ /dev/null @@ -1,2 +0,0 @@ -[build-system] -requires = ["setuptools_scm", "setuptools >= 43.0.0", "wheel"] diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 1bd81d2..602ebe9 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -10,6 +10,9 @@ author_email = {author_email} [options] packages = {package} +setup_requires = + setuptools_scm + setuptools >= 38.3.0 python_requires = >=3.6 [check] From a8ec290d35b71340971353bf3caa02dbc69dbabd Mon Sep 17 00:00:00 2001 From: Mark Rofail Date: Sun, 18 Oct 2020 08:47:38 +0200 Subject: [PATCH 06/47] [feat] add support to {var} in filepaths --- regen.py | 70 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/regen.py b/regen.py index 9b5331e..94d7169 100755 --- a/regen.py +++ b/regen.py @@ -4,12 +4,11 @@ # out. import configparser -import os import re from pathlib import Path from typing import Match -THIS_DIR = Path(os.path.abspath(__file__)).parent +THIS_DIR = Path(__file__).absolute().parent TEMPLATE_DIR = THIS_DIR / "templates" # This is very simplistic... @@ -34,6 +33,13 @@ def replace(match: Match[str]) -> str: return VARIABLE_RE.sub(replace, tmpl) +def is_template_file(filepath: Path) -> bool: + return ( + filepath.suffix == 'in' + or filepath.name == '__init__.py' + ) + + def main() -> None: # In case we've answered anything before, attempt load. parser = configparser.RawConfigParser() @@ -41,33 +47,39 @@ def main() -> None: if "vars" not in parser: parser.add_section("vars") - for dirpath, dirnames, filenames in os.walk(TEMPLATE_DIR): - for fn in filenames: - if fn.endswith(".in"): - template_path = Path(dirpath) / fn - local_path = (Path(dirpath) / fn[:-3]).relative_to(TEMPLATE_DIR) - with template_path.open("r") as f: - data = f.read() - variables = VARIABLE_RE.findall(data) - for v in variables: - if v not in parser["vars"]: - parser["vars"][v] = input(f"Value for {v}? ").strip() - with open(VARS_FILENAME, "w") as f: - parser.write(f) - - interpolated_data = variable_format(data, **parser["vars"]) - - if local_path.exists(): - with local_path.open("r") as f: - existing_data = f.read() - if existing_data == interpolated_data: - print(f"Unchanged {local_path}") - continue - - print(f"Writing {local_path}") - local_path.parent.mkdir(parents=True, exist_ok=True) - with local_path.open("w") as f: - f.write(interpolated_data) + for template_path in TEMPLATE_DIR.glob('**/*'): + dirpath = template_path.parent + + if is_template_file(template_path): + with template_path.open("r") as f: + data = f.read() + + variables = list() + variables.extend(VARIABLE_RE.findall(data)) + variables.extend(VARIABLE_RE.findall(str(template_path))) + + for v in variables: + if v not in parser["vars"]: + parser["vars"][v] = input(f"Value for {v}? ").strip() + with open(VARS_FILENAME, "w") as f: + parser.write(f) + + interpolated_data = variable_format(data, **parser["vars"]) + + local_path = (dirpath / template_path.with_suffix('')).relative_to(TEMPLATE_DIR) + local_path = Path(variable_format(str(local_path), **parser["vars"])) + + if local_path.exists(): + with local_path.open("r") as f: + existing_data = f.read() + if existing_data == interpolated_data: + print(f"Unchanged {local_path}") + continue + + print(f"Writing {local_path}") + local_path.parent.mkdir(parents=True, exist_ok=True) + with local_path.open("w") as f: + f.write(interpolated_data) if __name__ == "__main__": From 7cc9add2c214f226fc7eb1499e66895d84793b0d Mon Sep 17 00:00:00 2001 From: Mark Rofail Date: Sun, 18 Oct 2020 18:36:59 +0200 Subject: [PATCH 07/47] [fix] apply more pathlib modernization [fix] remove redundant code --- regen.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/regen.py b/regen.py index 94d7169..c64cdfd 100755 --- a/regen.py +++ b/regen.py @@ -33,13 +33,6 @@ def replace(match: Match[str]) -> str: return VARIABLE_RE.sub(replace, tmpl) -def is_template_file(filepath: Path) -> bool: - return ( - filepath.suffix == 'in' - or filepath.name == '__init__.py' - ) - - def main() -> None: # In case we've answered anything before, attempt load. parser = configparser.RawConfigParser() @@ -48,13 +41,10 @@ def main() -> None: parser.add_section("vars") for template_path in TEMPLATE_DIR.glob('**/*'): - dirpath = template_path.parent - - if is_template_file(template_path): - with template_path.open("r") as f: - data = f.read() + if template_path.suffix == '.in': + data = template_path.read_text() - variables = list() + variables = [] variables.extend(VARIABLE_RE.findall(data)) variables.extend(VARIABLE_RE.findall(str(template_path))) @@ -66,20 +56,18 @@ def main() -> None: interpolated_data = variable_format(data, **parser["vars"]) - local_path = (dirpath / template_path.with_suffix('')).relative_to(TEMPLATE_DIR) + local_path = template_path.with_suffix('').relative_to(TEMPLATE_DIR) local_path = Path(variable_format(str(local_path), **parser["vars"])) if local_path.exists(): - with local_path.open("r") as f: - existing_data = f.read() + existing_data = local_path.read_text() if existing_data == interpolated_data: print(f"Unchanged {local_path}") continue print(f"Writing {local_path}") local_path.parent.mkdir(parents=True, exist_ok=True) - with local_path.open("w") as f: - f.write(interpolated_data) + local_path.write_text(interpolated_data) if __name__ == "__main__": From 33961607ef360af92bf7e2d675446e5de04aac5d Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Thu, 29 Oct 2020 08:21:55 -0700 Subject: [PATCH 08/47] Run on more branches, and for py3.9 Based largely on https://github.com/omnilib/attribution/pull/15/ Fixes #8 --- templates/.github/workflows/build.yml.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/.github/workflows/build.yml.in b/templates/.github/workflows/build.yml.in index ccf082a..b4b097b 100644 --- a/templates/.github/workflows/build.yml.in +++ b/templates/.github/workflows/build.yml.in @@ -3,6 +3,8 @@ on: push: branches: - master + - main + - tmp-* tags: - v* pull_request: @@ -13,14 +15,14 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.6, 3.7, 3.8] + python-version: ["3.6", "3.7", "3.8", "3.9"] os: [macOS-latest, ubuntu-latest, windows-latest] steps: - name: Checkout uses: actions/checkout@v1 - name: Set Up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install @@ -32,6 +34,7 @@ jobs: run: make test - name: Lint run: make lint + if: ${{ matrix.python-version != '3.9' }} - name: Coverage run: codecov --token ${{ secrets.CODECOV_TOKEN }} --branch ${{ github.ref }} continue-on-error: true From 384c24f9459986cc680f8f80122c3978193e1904 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Thu, 1 Apr 2021 07:14:37 -0700 Subject: [PATCH 09/47] Switch to using ufmt This is extracted from https://github.com/thatch/moreorless/commit/4a9f62016b753ba1b72eeb9e8cb215699e1264ee --- templates/Makefile.in | 6 ++---- templates/requirements-dev.txt.in | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/templates/Makefile.in b/templates/Makefile.in index 54c8e65..783d913 100644 --- a/templates/Makefile.in +++ b/templates/Makefile.in @@ -21,13 +21,11 @@ test: .PHONY: format format: - python -m isort --recursive -y $(SOURCES) - python -m black $(SOURCES) + python -m ufmt format $(SOURCES) .PHONY: lint lint: - python -m isort --recursive --diff $(SOURCES) - python -m black --check $(SOURCES) + python -m ufmt check $(SOURCES) python -m flake8 $(SOURCES) mypy --strict {package} diff --git a/templates/requirements-dev.txt.in b/templates/requirements-dev.txt.in index 0479c95..b5f7505 100644 --- a/templates/requirements-dev.txt.in +++ b/templates/requirements-dev.txt.in @@ -1,9 +1,10 @@ -black==19.10b0 +black==20.8b1 coverage==4.5.4 flake8==3.7.9 -isort==4.3.21 mypy==0.750 tox==3.14.1 twine==3.1.1 +ufmt==1.1 +usort==0.6.3 volatile==2.1.0 wheel==0.33.6 From 00cf53767dea9ba6d178f4ed7d1db2da0fc6bd71 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Tue, 8 Nov 2022 09:41:17 -0800 Subject: [PATCH 10/47] Update for modern python versions - Run CI on 3.7-3.10 - Run lint on 3.9 (this was disabled because typeguard or mypy didn't work on it ~2 years ago) - Add checkdeps --- templates/.github/workflows/build.yml.in | 6 +----- templates/Makefile.in | 1 + templates/requirements-dev.txt.in | 19 ++++++++++--------- templates/setup.cfg.in | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/templates/.github/workflows/build.yml.in b/templates/.github/workflows/build.yml.in index b4b097b..a7e25b9 100644 --- a/templates/.github/workflows/build.yml.in +++ b/templates/.github/workflows/build.yml.in @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.6", "3.7", "3.8", "3.9"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] os: [macOS-latest, ubuntu-latest, windows-latest] steps: @@ -34,7 +34,3 @@ jobs: run: make test - name: Lint run: make lint - if: ${{ matrix.python-version != '3.9' }} - - name: Coverage - run: codecov --token ${{ secrets.CODECOV_TOKEN }} --branch ${{ github.ref }} - continue-on-error: true diff --git a/templates/Makefile.in b/templates/Makefile.in index 783d913..5ea6ba7 100644 --- a/templates/Makefile.in +++ b/templates/Makefile.in @@ -27,6 +27,7 @@ format: lint: python -m ufmt check $(SOURCES) python -m flake8 $(SOURCES) + python -m checkdeps --allow-names {package} {package} mypy --strict {package} .PHONY: release diff --git a/templates/requirements-dev.txt.in b/templates/requirements-dev.txt.in index b5f7505..714f996 100644 --- a/templates/requirements-dev.txt.in +++ b/templates/requirements-dev.txt.in @@ -1,10 +1,11 @@ -black==20.8b1 -coverage==4.5.4 -flake8==3.7.9 -mypy==0.750 -tox==3.14.1 -twine==3.1.1 -ufmt==1.1 -usort==0.6.3 +black==22.6.0 +checkdeps==0.0.2 +coverage==6.4.3 +flake8==5.0.4 +mypy==0.971 +tox==3.25.1 +twine==4.0.1 +ufmt==2.0.0 +usort==1.0.4 volatile==2.1.0 -wheel==0.33.6 +wheel==0.37.1 diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 602ebe9..ea2d418 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -13,7 +13,7 @@ packages = {package} setup_requires = setuptools_scm setuptools >= 38.3.0 -python_requires = >=3.6 +python_requires = >=3.7 [check] metadata = true From 8c3c562b5fc566eb6a0143005e2d1d84d7290a44 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Wed, 1 Nov 2023 04:50:48 -0700 Subject: [PATCH 11/47] Upgrade versions, target 3.7+ Don't yet include 3.12 in actions because checkdeps->stdlibs doesn't yet support it. --- templates/.github/workflows/build.yml.in | 4 ++-- templates/requirements-dev.txt.in | 18 +++++++++--------- templates/setup.cfg.in | 11 ++--------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/templates/.github/workflows/build.yml.in b/templates/.github/workflows/build.yml.in index a7e25b9..d268461 100644 --- a/templates/.github/workflows/build.yml.in +++ b/templates/.github/workflows/build.yml.in @@ -20,9 +20,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Set Up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install diff --git a/templates/requirements-dev.txt.in b/templates/requirements-dev.txt.in index 714f996..ea9aedf 100644 --- a/templates/requirements-dev.txt.in +++ b/templates/requirements-dev.txt.in @@ -1,11 +1,11 @@ -black==22.6.0 +black==23.10.1 checkdeps==0.0.2 -coverage==6.4.3 -flake8==5.0.4 -mypy==0.971 -tox==3.25.1 -twine==4.0.1 -ufmt==2.0.0 -usort==1.0.4 +coverage==7.3.2 +flake8==6.1.0 +mypy==1.6.1 +tox==4.11.3 +twine==4.0.2 +ufmt==2.3.0 +usort==1.0.7 volatile==2.1.0 -wheel==0.37.1 +wheel==0.41.3 diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index ea2d418..85efbcf 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -30,18 +30,11 @@ precision = 1 show_missing = True skip_covered = True -[isort] -line_length = 88 -multi_line_output = 3 -force_grid_wrap = False -include_trailing_comma = True -use_parentheses = True - [mypy] ignore_missing_imports = True [tox:tox] -envlist = py36, py37, py38 +envlist = py37, py38, py39, py310, py311 [testenv] deps = -rrequirements-dev.txt @@ -49,7 +42,7 @@ whitelist_externals = make commands = make test setenv = - py{36,37,38}: COVERAGE_FILE={envdir}/.coverage + py{37,38,39,310,311}: COVERAGE_FILE={envdir}/.coverage [flake8] ignore = E203, E231, E266, E302, E501, W503 From 1d48b4a506ca2033633469fcd708020600e71626 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Thu, 18 Jan 2024 17:23:07 -0800 Subject: [PATCH 12/47] Sync with 3.7+ code --- templates/requirements-dev.txt.in | 2 +- templates/setup.cfg.in | 1 + templates/setup.py.in | 1 + templates/{package}/__init__.py.in | 0 templates/{package}/py.typed.in | 0 templates/{package}/tests/__init__.py.in | 5 +++++ templates/{package}/tests/__main__.py.in | 4 ++++ test_skel.py | 14 ++++++++++++++ 8 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 templates/{package}/__init__.py.in create mode 100644 templates/{package}/py.typed.in create mode 100644 templates/{package}/tests/__init__.py.in create mode 100644 templates/{package}/tests/__main__.py.in create mode 100644 test_skel.py diff --git a/templates/requirements-dev.txt.in b/templates/requirements-dev.txt.in index ea9aedf..027ccab 100644 --- a/templates/requirements-dev.txt.in +++ b/templates/requirements-dev.txt.in @@ -1,4 +1,4 @@ -black==23.10.1 +black==23.3.0 # last version to support 3.7 checkdeps==0.0.2 coverage==7.3.2 flake8==6.1.0 diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 85efbcf..a428edd 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -14,6 +14,7 @@ setup_requires = setuptools_scm setuptools >= 38.3.0 python_requires = >=3.7 +include_package_data = true [check] metadata = true diff --git a/templates/setup.py.in b/templates/setup.py.in index 460aabe..d5d43d7 100644 --- a/templates/setup.py.in +++ b/templates/setup.py.in @@ -1,2 +1,3 @@ from setuptools import setup + setup(use_scm_version=True) diff --git a/templates/{package}/__init__.py.in b/templates/{package}/__init__.py.in new file mode 100644 index 0000000..e69de29 diff --git a/templates/{package}/py.typed.in b/templates/{package}/py.typed.in new file mode 100644 index 0000000..e69de29 diff --git a/templates/{package}/tests/__init__.py.in b/templates/{package}/tests/__init__.py.in new file mode 100644 index 0000000..67742dd --- /dev/null +++ b/templates/{package}/tests/__init__.py.in @@ -0,0 +1,5 @@ +# from .foo import FooTest + +__all__ = [ + # FooTest, +] diff --git a/templates/{package}/tests/__main__.py.in b/templates/{package}/tests/__main__.py.in new file mode 100644 index 0000000..e40763e --- /dev/null +++ b/templates/{package}/tests/__main__.py.in @@ -0,0 +1,4 @@ +import unittest + +if __name__ == "__main__": + unittest.main(module="{package}.tests", verbosity=2) diff --git a/test_skel.py b/test_skel.py new file mode 100644 index 0000000..b2b7c7e --- /dev/null +++ b/test_skel.py @@ -0,0 +1,14 @@ +import unittest +import regen + +class RegenTest(unittest.TestCase): + def test_variable_format(self): + self.assertEqual("1", regen.variable_format("{foo}", foo="1")) + self.assertEqual("{foo}", regen.variable_format("{foo}")) + self.assertEqual("{ foo }", regen.variable_format("{ foo }", foo="1")) + self.assertEqual("{{foo}}", regen.variable_format("{{foo}}", foo="1")) + with self.assertRaises(TypeError): + self.assertEqual("1", regen.variable_format("{foo}", foo=1, bar=2)) + +if __name__ == "__main__": + unittest.main() From 66cb3f0d53964baf641d259d45b6f0339287e8d8 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 19 Jan 2024 12:58:42 -0800 Subject: [PATCH 13/47] Standardize on 3.10-3.12 Dev-compatibility with a wide range of versions is getting increasingly hard (and in particular, linting only works on 3.12 due to ast changes). You can still (probably) test and publish on older versions, but for my projects this is diminishing returns and the sort of thing I'd need to ponder on an individual basis. usort needs LibCST to work on 3.13, and it looks like there's a rust issue fixed in git so it's just waiting on a release > 1.1.0. --- templates/.github/workflows/build.yml.in | 4 +-- templates/Makefile.in | 2 +- templates/requirements-dev.txt.in | 11 -------- templates/setup.cfg.in | 35 ++++++++++++++++++++---- 4 files changed, 32 insertions(+), 20 deletions(-) delete mode 100644 templates/requirements-dev.txt.in diff --git a/templates/.github/workflows/build.yml.in b/templates/.github/workflows/build.yml.in index d268461..a249fbb 100644 --- a/templates/.github/workflows/build.yml.in +++ b/templates/.github/workflows/build.yml.in @@ -15,14 +15,14 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12"] os: [macOS-latest, ubuntu-latest, windows-latest] steps: - name: Checkout uses: actions/checkout@v4 - name: Set Up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install diff --git a/templates/Makefile.in b/templates/Makefile.in index 5ea6ba7..08129ca 100644 --- a/templates/Makefile.in +++ b/templates/Makefile.in @@ -12,7 +12,7 @@ venv: .PHONY: setup setup: - python -m pip install -Ur requirements-dev.txt + python -m pip install -Ue .[dev,test] .PHONY: test test: diff --git a/templates/requirements-dev.txt.in b/templates/requirements-dev.txt.in deleted file mode 100644 index 027ccab..0000000 --- a/templates/requirements-dev.txt.in +++ /dev/null @@ -1,11 +0,0 @@ -black==23.3.0 # last version to support 3.7 -checkdeps==0.0.2 -coverage==7.3.2 -flake8==6.1.0 -mypy==1.6.1 -tox==4.11.3 -twine==4.0.2 -ufmt==2.3.0 -usort==1.0.7 -volatile==2.1.0 -wheel==0.41.3 diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index a428edd..9c53b02 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -11,11 +11,24 @@ author_email = {author_email} [options] packages = {package} setup_requires = - setuptools_scm - setuptools >= 38.3.0 -python_requires = >=3.7 + setuptools_scm >= 8 + setuptools >= 65 +python_requires = >=3.10 include_package_data = true +[options.extras_require] +dev = + black == 23.12.1 + checkdeps == 0.0.2 + flake8 == 7.0.0 + tox == 4.12.1 + twine == 4.0.2 + ufmt == 2.3.0 + usort == 1.0.7 + wheel == 0.42.0 +test = + coverage >= 6 + [check] metadata = true strict = true @@ -35,15 +48,25 @@ skip_covered = True ignore_missing_imports = True [tox:tox] -envlist = py37, py38, py39, py310, py311 +envlist = py{310,311,312}, coverage [testenv] deps = -rrequirements-dev.txt -whitelist_externals = make +allowlist_externals = make commands = make test setenv = - py{37,38,39,310,311}: COVERAGE_FILE={envdir}/.coverage + COVERAGE_FILE={toxworkdir}/.coverage.{envname} + +[testenv:coverage] +deps = coverage +setenv = + COVERAGE_FILE={toxworkdir}/.coverage +commands = + coverage combine + coverage report +depends = + py{310,311,312} [flake8] ignore = E203, E231, E266, E302, E501, W503 From 30850298ee5cda0583bc72e2b5c5d8aa52e8d950 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 19 Jan 2024 13:06:11 -0800 Subject: [PATCH 14/47] Add a simple way to escape interpolations --- regen.py | 9 +++++++-- templates/setup.cfg.in | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/regen.py b/regen.py index c64cdfd..79d26b1 100755 --- a/regen.py +++ b/regen.py @@ -12,7 +12,7 @@ TEMPLATE_DIR = THIS_DIR / "templates" # This is very simplistic... -VARIABLE_RE = re.compile(r"(? str: This means that '{ foo }' is not an interpolation, nor is '{{foo}}', but we also don't get '!r' suffix for free. Maybe someday. + + Non-interpolations can be written '{@foo}' which becomes '{foo}' when + rendered. """ def replace(match: Match[str]) -> str: g = match.group(1) + if g[:1] == "@": + return match.group(0).replace("@", "", 1) if g in kwargs: return kwargs[g] return match.group(0) @@ -49,7 +54,7 @@ def main() -> None: variables.extend(VARIABLE_RE.findall(str(template_path))) for v in variables: - if v not in parser["vars"]: + if v[:1] != '@' and v not in parser["vars"]: parser["vars"][v] = input(f"Value for {v}? ").strip() with open(VARS_FILENAME, "w") as f: parser.write(f) diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 9c53b02..aa6010c 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -48,7 +48,7 @@ skip_covered = True ignore_missing_imports = True [tox:tox] -envlist = py{310,311,312}, coverage +envlist = py{@310,311,312}, coverage [testenv] deps = -rrequirements-dev.txt @@ -56,17 +56,17 @@ allowlist_externals = make commands = make test setenv = - COVERAGE_FILE={toxworkdir}/.coverage.{envname} + COVERAGE_FILE={@toxworkdir}/.coverage.{@envname} [testenv:coverage] deps = coverage setenv = - COVERAGE_FILE={toxworkdir}/.coverage + COVERAGE_FILE={@toxworkdir}/.coverage commands = coverage combine coverage report depends = - py{310,311,312} + py{@310,311,312} [flake8] ignore = E203, E231, E266, E302, E501, W503 From 8a09ee6fbdfe69def654d49aa0f3f5962e51a711 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 19 Jan 2024 14:34:02 -0800 Subject: [PATCH 15/47] Ignore all venv dirs, locate .[dev] reqs in tox --- templates/.gitignore.in | 2 +- templates/setup.cfg.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/.gitignore.in b/templates/.gitignore.in index d431df9..0a4bafc 100644 --- a/templates/.gitignore.in +++ b/templates/.gitignore.in @@ -83,7 +83,7 @@ celerybeat-schedule # Environments .env -.venv +.venv* env/ venv/ ENV/ diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index aa6010c..8d306ad 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -51,7 +51,7 @@ ignore_missing_imports = True envlist = py{@310,311,312}, coverage [testenv] -deps = -rrequirements-dev.txt +deps = .[dev] allowlist_externals = make commands = make test From c8c045473daca52214ca90205209f3b711780355 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 19 Jan 2024 14:44:24 -0800 Subject: [PATCH 16/47] Better mypy config --- templates/Makefile.in | 2 +- templates/setup.cfg.in | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/Makefile.in b/templates/Makefile.in index 08129ca..21059d8 100644 --- a/templates/Makefile.in +++ b/templates/Makefile.in @@ -28,7 +28,7 @@ lint: python -m ufmt check $(SOURCES) python -m flake8 $(SOURCES) python -m checkdeps --allow-names {package} {package} - mypy --strict {package} + mypy --strict --non-interactive {package} .PHONY: release release: diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 8d306ad..ce54a85 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -46,6 +46,7 @@ skip_covered = True [mypy] ignore_missing_imports = True +install_types = True [tox:tox] envlist = py{@310,311,312}, coverage From f38f9c4e65a5ba164e25686badcee386f87b56bb Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 19 Jan 2024 14:45:19 -0800 Subject: [PATCH 17/47] Only need .[test] for tox --- templates/setup.cfg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index ce54a85..4ee4ecc 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -52,7 +52,7 @@ install_types = True envlist = py{@310,311,312}, coverage [testenv] -deps = .[dev] +deps = .[test] allowlist_externals = make commands = make test From 6724d4c4ad126b4dff6d83d188f8d8e70dccff32 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 19 Jan 2024 20:35:10 -0800 Subject: [PATCH 18/47] Add mypy to deps --- templates/setup.cfg.in | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 4ee4ecc..122434e 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -21,6 +21,7 @@ dev = black == 23.12.1 checkdeps == 0.0.2 flake8 == 7.0.0 + mypy == 1.8.0 tox == 4.12.1 twine == 4.0.2 ufmt == 2.3.0 From 9f7d9ec7f5c865f204b2342bf0fceecf6251fcfe Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 19 Jan 2024 20:43:42 -0800 Subject: [PATCH 19/47] Include skel revision in commit message --- regen-git.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/regen-git.py b/regen-git.py index d552c23..1f73893 100755 --- a/regen-git.py +++ b/regen-git.py @@ -32,6 +32,12 @@ def find_git_dir(path: Optional[Path] = None) -> Path: def main(): + skel_rev = subprocess.check_output( + ["git", "describe", "--always", "--dirty"], + cwd=os.path.dirname(__file__), + encoding="utf-8", + ).strip() + git_branches = subprocess.check_output( ["git", "branch", "-a"], encoding="utf-8" ).splitlines(False) @@ -72,7 +78,7 @@ def main(): regen.main() subprocess.check_call(["git", "add", "-A"]) try: - subprocess.check_call(["git", "commit", "-m", "Initialize skel"]) + subprocess.check_call(["git", "commit", "-m", f"Initialize skel\n\nrev: {skel_rev}"]) except subprocess.CalledProcessError as e: print("\x1b[33mNo changes?\x1b[0m") raise @@ -95,7 +101,7 @@ def main(): date = datetime.datetime.now().strftime("%Y-%m-%d") try: - subprocess.check_call(["git", "commit", "-m", f"Update skel {date}"]) + subprocess.check_call(["git", "commit", "-m", f"Update skel {date}\n\nrev: {skel_rev}"]) except subprocess.CalledProcessError as e: print("\x1b[33mNo changes?\x1b[0m") return From e254aa01a3a32fffd8879efcf3d4f5fb93cb7d36 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 19 Jan 2024 21:08:40 -0800 Subject: [PATCH 20/47] Trivial fix to commented-out test __all__ --- templates/{package}/tests/__init__.py.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/{package}/tests/__init__.py.in b/templates/{package}/tests/__init__.py.in index 67742dd..ff2b359 100644 --- a/templates/{package}/tests/__init__.py.in +++ b/templates/{package}/tests/__init__.py.in @@ -1,5 +1,5 @@ # from .foo import FooTest __all__ = [ - # FooTest, + # "FooTest", ] From 31a61de46317712ef6327bbf7f26e4f5edc83a0e Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Mon, 22 Jan 2024 09:15:37 -0800 Subject: [PATCH 21/47] mypy --install-types can't be configured? --- templates/Makefile.in | 2 +- templates/setup.cfg.in | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/templates/Makefile.in b/templates/Makefile.in index 21059d8..c5d6a20 100644 --- a/templates/Makefile.in +++ b/templates/Makefile.in @@ -28,7 +28,7 @@ lint: python -m ufmt check $(SOURCES) python -m flake8 $(SOURCES) python -m checkdeps --allow-names {package} {package} - mypy --strict --non-interactive {package} + mypy --strict --install-types --non-interactive {package} .PHONY: release release: diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 122434e..542991a 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -47,7 +47,6 @@ skip_covered = True [mypy] ignore_missing_imports = True -install_types = True [tox:tox] envlist = py{@310,311,312}, coverage From 8b26f3ab3eceb2e95403c702ae637d5892d20171 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Mon, 22 Jan 2024 10:32:35 -0800 Subject: [PATCH 22/47] Add examples for install_requires and console_scripts --- templates/setup.cfg.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 542991a..a8c8571 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -15,6 +15,7 @@ setup_requires = setuptools >= 65 python_requires = >=3.10 include_package_data = true +install_requires = [options.extras_require] dev = @@ -30,6 +31,10 @@ dev = test = coverage >= 6 +[options.entry_points] +# console_scripts = +# foo=foo:bar + [check] metadata = true strict = true From 207b13b7aa68fff40d08168147ecb580e7979f21 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Mon, 22 Jan 2024 10:32:48 -0800 Subject: [PATCH 23/47] Use new checkdeps that understands metadata --- templates/setup.cfg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index a8c8571..2672c6c 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -20,7 +20,7 @@ install_requires = [options.extras_require] dev = black == 23.12.1 - checkdeps == 0.0.2 + checkdeps == 0.9.0 flake8 == 7.0.0 mypy == 1.8.0 tox == 4.12.1 From 286c10311bee454c427f9834855d600dcef0e092 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Tue, 23 Jan 2024 17:51:29 -0800 Subject: [PATCH 24/47] Just give up and use find: This wasn't including tests, and I just now noticed. --- templates/setup.cfg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 2672c6c..de56f40 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -9,7 +9,7 @@ author = {author} author_email = {author_email} [options] -packages = {package} +packages = find: setup_requires = setuptools_scm >= 8 setuptools >= 65 From 86bc977d99d82a4e710dd991fd02742bda5a9e92 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Tue, 13 Feb 2024 17:32:14 -0800 Subject: [PATCH 25/47] Attempt to test on 3.7-3.12 (3.13 on GHA) --- templates/.github/workflows/build.yml.in | 26 ++++++++++++++++++++++++ templates/README.md.in | 4 ++++ templates/setup.cfg.in | 9 ++++---- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/templates/.github/workflows/build.yml.in b/templates/.github/workflows/build.yml.in index a249fbb..e6c86c7 100644 --- a/templates/.github/workflows/build.yml.in +++ b/templates/.github/workflows/build.yml.in @@ -10,6 +10,32 @@ on: pull_request: jobs: + {package}-just-tests: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + os: [macOS-latest, ubuntu-latest, windows-latest] + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set Up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + allow-prereleases: true + - name: Install + run: | + python -m pip install --upgrade pip + make setup + pip install -U . + - name: Test + run: make test + - name: Lint + run: make lint + {package}: runs-on: ${{ matrix.os }} strategy: diff --git a/templates/README.md.in b/templates/README.md.in index 132fecf..b6f3699 100644 --- a/templates/README.md.in +++ b/templates/README.md.in @@ -1,6 +1,10 @@ # {package_name} +# Version Compat + +Usage of this library should work back to 3.7, but development (and mypy +compatibility) only on 3.10-3.12. Linting requires 3.12 for full fidelity. # License diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index de56f40..9e1b8e8 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -10,10 +10,11 @@ author_email = {author_email} [options] packages = find: +python_requires = >=3.7 setup_requires = - setuptools_scm >= 8 + setuptools_scm < 8; python_version<'3.8' + setuptools_scm >= 8; python_version>='3.8' setuptools >= 65 -python_requires = >=3.10 include_package_data = true install_requires = @@ -54,7 +55,7 @@ skip_covered = True ignore_missing_imports = True [tox:tox] -envlist = py{@310,311,312}, coverage +envlist = py{@37,38,39,310,311,312}, coverage [testenv] deps = .[test] @@ -72,7 +73,7 @@ commands = coverage combine coverage report depends = - py{@310,311,312} + py{@37,38,39,310,311,312} [flake8] ignore = E203, E231, E266, E302, E501, W503 From 817e4cc1ccab0a7fec7b79a94c6b6e8befb2314b Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Mon, 26 Feb 2024 08:47:43 -0800 Subject: [PATCH 26/47] Include version block in default init tmpl --- templates/{package}/__init__.py.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/{package}/__init__.py.in b/templates/{package}/__init__.py.in index e69de29..da9f1c2 100644 --- a/templates/{package}/__init__.py.in +++ b/templates/{package}/__init__.py.in @@ -0,0 +1,4 @@ +try: + from .version import __version__ +except ImportError: + __version__ = "dev" From 33c7e50386a40887f1cb36a5582147cadcab1fc8 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 1 Mar 2024 06:58:20 -0800 Subject: [PATCH 27/47] Fix just-tests, versioning, and license note --- templates/.github/workflows/build.yml.in | 6 ++---- templates/README.md.in | 14 +++++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/templates/.github/workflows/build.yml.in b/templates/.github/workflows/build.yml.in index e6c86c7..bcc44eb 100644 --- a/templates/.github/workflows/build.yml.in +++ b/templates/.github/workflows/build.yml.in @@ -30,11 +30,9 @@ jobs: run: | python -m pip install --upgrade pip make setup - pip install -U . + pip install -U .[test] - name: Test - run: make test - - name: Lint - run: make lint + run: python -m unittest {package}.tests {package}: runs-on: ${{ matrix.os }} diff --git a/templates/README.md.in b/templates/README.md.in index b6f3699..5a9fcd3 100644 --- a/templates/README.md.in +++ b/templates/README.md.in @@ -1,4 +1,4 @@ -# {package_name} +# {pypi_name} # Version Compat @@ -6,9 +6,13 @@ Usage of this library should work back to 3.7, but development (and mypy compatibility) only on 3.10-3.12. Linting requires 3.12 for full fidelity. +# Versioning + +This library follows [meanver](https://meanver.org/) which basically means +[semver](https://semver.org/) along with a promise to rename when the major +version changes. + # License -{package_name} is copyright [{author}]({author_website}), and licensed under -the MIT license. I am providing code in this repository to you under an open -source license. This is my personal repository; the license you receive to -my code is from me and not from my employer. See the `LICENSE` file for details. +{pypi_name} is copyright [{author}]({author_website}), and licensed under +the MIT license. See the `LICENSE` file for details. From ae3e410ed762435d7756b898d2e56f8a879afab2 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 1 Mar 2024 07:06:14 -0800 Subject: [PATCH 28/47] fix skel itself to be more modern (isort/black->ufmt) --- Makefile | 10 ++++++---- regen-git.py | 8 ++++++-- regen.py | 8 ++++---- requirements-dev.txt | 17 +++++++++-------- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 5787634..ecebb3c 100644 --- a/Makefile +++ b/Makefile @@ -16,12 +16,14 @@ setup: .PHONY: format format: - python -m isort --recursive -y $(SOURCES) - python -m black $(SOURCES) + python -m ufmt format $(SOURCES) .PHONY: lint lint: - python -m isort --recursive --diff $(SOURCES) - python -m black --check $(SOURCES) + python -m ufmt check $(SOURCES) python -m flake8 $(SOURCES) mypy --strict regen.py + +.PHONY: checkdeps +checkdeps: + python -m checkdeps . --allow-names regen diff --git a/regen-git.py b/regen-git.py index 1f73893..49b84a4 100755 --- a/regen-git.py +++ b/regen-git.py @@ -78,7 +78,9 @@ def main(): regen.main() subprocess.check_call(["git", "add", "-A"]) try: - subprocess.check_call(["git", "commit", "-m", f"Initialize skel\n\nrev: {skel_rev}"]) + subprocess.check_call( + ["git", "commit", "-m", f"Initialize skel\n\nrev: {skel_rev}"] + ) except subprocess.CalledProcessError as e: print("\x1b[33mNo changes?\x1b[0m") raise @@ -101,7 +103,9 @@ def main(): date = datetime.datetime.now().strftime("%Y-%m-%d") try: - subprocess.check_call(["git", "commit", "-m", f"Update skel {date}\n\nrev: {skel_rev}"]) + subprocess.check_call( + ["git", "commit", "-m", f"Update skel {date}\n\nrev: {skel_rev}"] + ) except subprocess.CalledProcessError as e: print("\x1b[33mNo changes?\x1b[0m") return diff --git a/regen.py b/regen.py index 79d26b1..fdf0631 100755 --- a/regen.py +++ b/regen.py @@ -45,8 +45,8 @@ def main() -> None: if "vars" not in parser: parser.add_section("vars") - for template_path in TEMPLATE_DIR.glob('**/*'): - if template_path.suffix == '.in': + for template_path in TEMPLATE_DIR.glob("**/*"): + if template_path.suffix == ".in": data = template_path.read_text() variables = [] @@ -54,14 +54,14 @@ def main() -> None: variables.extend(VARIABLE_RE.findall(str(template_path))) for v in variables: - if v[:1] != '@' and v not in parser["vars"]: + if v[:1] != "@" and v not in parser["vars"]: parser["vars"][v] = input(f"Value for {v}? ").strip() with open(VARS_FILENAME, "w") as f: parser.write(f) interpolated_data = variable_format(data, **parser["vars"]) - local_path = template_path.with_suffix('').relative_to(TEMPLATE_DIR) + local_path = template_path.with_suffix("").relative_to(TEMPLATE_DIR) local_path = Path(variable_format(str(local_path), **parser["vars"])) if local_path.exists(): diff --git a/requirements-dev.txt b/requirements-dev.txt index 0479c95..54f7c91 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,9 +1,10 @@ -black==19.10b0 -coverage==4.5.4 -flake8==3.7.9 -isort==4.3.21 -mypy==0.750 -tox==3.14.1 -twine==3.1.1 +ufmt==2.5.1 +black==24.2.0 +usort==1.0.8.post1 +coverage==7.4.3 +flake8==7.0.0 +mypy==1.8.0 +tox==4.13.0 +twine==5.0.0 volatile==2.1.0 -wheel==0.33.6 +wheel==0.42.0 From 7d9d762c8fb5095fa40f4c1ff5d3c6e4bba9d58d Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 1 Mar 2024 07:41:02 -0800 Subject: [PATCH 29/47] Simplify just-tests invocation --- templates/.github/workflows/build.yml.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/.github/workflows/build.yml.in b/templates/.github/workflows/build.yml.in index bcc44eb..9a7e51e 100644 --- a/templates/.github/workflows/build.yml.in +++ b/templates/.github/workflows/build.yml.in @@ -32,7 +32,7 @@ jobs: make setup pip install -U .[test] - name: Test - run: python -m unittest {package}.tests + run: python -m {package}.tests {package}: runs-on: ${{ matrix.os }} From 0fbb1bb2450e59d4132c95879098322ec12de68a Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Tue, 5 Mar 2024 08:24:30 -0800 Subject: [PATCH 30/47] Fixup coverage ignores --- templates/.gitignore.in | 6 ++++++ templates/setup.py.in | 2 +- templates/{package}/__init__.py.in | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/templates/.gitignore.in b/templates/.gitignore.in index 0a4bafc..d6fda1d 100644 --- a/templates/.gitignore.in +++ b/templates/.gitignore.in @@ -105,3 +105,9 @@ venv.bak/ # Visual Studio Code .vscode/ + +# Vim swapfiles +*.sw[op] + +# Setuptools-scm +_version.py diff --git a/templates/setup.py.in b/templates/setup.py.in index d5d43d7..7e06d89 100644 --- a/templates/setup.py.in +++ b/templates/setup.py.in @@ -1,3 +1,3 @@ from setuptools import setup -setup(use_scm_version=True) +setup(use_scm_version={"write_to": "_version.py"}) diff --git a/templates/{package}/__init__.py.in b/templates/{package}/__init__.py.in index da9f1c2..cad7466 100644 --- a/templates/{package}/__init__.py.in +++ b/templates/{package}/__init__.py.in @@ -1,4 +1,4 @@ try: from .version import __version__ -except ImportError: +except ImportError: # pragma: no cover __version__ = "dev" From cc549e0720d21abf2d600c34ec2b6a94d16a5cd8 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Tue, 5 Mar 2024 08:26:01 -0800 Subject: [PATCH 31/47] Correct setuptools-scm version file location --- templates/setup.py.in | 2 +- templates/{package}/__init__.py.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/setup.py.in b/templates/setup.py.in index 7e06d89..8423a4c 100644 --- a/templates/setup.py.in +++ b/templates/setup.py.in @@ -1,3 +1,3 @@ from setuptools import setup -setup(use_scm_version={"write_to": "_version.py"}) +setup(use_scm_version={"write_to": "{package}/_version.py"}) diff --git a/templates/{package}/__init__.py.in b/templates/{package}/__init__.py.in index cad7466..9976658 100644 --- a/templates/{package}/__init__.py.in +++ b/templates/{package}/__init__.py.in @@ -1,4 +1,4 @@ try: - from .version import __version__ + from ._version import __version__ except ImportError: # pragma: no cover __version__ = "dev" From ff370a4ce6435e88746adc6ca609a0dffcbce895 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Tue, 5 Mar 2024 08:28:06 -0800 Subject: [PATCH 32/47] Don't install dev requirements for just-tests --- templates/.github/workflows/build.yml.in | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/.github/workflows/build.yml.in b/templates/.github/workflows/build.yml.in index 9a7e51e..bb8bd63 100644 --- a/templates/.github/workflows/build.yml.in +++ b/templates/.github/workflows/build.yml.in @@ -29,7 +29,6 @@ jobs: - name: Install run: | python -m pip install --upgrade pip - make setup pip install -U .[test] - name: Test run: python -m {package}.tests From 7a6bab211af29a1972f28e59cd3b6074e5b273bf Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Tue, 5 Mar 2024 08:29:23 -0800 Subject: [PATCH 33/47] Bump black and usort versions --- templates/setup.cfg.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 9e1b8e8..55ee41c 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -20,13 +20,13 @@ install_requires = [options.extras_require] dev = - black == 23.12.1 + black == 24.2.0 checkdeps == 0.9.0 flake8 == 7.0.0 mypy == 1.8.0 tox == 4.12.1 twine == 4.0.2 - ufmt == 2.3.0 + ufmt == 2.5.1 usort == 1.0.7 wheel == 0.42.0 test = From 1ec3c6cad1ef654d0148a109034eb35eab351971 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Sun, 24 Nov 2024 19:12:17 -0800 Subject: [PATCH 34/47] Update skel to use trusted publishing by default --- templates/.github/workflows/build.yml.in | 68 ++++++++++++++---------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/templates/.github/workflows/build.yml.in b/templates/.github/workflows/build.yml.in index bb8bd63..0a78554 100644 --- a/templates/.github/workflows/build.yml.in +++ b/templates/.github/workflows/build.yml.in @@ -9,13 +9,16 @@ on: - v* pull_request: +env: + UV_SYSTEM_PYTHON: 1 + jobs: - {package}-just-tests: + test: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] os: [macOS-latest, ubuntu-latest, windows-latest] steps: @@ -25,35 +28,46 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - allow-prereleases: true + - uses: astral-sh/setup-uv@v3 - name: Install run: | - python -m pip install --upgrade pip - pip install -U .[test] + uv pip install -e .[test] - name: Test - run: python -m {package}.tests - - {package}: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - python-version: ["3.10", "3.11", "3.12"] - os: [macOS-latest, ubuntu-latest, windows-latest] + run: make test + - name: Lint + run: | + uv pip install -e .[test,dev] + make lint + if: ${{ matrix.python-version != '3.9' && matrix.python-version != '3.8'}} + build: + needs: test + runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set Up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: "3.12" + - uses: astral-sh/setup-uv@v3 - name: Install - run: | - python -m pip install --upgrade pip - make setup - pip install -U . - - name: Test - run: make test - - name: Lint - run: make lint + run: uv pip install build + - name: Build + run: python -m build + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: sdist + path: dist + + publish: + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v3 + with: + name: sdist + path: dist + - uses: pypa/gh-action-pypi-publish@release/v1 From f7d45172e90ba27881195009b5663b61783bc03b Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Sun, 24 Nov 2024 19:12:40 -0800 Subject: [PATCH 35/47] Bump versions, use min 3.8 --- templates/setup.cfg.in | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 55ee41c..db3c72d 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -10,25 +10,22 @@ author_email = {author_email} [options] packages = find: -python_requires = >=3.7 +python_requires = >=3.8 setup_requires = - setuptools_scm < 8; python_version<'3.8' - setuptools_scm >= 8; python_version>='3.8' + setuptools_scm >= 8 setuptools >= 65 include_package_data = true install_requires = [options.extras_require] dev = - black == 24.2.0 + black == 24.10.0 checkdeps == 0.9.0 - flake8 == 7.0.0 - mypy == 1.8.0 - tox == 4.12.1 - twine == 4.0.2 - ufmt == 2.5.1 - usort == 1.0.7 - wheel == 0.42.0 + flake8 == 7.1.1 + mypy == 1.13.0 + tox == 4.23.2 + ufmt == 2.8.0 + usort == 1.0.8.post1 test = coverage >= 6 @@ -55,7 +52,7 @@ skip_covered = True ignore_missing_imports = True [tox:tox] -envlist = py{@37,38,39,310,311,312}, coverage +envlist = py{@38,39,310,311,312,313}, coverage [testenv] deps = .[test] @@ -73,7 +70,7 @@ commands = coverage combine coverage report depends = - py{@37,38,39,310,311,312} + py{@38,39,310,311,312,313} [flake8] ignore = E203, E231, E266, E302, E501, W503 From 2840097f719b475a04a1fa3ae9b9c67d2f329aee Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Tue, 26 Nov 2024 11:59:44 -0800 Subject: [PATCH 36/47] Use ruff and uv instead of flake8 and pip. --- requirements-dev.txt | 3 +-- templates/Makefile.in | 7 +++++-- templates/setup.cfg.in | 6 +----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 54f7c91..677de44 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,8 +1,7 @@ ufmt==2.5.1 -black==24.2.0 +ruff==0.8.0 usort==1.0.8.post1 coverage==7.4.3 -flake8==7.0.0 mypy==1.8.0 tox==4.13.0 twine==5.0.0 diff --git a/templates/Makefile.in b/templates/Makefile.in index c5d6a20..483311e 100644 --- a/templates/Makefile.in +++ b/templates/Makefile.in @@ -12,7 +12,8 @@ venv: .PHONY: setup setup: - python -m pip install -Ue .[dev,test] + python -m pip install uv + uv pip install -Ue .[dev,test] .PHONY: test test: @@ -22,11 +23,13 @@ test: .PHONY: format format: python -m ufmt format $(SOURCES) + ruff format + ruff check --fix .PHONY: lint lint: python -m ufmt check $(SOURCES) - python -m flake8 $(SOURCES) + ruff check $(SOURCES) python -m checkdeps --allow-names {package} {package} mypy --strict --install-types --non-interactive {package} diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index db3c72d..1694ad4 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -19,9 +19,8 @@ install_requires = [options.extras_require] dev = - black == 24.10.0 + ruff == 0.8.0 checkdeps == 0.9.0 - flake8 == 7.1.1 mypy == 1.13.0 tox == 4.23.2 ufmt == 2.8.0 @@ -72,6 +71,3 @@ commands = depends = py{@38,39,310,311,312,313} -[flake8] -ignore = E203, E231, E266, E302, E501, W503 -max-line-length = 88 From bdc04ab2f448bda8b4a46d81841c3c167d4b726d Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Tue, 26 Nov 2024 13:35:16 -0800 Subject: [PATCH 37/47] Use UV when available. --- templates/Makefile.in | 16 +++++++++++----- templates/pyproject.toml | 12 ++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 templates/pyproject.toml diff --git a/templates/Makefile.in b/templates/Makefile.in index 483311e..599a99e 100644 --- a/templates/Makefile.in +++ b/templates/Makefile.in @@ -1,9 +1,18 @@ PYTHON?=python SOURCES={package} setup.py +UV:=$(shell uv --version) +ifdef UV + VENV:=uv venv + PIP:=uv pip +else + VENV:=python -m venv + PIP:=python -m pip +endif + .PHONY: venv venv: - $(PYTHON) -m venv .venv + $(VENV) .venv source .venv/bin/activate && make setup @echo 'run `source .venv/bin/activate` to use virtualenv' @@ -12,8 +21,7 @@ venv: .PHONY: setup setup: - python -m pip install uv - uv pip install -Ue .[dev,test] + $(PIP) install -Ue .[dev,test] .PHONY: test test: @@ -22,13 +30,11 @@ test: .PHONY: format format: - python -m ufmt format $(SOURCES) ruff format ruff check --fix .PHONY: lint lint: - python -m ufmt check $(SOURCES) ruff check $(SOURCES) python -m checkdeps --allow-names {package} {package} mypy --strict --install-types --non-interactive {package} diff --git a/templates/pyproject.toml b/templates/pyproject.toml new file mode 100644 index 0000000..a1ca0b6 --- /dev/null +++ b/templates/pyproject.toml @@ -0,0 +1,12 @@ +[tool.ruff] +line-length = 88 + +[tool.ruff.lint] +extend-select = [ + "I", # isort +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = [ + "PLR2004", # Magic value used instead of constant (only in tests) +] From 189b0f18b5e5b15e542c27a3d685a0fc15c566e0 Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Tue, 26 Nov 2024 13:38:51 -0800 Subject: [PATCH 38/47] Set order-by-type to false. --- templates/pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/pyproject.toml b/templates/pyproject.toml index a1ca0b6..1422247 100644 --- a/templates/pyproject.toml +++ b/templates/pyproject.toml @@ -6,6 +6,9 @@ extend-select = [ "I", # isort ] +[tool.ruff.lint.isort] +order-by-type = false + [tool.ruff.lint.per-file-ignores] "tests/*" = [ "PLR2004", # Magic value used instead of constant (only in tests) From 7d3147449c1239499494a436c9be1fadb50358f3 Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Tue, 26 Nov 2024 13:40:04 -0800 Subject: [PATCH 39/47] Remove ufmt as a dep. --- templates/setup.cfg.in | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 1694ad4..316c095 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -23,7 +23,6 @@ dev = checkdeps == 0.9.0 mypy == 1.13.0 tox == 4.23.2 - ufmt == 2.8.0 usort == 1.0.8.post1 test = coverage >= 6 From 3084ceddb15303434dc3e417e33a055ae9be8d79 Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Tue, 26 Nov 2024 13:49:48 -0800 Subject: [PATCH 40/47] Migrate top level Makefile to use ruff and uv. --- Makefile | 21 +++++++++++++++------ pyproject.toml | 15 +++++++++++++++ requirements-dev.txt | 2 -- 3 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 pyproject.toml diff --git a/Makefile b/Makefile index ecebb3c..fc9bebb 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,18 @@ PYTHON?=python SOURCES=regen.py regen-git.py +UV:=$(shell uv --version) +ifdef UV + VENV:=uv venv + PIP:=uv pip +else + VENV:=python -m venv + PIP:=python -m pip +endif + .PHONY: venv venv: - $(PYTHON) -m venv .venv + $(VENV) .venv source .venv/bin/activate && make setup @echo 'run `source .venv/bin/activate` to use virtualenv' @@ -12,17 +21,17 @@ venv: .PHONY: setup setup: - python -m pip install -Ur requirements-dev.txt + $(PIP) install -Ur requirements-dev.txt .PHONY: format format: - python -m ufmt format $(SOURCES) + ruff format + ruff check --fix .PHONY: lint lint: - python -m ufmt check $(SOURCES) - python -m flake8 $(SOURCES) - mypy --strict regen.py + ruff check $(SOURCES) + mypy --strict $(SOURCES) .PHONY: checkdeps checkdeps: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..1422247 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[tool.ruff] +line-length = 88 + +[tool.ruff.lint] +extend-select = [ + "I", # isort +] + +[tool.ruff.lint.isort] +order-by-type = false + +[tool.ruff.lint.per-file-ignores] +"tests/*" = [ + "PLR2004", # Magic value used instead of constant (only in tests) +] diff --git a/requirements-dev.txt b/requirements-dev.txt index 677de44..b5c4bd8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,6 +1,4 @@ -ufmt==2.5.1 ruff==0.8.0 -usort==1.0.8.post1 coverage==7.4.3 mypy==1.8.0 tox==4.13.0 From 6a62ddf9d129f50b6d7095ef3df296e6d7b98a05 Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Tue, 26 Nov 2024 13:50:53 -0800 Subject: [PATCH 41/47] Format using make format. --- regen-git.py | 4 ++-- test_skel.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/regen-git.py b/regen-git.py index 49b84a4..4a23a4b 100755 --- a/regen-git.py +++ b/regen-git.py @@ -81,7 +81,7 @@ def main(): subprocess.check_call( ["git", "commit", "-m", f"Initialize skel\n\nrev: {skel_rev}"] ) - except subprocess.CalledProcessError as e: + except subprocess.CalledProcessError: print("\x1b[33mNo changes?\x1b[0m") raise subprocess.check_call(["git", "push", "origin", SKEL_BRANCH]) @@ -106,7 +106,7 @@ def main(): subprocess.check_call( ["git", "commit", "-m", f"Update skel {date}\n\nrev: {skel_rev}"] ) - except subprocess.CalledProcessError as e: + except subprocess.CalledProcessError: print("\x1b[33mNo changes?\x1b[0m") return diff --git a/test_skel.py b/test_skel.py index b2b7c7e..08e3cd4 100644 --- a/test_skel.py +++ b/test_skel.py @@ -1,6 +1,8 @@ import unittest + import regen + class RegenTest(unittest.TestCase): def test_variable_format(self): self.assertEqual("1", regen.variable_format("{foo}", foo="1")) @@ -10,5 +12,6 @@ def test_variable_format(self): with self.assertRaises(TypeError): self.assertEqual("1", regen.variable_format("{foo}", foo=1, bar=2)) + if __name__ == "__main__": unittest.main() From dbb5e2850bc3398a7903647c545acfe67dfa8251 Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Tue, 26 Nov 2024 13:52:29 -0800 Subject: [PATCH 42/47] Add a type hint to main()'s return. --- regen-git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regen-git.py b/regen-git.py index 4a23a4b..68e1639 100755 --- a/regen-git.py +++ b/regen-git.py @@ -31,7 +31,7 @@ def find_git_dir(path: Optional[Path] = None) -> Path: raise Exception("No git dir found before root") -def main(): +def main() -> None: skel_rev = subprocess.check_output( ["git", "describe", "--always", "--dirty"], cwd=os.path.dirname(__file__), From b8ab5e6f8a292be551f77c8724b16ebad887739e Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Tue, 26 Nov 2024 13:58:30 -0800 Subject: [PATCH 43/47] Fix type hints in test_skel.py --- Makefile | 2 +- test_skel.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index fc9bebb..d334f84 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PYTHON?=python -SOURCES=regen.py regen-git.py +SOURCES=regen.py regen-git.py test_skel.py UV:=$(shell uv --version) ifdef UV diff --git a/test_skel.py b/test_skel.py index 08e3cd4..8962656 100644 --- a/test_skel.py +++ b/test_skel.py @@ -4,13 +4,13 @@ class RegenTest(unittest.TestCase): - def test_variable_format(self): + def test_variable_format(self) -> None: self.assertEqual("1", regen.variable_format("{foo}", foo="1")) self.assertEqual("{foo}", regen.variable_format("{foo}")) self.assertEqual("{ foo }", regen.variable_format("{ foo }", foo="1")) self.assertEqual("{{foo}}", regen.variable_format("{{foo}}", foo="1")) with self.assertRaises(TypeError): - self.assertEqual("1", regen.variable_format("{foo}", foo=1, bar=2)) + self.assertEqual("1", regen.variable_format("{foo}", foo=1, bar=2)) # type: ignore [arg-type] if __name__ == "__main__": From 4dfcfbbcd01dad68bfbd1333190b2574b9b1bf74 Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Tue, 26 Nov 2024 13:59:22 -0800 Subject: [PATCH 44/47] Remove usort from deps. --- templates/setup.cfg.in | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 316c095..8ec4322 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -23,7 +23,6 @@ dev = checkdeps == 0.9.0 mypy == 1.13.0 tox == 4.23.2 - usort == 1.0.8.post1 test = coverage >= 6 From b58e475296e17ea932077eb56b1c3b9a8137c7b9 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Wed, 18 Mar 2026 09:02:35 -0700 Subject: [PATCH 45/47] Modernize Python, GHA, Ruff + Uv --- templates/.github/workflows/build.yml.in | 18 ++++++++------- templates/Makefile.in | 29 ++++++++---------------- templates/setup.cfg.in | 20 ++++++++-------- 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/templates/.github/workflows/build.yml.in b/templates/.github/workflows/build.yml.in index 0a78554..f236aeb 100644 --- a/templates/.github/workflows/build.yml.in +++ b/templates/.github/workflows/build.yml.in @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] os: [macOS-latest, ubuntu-latest, windows-latest] steps: @@ -28,17 +28,19 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true - uses: astral-sh/setup-uv@v3 - name: Install run: | - uv pip install -e .[test] + uv pip install -e .[test,dev] - name: Test - run: make test + run: | + git config --global user.name "Unit Test" + git config --global user.email "example@example.com" + make test - name: Lint run: | - uv pip install -e .[test,dev] make lint - if: ${{ matrix.python-version != '3.9' && matrix.python-version != '3.8'}} build: needs: test @@ -47,14 +49,14 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.14" - uses: astral-sh/setup-uv@v3 - name: Install run: uv pip install build - name: Build run: python -m build - name: Upload - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: sdist path: dist @@ -66,7 +68,7 @@ jobs: permissions: id-token: write steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: sdist path: dist diff --git a/templates/Makefile.in b/templates/Makefile.in index 599a99e..5d9c236 100644 --- a/templates/Makefile.in +++ b/templates/Makefile.in @@ -1,5 +1,8 @@ -PYTHON?=python -SOURCES={package} setup.py +ifeq ($(OS),Windows_NT) + ACTIVATE:=.venv/Scripts/activate +else + ACTIVATE:=.venv/bin/activate +endif UV:=$(shell uv --version) ifdef UV @@ -10,22 +13,16 @@ else PIP:=python -m pip endif -.PHONY: venv -venv: +.venv: $(VENV) .venv - source .venv/bin/activate && make setup - @echo 'run `source .venv/bin/activate` to use virtualenv' - -# The rest of these are intended to be run within the venv, where python points -# to whatever was used to set up the venv. .PHONY: setup -setup: - $(PIP) install -Ue .[dev,test] +setup: .venv + source $(ACTIVATE) && $(PIP) install -Ue .[dev,test] .PHONY: test test: - python -m coverage run -m {package}.tests $(TESTOPTS) + python -m coverage run -m pytest $(TESTOPTS) python -m coverage report .PHONY: format @@ -35,12 +32,6 @@ format: .PHONY: lint lint: - ruff check $(SOURCES) + ruff check python -m checkdeps --allow-names {package} {package} mypy --strict --install-types --non-interactive {package} - -.PHONY: release -release: - rm -rf dist - python setup.py sdist bdist_wheel - twine upload dist/* diff --git a/templates/setup.cfg.in b/templates/setup.cfg.in index 8ec4322..c946f71 100644 --- a/templates/setup.cfg.in +++ b/templates/setup.cfg.in @@ -10,7 +10,7 @@ author_email = {author_email} [options] packages = find: -python_requires = >=3.8 +python_requires = >=3.10 setup_requires = setuptools_scm >= 8 setuptools >= 65 @@ -19,12 +19,14 @@ install_requires = [options.extras_require] dev = - ruff == 0.8.0 checkdeps == 0.9.0 - mypy == 1.13.0 - tox == 4.23.2 + mypy == 1.19.1 + ruff == 0.15.6 + tox == 4.50.0 + tox-uv == 1.33.4 test = coverage >= 6 + pytest >= 8 [options.entry_points] # console_scripts = @@ -36,8 +38,7 @@ strict = true [coverage:run] branch = True -include = {package}/* -omit = {package}/tests/* +source = {package},tests [coverage:report] fail_under = 70 @@ -49,13 +50,12 @@ skip_covered = True ignore_missing_imports = True [tox:tox] -envlist = py{@38,39,310,311,312,313}, coverage +envlist = py{@310,311,312,313,314}, coverage [testenv] deps = .[test] -allowlist_externals = make commands = - make test + coverage run -m pytest setenv = COVERAGE_FILE={@toxworkdir}/.coverage.{@envname} @@ -67,5 +67,5 @@ commands = coverage combine coverage report depends = - py{@38,39,310,311,312,313} + py{@10,311,312,313,314} From 10568a3ef3441616ca33ca76d51fbdbec5da965f Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Wed, 18 Mar 2026 08:29:40 -0700 Subject: [PATCH 46/47] Move to pytest too --- templates/tests/conftest.py.in | 0 templates/{package}/tests/__init__.py.in | 5 ----- templates/{package}/tests/__main__.py.in | 4 ---- 3 files changed, 9 deletions(-) create mode 100644 templates/tests/conftest.py.in delete mode 100644 templates/{package}/tests/__init__.py.in delete mode 100644 templates/{package}/tests/__main__.py.in diff --git a/templates/tests/conftest.py.in b/templates/tests/conftest.py.in new file mode 100644 index 0000000..e69de29 diff --git a/templates/{package}/tests/__init__.py.in b/templates/{package}/tests/__init__.py.in deleted file mode 100644 index ff2b359..0000000 --- a/templates/{package}/tests/__init__.py.in +++ /dev/null @@ -1,5 +0,0 @@ -# from .foo import FooTest - -__all__ = [ - # "FooTest", -] diff --git a/templates/{package}/tests/__main__.py.in b/templates/{package}/tests/__main__.py.in deleted file mode 100644 index e40763e..0000000 --- a/templates/{package}/tests/__main__.py.in +++ /dev/null @@ -1,4 +0,0 @@ -import unittest - -if __name__ == "__main__": - unittest.main(module="{package}.tests", verbosity=2) From adae1006684b2ba4fecd0f0c76042aacc7a63b7e Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Wed, 18 Mar 2026 09:06:02 -0700 Subject: [PATCH 47/47] Update readme boilerplate --- templates/README.md.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/README.md.in b/templates/README.md.in index 5a9fcd3..d26ed96 100644 --- a/templates/README.md.in +++ b/templates/README.md.in @@ -3,8 +3,8 @@ # Version Compat -Usage of this library should work back to 3.7, but development (and mypy -compatibility) only on 3.10-3.12. Linting requires 3.12 for full fidelity. +This library is compatile with Python 3.10+, but should be linted under the +newest stable version. # Versioning