Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
*.bat text eol=crlf

# setuptools-scm reads the version out of this file when the source tree is a
# ``git archive`` (a GitHub source download) rather than a checkout.
# Deliberately the "stable" template: it records describe output but not
# ``ref-names``, so the archive of a given commit does not change its content
# -- and therefore its checksum -- when a branch that points at it later moves.
.git_archival.txt export-subst
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Only meaningful inside a ``git archive``, where ``export-subst`` has filled it
# in; an sdist carries its version in the metadata instead. Shipping the
# unexpanded template would leave setuptools-scm a stray ``$Format:...$`` to
# consider on every build from an unpacked sdist.
exclude .git_archival.txt
17 changes: 17 additions & 0 deletions changelog/11680.packaging.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Source archives of arbitrary commits -- the tarballs GitHub serves under
``/archive/``, not just the ones for tags -- can now be built into an sdist or a
wheel with a correct version. A ``.git_archival.txt`` file, expanded by ``git
archive`` via ``export-subst``, carries the describe output that
``setuptools-scm`` would otherwise have to ask ``git`` for.

The archival file deliberately omits ``ref-names``. Recording it would make the
content of an archive -- and therefore its checksum -- change whenever a branch
that points at the archived commit is moved afterwards, which is how the
equivalent tarballs of tagged releases became unstable for other projects.
Describe output alone depends only on the commit and on the tags reachable from
it.

The archival file is not shipped in the sdist -- an sdist carries its version
in its metadata, and the template is only ever expanded by ``git archive``.

Building pytest from a git checkout now requires ``setuptools-scm >= 10.1``.
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=77",
"setuptools-scm[toml]>=6.2.3",
"setuptools-scm[toml]>=10.1",
]

[project]
Expand Down Expand Up @@ -82,7 +82,10 @@ scripts.pytest = "_pytest.config:_console_main"
]

[tool.setuptools_scm]
write_to = "src/_pytest/_version.py"
version_file = "src/_pytest/_version.py"
# keep writing _version.py into the checkout: running pytest from a source
# tree relies on it. The setuptools-scm default flips in a future major.
write_to_source = true

[tool.black]
# See https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#t-target-version
Expand Down