-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addopt setuptools-scm
without vendoring setuptools-scm
#4537
base: main
Are you sure you want to change the base?
Changes from all commits
77a1f08
2ad959d
5a43f50
5e5f5d7
ae23c02
78b876b
92d4c30
366858e
1e4ade7
c2c5132
6a8a4b5
bbe0488
561f959
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v72.2.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder why this isn't a problem for other projects I use that employ setuptools_scm. It's a little frustrating that this concern needs to be addressed in multiple different places. Probably it should instead reference a common setting that documents its purpose. No need to deal with that yet, until we decide to go forward with this approach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably because |
||
- 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: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,23 @@ | ||
""" | ||
Finalize the repo for a release. Invokes towncrier and bumpversion. | ||
Finalize the repo for a release. Invokes towncrier. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was really hoping to see this file gone, as it mostly duplicates There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have removed most of the duplication based on the approach discussed in #4537 (comment). We could add support for a hook in # Potential change in jaraco.develop.finalize
Hook: TypeAlias = Callable[[str], Iterable[str]]
def finalize(modify_files: Hook = lambda _: []):
...
if modified := modify_files(version):
subprocess.run(["git", "add", *modified], ...)
... Or something like a |
||
""" | ||
|
||
__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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just moved this part around such that tox would be installed before pre-building distributions1.
Footnotes
The pre-built distributions were previously introduced to be used with virtualenv fixtures, it is also used by downstream packagers. ↩