diff --git a/(meta)/stable.txt b/(meta)/stable.txt new file mode 100644 index 0000000000..d23e20b4d8 --- /dev/null +++ b/(meta)/stable.txt @@ -0,0 +1 @@ +v72.2.0 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b9ecc51412..cbb7f7f9ae 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 @@ -91,20 +93,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: | + tox -e version rm -rf dist # workaround for pypa/setuptools#4333 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 @@ -172,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: @@ -227,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 @@ -252,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: diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..30572aa4b0 --- /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. +(meta)/latest.txt diff --git a/MANIFEST.in b/MANIFEST.in index 0643e7ee2d..6c7b23c06e 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 +graft (meta) global-exclude *.py[cod] __pycache__ diff --git a/pyproject.toml b/pyproject.toml index 1ce17e63ab..886bd7d079 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_file = "(meta)/latest.txt" diff --git a/setup.py b/setup.py index 1cd9e36c15..de4b77402e 100755 --- a/setup.py +++ b/setup.py @@ -26,6 +26,13 @@ package_data.setdefault('setuptools.command', []).extend(['*.xml']) +def get_version() -> str: + 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() + + def pypi_link(pkg_filename): """ Given the filename, including md5 fragment, construct the @@ -83,6 +90,7 @@ def _restore_install_lib(self): setup_params = dict( + version=get_version(), cmdclass={'install': install_with_pth}, package_data=package_data, ) diff --git a/tools/finalize.py b/tools/finalize.py index d646e67cd0..084099ed40 100644 --- a/tools/finalize.py +++ b/tools/finalize.py @@ -1,62 +1,23 @@ """ -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 import subprocess -import sys +from pathlib import Path from jaraco.develop import towncrier - -bump_version_command = [ - sys.executable, - '-m', - 'bumpversion', - towncrier.release_kind(), -] - - -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) - - -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 bump_version(): - cmd = bump_version_command + ['--allow-dirty'] - subprocess.check_call(cmd) +from jaraco.develop.finalize import finalize -def ensure_config(): - """ - Double-check that Git has an e-mail configured. - """ - subprocess.check_output(['git', 'config', 'user.email']) +def main(): + version = towncrier.semver(towncrier.get_version()) + version = version.lstrip("v") # Compatibility with setuptools-scm + 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__': - print("Cutting release at", get_version()) - ensure_config() - towncrier.check_changes() - update_changelog() - bump_version() +__name__ == '__main__' and main() diff --git a/tox.ini b/tox.ini index bc0540b0d4..4387848960 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 = @@ -53,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 @@ -63,12 +65,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 @@ -81,6 +81,15 @@ deps = commands = vendor: python -m tools.vendored +[testenv:version] +skip_install = True +deps = + setuptools_scm>=8.1 +pass_env = + SETUPTOOLS_SCM* +commands = + python -m setuptools_scm --force-write-version-files + [testenv:generate-validation-code] skip_install = True deps =