From 77a1f08d1a90db76f08804199d4d305a2fbae5f3 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 1 Aug 2024 14:08:45 +0100 Subject: [PATCH 01/13] Use setuptools-scm to produce new versions --- .gitignore | 4 ++++ MANIFEST.in | 1 + conftest.py | 1 + pyproject.toml | 3 ++- setup.py | 23 +++++++++++++++++++++++ tools/save_version.py | 11 +++++++++++ tox.ini | 12 ++++++++++++ 7 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 tools/save_version.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..a400127ca7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# This file lists exclude patterns unique to the repository. +# Do not add common patterns here, see https://blog.jaraco.com/skeleton/#ignoring-artifacts +# for a global approach or use .git/info/exclude. +.version diff --git a/MANIFEST.in b/MANIFEST.in index 0643e7ee2d..e4357aaae2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -18,4 +18,5 @@ include pytest.ini include tox.ini include setuptools/tests/config/setupcfg_examples.txt include setuptools/config/*.schema.json +include .version global-exclude *.py[cod] __pycache__ diff --git a/conftest.py b/conftest.py index 01ed2fa2e6..ef15034ffc 100644 --- a/conftest.py +++ b/conftest.py @@ -27,6 +27,7 @@ def pytest_configure(config): collect_ignore = [ + 'tools/save_version.py', 'tests/manual_test.py', 'setuptools/tests/mod_with_constant.py', 'setuptools/_distutils', diff --git a/pyproject.toml b/pyproject.toml index 1ce17e63ab..e0cb8a31df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,6 @@ backend-path = ["."] [project] name = "setuptools" -version = "72.2.0" authors = [ { name = "Python Packaging Authority", email = "distutils-sig@python.org" }, ] @@ -26,6 +25,7 @@ keywords = ["CPAN PyPI distutils eggs package management"] requires-python = ">=3.8" dependencies = [ ] +dynamic = ["version"] [project.urls] Source = "https://github.com/pypa/setuptools" @@ -194,3 +194,4 @@ namespaces = true formats = "zip" [tool.setuptools_scm] +version_scheme = "no-guess-dev" diff --git a/setup.py b/setup.py index 1cd9e36c15..19d4e616f0 100755 --- a/setup.py +++ b/setup.py @@ -10,6 +10,28 @@ here = os.path.dirname(__file__) +try: + with open(".version") as f: + version = f.read() +except FileNotFoundError as ex: + # We could just use `tool.setuptools.dynamic.version.file` in `pyproject.toml`, + # but this way we can have a clear error message with specific instructions + # on how to solve the problem. + msg = f"""{ex!s} + + This is probably caused by one of the following: + a. You are trying to build `setuptools` source-tree from scratch + (without using the official `sdist` distributed in PyPI). + b. You are trying to test `setuptools` without the help of `tox`. + + To prevent this error from happening please write a PEP 440 compliant string + corresponding to the current setuptools version on the `.version` file at the root + of the repository (`tox -e version` can automatically do that for you based on the + available git tags). + """ + raise FileNotFoundError(msg) from None + + package_data = { "": ["LICEN[CS]E*", "COPYING*", "NOTICE*", "AUTHORS*"], "setuptools": ['script (dev).tmpl', 'script.tmpl', 'site-patch.py'], @@ -83,6 +105,7 @@ def _restore_install_lib(self): setup_params = dict( + version=version, cmdclass={'install': install_with_pth}, package_data=package_data, ) diff --git a/tools/save_version.py b/tools/save_version.py new file mode 100644 index 0000000000..1075cd3292 --- /dev/null +++ b/tools/save_version.py @@ -0,0 +1,11 @@ +from pathlib import Path +from setuptools_scm import get_version + + +def save_version(): + version = get_version() + Path(".version").write_text(version, encoding="utf-8") + return version + + +__name__ == '__main__' and print(save_version()) diff --git a/tox.ini b/tox.ini index bc0540b0d4..0f8700fdaa 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,7 @@ setenv = PYTHONWARNDEFAULTENCODING = 1 SETUPTOOLS_ENFORCE_DEPRECATION = {env:SETUPTOOLS_ENFORCE_DEPRECATION:1} commands = + tox -qe version # Use a separated testenv to avoid entrypoints tampering with tests pytest {posargs} usedevelop = True extras = @@ -81,6 +82,17 @@ deps = commands = vendor: python -m tools.vendored +[testenv:version] +skip_install = True +deps = + setuptools_scm>=8 +pass_env = + SETUPTOOLS_SCM* +commands = + # Ideally `python -m setuptools_scm > .version` + # but pipping is not supported by tox and `bash -c` does not work on Windows + python -m tools.save_version + [testenv:generate-validation-code] skip_install = True deps = From 2ad959d4fe0e45ec75456bc6eca2e22ce91a6c92 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 1 Aug 2024 14:56:48 +0100 Subject: [PATCH 02/13] Use finalize to save stable version --- .stable | 1 + MANIFEST.in | 2 +- setup.py | 30 +++++++----------------------- tools/finalize.py | 27 ++++++++++++++------------- tox.ini | 4 +--- 5 files changed, 24 insertions(+), 40 deletions(-) create mode 100644 .stable diff --git a/.stable b/.stable new file mode 100644 index 0000000000..82ba3aba87 --- /dev/null +++ b/.stable @@ -0,0 +1 @@ +v72.1.0 diff --git a/MANIFEST.in b/MANIFEST.in index e4357aaae2..33fc078972 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -18,5 +18,5 @@ include pytest.ini include tox.ini include setuptools/tests/config/setupcfg_examples.txt include setuptools/config/*.schema.json -include .version +include .version .stable global-exclude *.py[cod] __pycache__ diff --git a/setup.py b/setup.py index 19d4e616f0..8ab6f09817 100755 --- a/setup.py +++ b/setup.py @@ -10,28 +10,6 @@ here = os.path.dirname(__file__) -try: - with open(".version") as f: - version = f.read() -except FileNotFoundError as ex: - # We could just use `tool.setuptools.dynamic.version.file` in `pyproject.toml`, - # but this way we can have a clear error message with specific instructions - # on how to solve the problem. - msg = f"""{ex!s} - - This is probably caused by one of the following: - a. You are trying to build `setuptools` source-tree from scratch - (without using the official `sdist` distributed in PyPI). - b. You are trying to test `setuptools` without the help of `tox`. - - To prevent this error from happening please write a PEP 440 compliant string - corresponding to the current setuptools version on the `.version` file at the root - of the repository (`tox -e version` can automatically do that for you based on the - available git tags). - """ - raise FileNotFoundError(msg) from None - - package_data = { "": ["LICEN[CS]E*", "COPYING*", "NOTICE*", "AUTHORS*"], "setuptools": ['script (dev).tmpl', 'script.tmpl', 'site-patch.py'], @@ -48,6 +26,12 @@ package_data.setdefault('setuptools.command', []).extend(['*.xml']) +def get_version() -> str: + version_files = (f for f in [".version", ".stable"] if os.path.exists(f)) + with open(next(version_files), encoding="utf-8") as fp: + return fp.read() + + def pypi_link(pkg_filename): """ Given the filename, including md5 fragment, construct the @@ -105,7 +89,7 @@ def _restore_install_lib(self): setup_params = dict( - version=version, + version=get_version(), cmdclass={'install': install_with_pth}, package_data=package_data, ) diff --git a/tools/finalize.py b/tools/finalize.py index d646e67cd0..31b4fce44f 100644 --- a/tools/finalize.py +++ b/tools/finalize.py @@ -1,9 +1,8 @@ """ -Finalize the repo for a release. Invokes towncrier and bumpversion. +Finalize the repo for a release. Invokes towncrier. """ -__requires__ = ['bump2version', 'towncrier', 'jaraco.develop>=7.21'] - +__requires__ = ['towncrier', 'jaraco.develop>=7.23'] import pathlib import re @@ -21,9 +20,13 @@ def get_version(): - cmd = bump_version_command + ['--dry-run', '--verbose'] - out = subprocess.check_output(cmd, text=True, encoding='utf-8') - return re.search('^new_version=(.*)', out, re.MULTILINE).group(1) + return towncrier.semver(towncrier.get_version()) + + +def save_version(version): + pathlib.Path(".version").unlink() # Remove development version + pathlib.Path(".stable").write_text(version, encoding="utf-8") + subprocess.check_output(['git', 'add', ".stable"]) def update_changelog(): @@ -42,11 +45,6 @@ def _repair_changelog(): subprocess.check_output(['git', 'add', changelog_fn]) -def bump_version(): - cmd = bump_version_command + ['--allow-dirty'] - subprocess.check_call(cmd) - - def ensure_config(): """ Double-check that Git has an e-mail configured. @@ -55,8 +53,11 @@ def ensure_config(): if __name__ == '__main__': - print("Cutting release at", get_version()) + version = get_version() + print("Cutting release at", version) ensure_config() + save_version(version) towncrier.check_changes() update_changelog() - bump_version() + subprocess.check_call(['git', 'commit', '-a', '-m', f'Finalize #{version}']) + subprocess.check_call(['git', 'tag', '-a', '-m', '', version]) diff --git a/tox.ini b/tox.ini index 0f8700fdaa..af744e327a 100644 --- a/tox.ini +++ b/tox.ini @@ -64,12 +64,10 @@ description = assemble changelog and tag a release skip_install = True deps = towncrier - bump2version jaraco.develop >= 7.23 - importlib_resources < 6 # twisted/towncrier#528 (waiting for release) pass_env = * commands = - python tools/finalize.py + python -m tools.finalize [testenv:vendor] skip_install = True From 5a43f50a731ebf9860e9bdc908592d7c98b10e75 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 1 Aug 2024 14:59:46 +0100 Subject: [PATCH 03/13] Rename .version to .latest --- .gitignore | 2 +- MANIFEST.in | 2 +- setup.py | 2 +- tools/finalize.py | 2 +- tools/save_version.py | 7 +++++-- tox.ini | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index a400127ca7..d73c329e3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ # This file lists exclude patterns unique to the repository. # Do not add common patterns here, see https://blog.jaraco.com/skeleton/#ignoring-artifacts # for a global approach or use .git/info/exclude. -.version +.latest diff --git a/MANIFEST.in b/MANIFEST.in index 33fc078972..7980c7dc17 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -18,5 +18,5 @@ include pytest.ini include tox.ini include setuptools/tests/config/setupcfg_examples.txt include setuptools/config/*.schema.json -include .version .stable +include .latest .stable global-exclude *.py[cod] __pycache__ diff --git a/setup.py b/setup.py index 8ab6f09817..9d49aac060 100755 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def get_version() -> str: - version_files = (f for f in [".version", ".stable"] if os.path.exists(f)) + version_files = (f for f in [".latest", ".stable"] if os.path.exists(f)) with open(next(version_files), encoding="utf-8") as fp: return fp.read() diff --git a/tools/finalize.py b/tools/finalize.py index 31b4fce44f..1a6c6e11f7 100644 --- a/tools/finalize.py +++ b/tools/finalize.py @@ -24,7 +24,7 @@ def get_version(): def save_version(version): - pathlib.Path(".version").unlink() # Remove development version + pathlib.Path(".latest").unlink() # Remove "unstable"/development version pathlib.Path(".stable").write_text(version, encoding="utf-8") subprocess.check_output(['git', 'add', ".stable"]) diff --git a/tools/save_version.py b/tools/save_version.py index 1075cd3292..bdfa3e1740 100644 --- a/tools/save_version.py +++ b/tools/save_version.py @@ -1,10 +1,13 @@ +__requires__ = ['setuptools_scm>=8'] + + from pathlib import Path from setuptools_scm import get_version def save_version(): - version = get_version() - Path(".version").write_text(version, encoding="utf-8") + version = f"v{get_version().lstrip('v')}" + Path(".latest").write_text(version, encoding="utf-8") return version diff --git a/tox.ini b/tox.ini index af744e327a..d92952e24c 100644 --- a/tox.ini +++ b/tox.ini @@ -87,7 +87,7 @@ deps = pass_env = SETUPTOOLS_SCM* commands = - # Ideally `python -m setuptools_scm > .version` + # Ideally `python -m setuptools_scm > .latest` # but pipping is not supported by tox and `bash -c` does not work on Windows python -m tools.save_version From 5e5f5d714d74a833cb537a13981102c351811fd6 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 1 Aug 2024 15:03:50 +0100 Subject: [PATCH 04/13] Simplify fallback in save_version --- tools/save_version.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/save_version.py b/tools/save_version.py index bdfa3e1740..6cd224fff2 100644 --- a/tools/save_version.py +++ b/tools/save_version.py @@ -1,12 +1,11 @@ __requires__ = ['setuptools_scm>=8'] - from pathlib import Path from setuptools_scm import get_version def save_version(): - version = f"v{get_version().lstrip('v')}" + version = f"v{get_version()}" # add v -> compatible with jaraco.develop.towncrier Path(".latest").write_text(version, encoding="utf-8") return version From ae23c0277867b9768ae63c430867f5cb7726ab88 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 1 Aug 2024 15:23:58 +0100 Subject: [PATCH 05/13] Remove version scheme customisation --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e0cb8a31df..f501414f26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -194,4 +194,3 @@ namespaces = true formats = "zip" [tool.setuptools_scm] -version_scheme = "no-guess-dev" From 78b876b8da5ef87d4345c9d3528d2b7e7b7b6acb Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 1 Aug 2024 15:27:03 +0100 Subject: [PATCH 06/13] Fix mispelling --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index d92952e24c..1fcab6ce8a 100644 --- a/tox.ini +++ b/tox.ini @@ -88,7 +88,7 @@ pass_env = SETUPTOOLS_SCM* commands = # Ideally `python -m setuptools_scm > .latest` - # but pipping is not supported by tox and `bash -c` does not work on Windows + # but piping is not supported by tox and `bash -c` does not work on Windows python -m tools.save_version [testenv:generate-validation-code] From 92d4c302bf9fa6b2d8aff421b251a4c51c771b2d Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 1 Aug 2024 15:28:53 +0100 Subject: [PATCH 07/13] Update version before building docs --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 1fcab6ce8a..c9cfb07b13 100644 --- a/tox.ini +++ b/tox.ini @@ -54,6 +54,7 @@ changedir = docs deps = importlib_resources < 6 # twisted/towncrier#528 (waiting for release) commands = + tox -qe version python -m sphinx -W --keep-going . {toxinidir}/build/html python -m sphinxlint \ # workaround for sphinx-contrib/sphinx-lint#83 From 366858e78e8222fca04521a1c33a7e7f653a98b0 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 1 Aug 2024 16:05:23 +0100 Subject: [PATCH 08/13] Use development version when creating wheels --- .github/workflows/main.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b9ecc51412..231c557528 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -91,20 +91,21 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' working-directory: setuptools/tests/config run: python -m downloads.preload setupcfg_examples.txt + - name: Workaround for unreleased PyNaCl (pyca/pynacl#805) + if: contains(matrix.python, 'pypy') + run: echo "SETUPTOOLS_ENFORCE_DEPRECATION=0" >> $GITHUB_ENV + - name: Install tox + run: python -m pip install tox - name: Pre-build distributions for test shell: bash run: | rm -rf dist # workaround for pypa/setuptools#4333 + tox -e version pipx run --pip-args 'pyproject-hooks!=1.1' build echo "PRE_BUILT_SETUPTOOLS_SDIST=$(ls dist/*.tar.gz)" >> $GITHUB_ENV echo "PRE_BUILT_SETUPTOOLS_WHEEL=$(ls dist/*.whl)" >> $GITHUB_ENV rm -rf setuptools.egg-info # Avoid interfering with the other tests - - name: Workaround for unreleased PyNaCl (pyca/pynacl#805) - if: contains(matrix.python, 'pypy') - run: echo "SETUPTOOLS_ENFORCE_DEPRECATION=0" >> $GITHUB_ENV - - name: Install tox - run: python -m pip install tox - name: Run run: tox - name: Create coverage report From 1e4ade70d516e2e2c83f14b7d40d502fc865968c Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 2 Aug 2024 10:55:54 +0100 Subject: [PATCH 09/13] Fetch git history so that setuptools-scm may work --- .github/workflows/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 231c557528..b91fb05941 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,6 +74,8 @@ jobs: timeout-minutes: 75 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Python id: python-install uses: actions/setup-python@v5 @@ -173,6 +175,8 @@ jobs: timeout-minutes: 75 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install Cygwin with Python uses: cygwin/cygwin-install-action@v4 with: @@ -228,6 +232,8 @@ jobs: timeout-minutes: 75 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install OS-level dependencies run: | sudo apt-get update @@ -253,6 +259,8 @@ jobs: timeout-minutes: 75 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v5 with: From c2c5132a407ef470d9e539a666d197b4edf0e917 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Mon, 12 Aug 2024 17:55:21 +0100 Subject: [PATCH 10/13] Fix comment position --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b91fb05941..cbb7f7f9ae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -101,9 +101,9 @@ jobs: - name: Pre-build distributions for test shell: bash run: | + tox -e version rm -rf dist # workaround for pypa/setuptools#4333 - tox -e version pipx run --pip-args 'pyproject-hooks!=1.1' build echo "PRE_BUILT_SETUPTOOLS_SDIST=$(ls dist/*.tar.gz)" >> $GITHUB_ENV echo "PRE_BUILT_SETUPTOOLS_WHEEL=$(ls dist/*.whl)" >> $GITHUB_ENV From 6a8a4b59d57667abe10d06cfeaf164241a855e7d Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Mon, 12 Aug 2024 18:18:10 +0100 Subject: [PATCH 11/13] Use (meta) for version files instead of '.*' --- .stable => (meta)/stable.txt | 0 .gitignore | 2 +- MANIFEST.in | 2 +- conftest.py | 1 - pyproject.toml | 1 + setup.py | 5 +++-- tools/finalize.py | 5 +++-- tools/save_version.py | 13 ------------- tox.ini | 6 ++---- 9 files changed, 11 insertions(+), 24 deletions(-) rename .stable => (meta)/stable.txt (100%) delete mode 100644 tools/save_version.py diff --git a/.stable b/(meta)/stable.txt similarity index 100% rename from .stable rename to (meta)/stable.txt diff --git a/.gitignore b/.gitignore index d73c329e3f..30572aa4b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ # This file lists exclude patterns unique to the repository. # Do not add common patterns here, see https://blog.jaraco.com/skeleton/#ignoring-artifacts # for a global approach or use .git/info/exclude. -.latest +(meta)/latest.txt diff --git a/MANIFEST.in b/MANIFEST.in index 7980c7dc17..6c7b23c06e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -18,5 +18,5 @@ include pytest.ini include tox.ini include setuptools/tests/config/setupcfg_examples.txt include setuptools/config/*.schema.json -include .latest .stable +graft (meta) global-exclude *.py[cod] __pycache__ diff --git a/conftest.py b/conftest.py index ef15034ffc..01ed2fa2e6 100644 --- a/conftest.py +++ b/conftest.py @@ -27,7 +27,6 @@ def pytest_configure(config): collect_ignore = [ - 'tools/save_version.py', 'tests/manual_test.py', 'setuptools/tests/mod_with_constant.py', 'setuptools/_distutils', diff --git a/pyproject.toml b/pyproject.toml index f501414f26..886bd7d079 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -194,3 +194,4 @@ namespaces = true formats = "zip" [tool.setuptools_scm] +version_file = "(meta)/latest.txt" diff --git a/setup.py b/setup.py index 9d49aac060..de4b77402e 100755 --- a/setup.py +++ b/setup.py @@ -27,8 +27,9 @@ def get_version() -> str: - version_files = (f for f in [".latest", ".stable"] if os.path.exists(f)) - with open(next(version_files), encoding="utf-8") as fp: + candidates = ["(meta)/latest.txt", "(meta)/stable.txt"] + version_file = next(f for f in candidates if os.path.exists(f)) + with open(version_file, encoding="utf-8") as fp: return fp.read() diff --git a/tools/finalize.py b/tools/finalize.py index 1a6c6e11f7..9e68fb8b04 100644 --- a/tools/finalize.py +++ b/tools/finalize.py @@ -24,8 +24,9 @@ def get_version(): def save_version(version): - pathlib.Path(".latest").unlink() # Remove "unstable"/development version - pathlib.Path(".stable").write_text(version, encoding="utf-8") + version = version.lstrip("v") # Compatibility with setuptools-scm + pathlib.Path("(meta)/latest.txt").unlink() # Remove "unstable"/development version + pathlib.Path("(meta)/stable.txt").write_text(version, encoding="utf-8") subprocess.check_output(['git', 'add', ".stable"]) diff --git a/tools/save_version.py b/tools/save_version.py deleted file mode 100644 index 6cd224fff2..0000000000 --- a/tools/save_version.py +++ /dev/null @@ -1,13 +0,0 @@ -__requires__ = ['setuptools_scm>=8'] - -from pathlib import Path -from setuptools_scm import get_version - - -def save_version(): - version = f"v{get_version()}" # add v -> compatible with jaraco.develop.towncrier - Path(".latest").write_text(version, encoding="utf-8") - return version - - -__name__ == '__main__' and print(save_version()) diff --git a/tox.ini b/tox.ini index c9cfb07b13..4387848960 100644 --- a/tox.ini +++ b/tox.ini @@ -84,13 +84,11 @@ commands = [testenv:version] skip_install = True deps = - setuptools_scm>=8 + setuptools_scm>=8.1 pass_env = SETUPTOOLS_SCM* commands = - # Ideally `python -m setuptools_scm > .latest` - # but piping is not supported by tox and `bash -c` does not work on Windows - python -m tools.save_version + python -m setuptools_scm --force-write-version-files [testenv:generate-validation-code] skip_install = True From bbe048817dee36dc6e1dce4f60eb11651c6f8997 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Mon, 12 Aug 2024 18:33:59 +0100 Subject: [PATCH 12/13] Simplify tools/finalize --- tools/finalize.py | 59 ++++++++--------------------------------------- 1 file changed, 9 insertions(+), 50 deletions(-) diff --git a/tools/finalize.py b/tools/finalize.py index 9e68fb8b04..084099ed40 100644 --- a/tools/finalize.py +++ b/tools/finalize.py @@ -4,61 +4,20 @@ __requires__ = ['towncrier', 'jaraco.develop>=7.23'] -import pathlib -import re import subprocess -import sys +from pathlib import Path from jaraco.develop import towncrier +from jaraco.develop.finalize import finalize -bump_version_command = [ - sys.executable, - '-m', - 'bumpversion', - towncrier.release_kind(), -] - -def get_version(): - return towncrier.semver(towncrier.get_version()) - - -def save_version(version): +def main(): + version = towncrier.semver(towncrier.get_version()) version = version.lstrip("v") # Compatibility with setuptools-scm - pathlib.Path("(meta)/latest.txt").unlink() # Remove "unstable"/development version - pathlib.Path("(meta)/stable.txt").write_text(version, encoding="utf-8") - subprocess.check_output(['git', 'add', ".stable"]) - - -def update_changelog(): - towncrier.run('build', '--yes') - _repair_changelog() - - -def _repair_changelog(): - """ - Workaround for #2666 - """ - changelog_fn = pathlib.Path('NEWS.rst') - changelog = changelog_fn.read_text(encoding='utf-8') - fixed = re.sub(r'^(v[0-9.]+)v[0-9.]+$', r'\1', changelog, flags=re.M) - changelog_fn.write_text(fixed, encoding='utf-8') - subprocess.check_output(['git', 'add', changelog_fn]) - - -def ensure_config(): - """ - Double-check that Git has an e-mail configured. - """ - subprocess.check_output(['git', 'config', 'user.email']) + Path("(meta)/latest.txt").unlink() # Remove "unstable"/development version + Path("(meta)/stable.txt").write_text(version, encoding="utf-8") + subprocess.check_output(['git', 'add', "(meta)/stable.txt"]) + finalize() -if __name__ == '__main__': - version = get_version() - print("Cutting release at", version) - ensure_config() - save_version(version) - towncrier.check_changes() - update_changelog() - subprocess.check_call(['git', 'commit', '-a', '-m', f'Finalize #{version}']) - subprocess.check_call(['git', 'tag', '-a', '-m', '', version]) +__name__ == '__main__' and main() From 561f959daa723d6242e7ef36551c10a339260a39 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 13 Aug 2024 11:58:16 +0100 Subject: [PATCH 13/13] Update stable version according to tags --- (meta)/stable.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/(meta)/stable.txt b/(meta)/stable.txt index 82ba3aba87..d23e20b4d8 100644 --- a/(meta)/stable.txt +++ b/(meta)/stable.txt @@ -1 +1 @@ -v72.1.0 +v72.2.0