Skip to content

Add static version to setup.cfg (unblock Windows build of 3.1.0+security.1) - #2

Merged
icanhasmath merged 1 commit into
3.1.0.xfrom
static-version-for-windows-build
Aug 26, 2026
Merged

icanhasmath merged 1 commit into
3.1.0.xfrom
static-version-for-windows-build

Conversation

@icanhasmath

Copy link
Copy Markdown
Collaborator

Problem

The AS Windows build of ingredient filelock 3.1.0.1 fails on windows-2025-msvc-builder:

Copying src\filelock.egg-info to build\...\filelock-0.0.0-py2.7.egg-info
Created wheel in ...\filelock-0.0.0-py2.py3-none-any.whl
Builder Error Message: Distribution name and/or version could not be determined.

0.0.0 is distutils' get_version() fallback for version is None. filelock 3.1.0 declares its version nowhere statically โ€” it comes solely from setuptools_scm's finalize_distribution_options hook (infer_version), driven by [tool.setuptools_scm]. That hook does not run on this builder, and infer_version swallows every failure (except Exception: return trace_exception()), so the version silently stays None and ActiveStateWheel/steps.py rejects the resulting wheel.

Two things that do not fix it, both ruled out empirically:

  • Shipping an sdist โ€” we already do; the build consumes our filelock-3.1.0+security.1.tar.gz (sha256 a582574โ€ฆ, byte-identical to the release asset) with a correct root PKG-INFO. Plain setuptools never reads an sdist's PKG-INFO for the version; only setuptools_scm's PKG-INFO fallback parser does, and that lives behind the dead hook.
  • SETUPTOOLS_SCM_PRETEND_VERSION โ€” tried on build 2 (4ef58fcc, --env-var=SETUPTOOLS_SCM_PRETEND_VERSION=3.1.0). Still filelock-0.0.0. The env var is read inside _do_parse, which is also behind the hook.

Not filelock-specific: the pristine PyPI sdist of backports.functools_lru_cache 1.6.6 fails identically on the same builder image (8d62bf93), while an otherwise-identical Windows build of it succeeds (f11ceddc). Worth a platform ticket of its own โ€” this breaks any setuptools_scm + pyproject-only package there.

Fix

One line: a static version in setup.cfg [metadata], which plain setuptools reads with no scm, no toml, and no cooperation from the builder.

setuptools_scm is deliberately kept in pyproject.toml โ€” removing it also removes its git file-finder, which shrinks the sdist from 586KB to 8KB (dropping tests/, docs/, example/).

Verification

Rebuilt sdist, extracted with no .git, on 2.7.18:

condition setup.py --version
setuptools_scm absent 3.1.0+security.1
setuptools_scm 5.0.2 active 3.1.0+security.1
scm active, toml unimportable 3.1.0+security.1

Both paths converge because scm's PKG-INFO fallback reads back the same string it wrote.

  • Wheel built with no scm on the path: filelock-3.1.0+security.1-py2.py3-none-any.whl โ€” clears the builder's parts[1] == "0.0.0" gate.
  • filelock.__version__ == '3.1.0+security.1'; _is_reparse_point (CVE-2025-68146 fix) present.
  • 25/25 tests pass on 2.7.18 โ€” matches the release baseline.
  • Sdist: 586086 B vs 585971 B, same 43 members.

No version change, no behaviour change: 3.1.0+security.1 is unaffected, as are the virtualenv pin, Jira DE-8131, and the CVE override rows.

๐Ÿค– Generated with Claude Code

The AS Windows builder (windows-2025-msvc-builder) does not run
setuptools_scm's finalize_distribution_options hook, so filelock's
version -- which had no static declaration anywhere -- silently fell
back to distutils' 0.0.0 and the wheel was rejected with
"Distribution name and/or version could not be determined".

setuptools_scm's PKG-INFO fallback and SETUPTOOLS_SCM_PRETEND_VERSION
both live behind that hook, so neither an sdist nor an env var can
recover the version there. A static version in setup.cfg is read by
plain setuptools with no scm involvement at all; where the hook does
run it resolves to the same string, so both paths agree.
@icanhasmath
icanhasmath merged commit 7330a81 into 3.1.0.x Aug 26, 2026
@icanhasmath
icanhasmath deleted the static-version-for-windows-build branch August 26, 2026 14:21
icanhasmath added a commit that referenced this pull request Nov 5, 2026
โ€ฆr hard-linked onto the lock path) (#3)

* CVE-2026-112909 Don't truncate a file renamed or hard-linked onto the lock path

GHSA-69hj-f68j-2879: UnixFileLock opened the lock file with
O_RDWR | O_CREAT | O_TRUNC. O_NOFOLLOW (the CVE-2025-68146 fix) refuses a
symlink, but not a regular file that another local user renames or
hard-links onto the lock path while the lock file does not exist. The lock
user's next acquire then emptied that file -- under every name it has --
with the lock user's privileges. Because O_TRUNC is applied by open(), even
an attempt that went on to lose the flock truncated the file.

Backport the upstream 4.2.1 fix (tox-dev#835, e1e825b), adapted to
this 3.1.0 single-module layout: open without O_TRUNC, so an existing file
is locked as found. The lock never stores data in the file, so nothing
depended on the truncation.

The advisory's second half -- fchmod of the found file to an explicit
`mode` -- does not apply: 3.1.0 has no `mode` parameter (added in 3.10.0)
and never chmods the lock file.

WindowsFileLock opened with O_TRUNC too in 3.1.0, so drop it there as
well (same reasoning; Windows lets a user rename or hard-link a file into a
shared directory). SoftFileLock opens with O_EXCL, which refuses an existing
path, so it never truncated a found file; left unchanged.

Regression tests (both lock types): a file renamed onto the lock path, a
file hard-linked onto it, and a holder's lock file seen by a losing
contender all keep their content. Py2.7-safe: no new syntax or imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Ship src/filelock/version.py as a tracked static file

Since the static setup.cfg version (#2), setuptools_scm sees the version
already set ("version of filelock already set"), skips version inference,
and so never runs its write_to step. The generated, gitignored
src/filelock/version.py is then missing from a clean checkout's sdist and
wheel, while filelock/__init__.py does `from .version import version`:
a wheel built from the 3.1.0+security.1 tag in a fresh clone fails with
"ModuleNotFoundError: No module named 'filelock.version'".

Track version.py with the static version (kept in step with setup.cfg),
un-ignore it, and drop write_to so setuptools_scm never overwrites it. No
setuptools_scm hook is needed for either value, which keeps the Windows
builder (which does not run that hook) working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Release 3.1.0.post2: fix CVE-2026-112909

Set the static version in setup.cfg and src/filelock/version.py to
3.1.0.post2 (PEP 440 post-release; the line moves from the +security.N
scheme to .postN) and add CHANGELOG.md recording every advisory's status on
the 3.1.0 line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant