Skip to content

Ship C sources and version.mk in the python sdist - #255

Merged
manugarg merged 3 commits into
mainfrom
fix/py-sdist-missing-sources
Aug 22, 2026
Merged

Ship C sources and version.mk in the python sdist#255
manugarg merged 3 commits into
mainfrom
fix/py-sdist-missing-sources

Conversation

@manugarg

Copy link
Copy Markdown
Owner

Fixes #254

The sdist built from src/pymod only contained pacparser_py.c and pacparser/init.py, so building it from source always failed:

  • pacparser_py.c:22 includes pacparser.h, which was not in the tarball
  • linking _pacparser needs pacparser.o and quickjs/libquickjs.a, which were also missing

Changes:

  • The sdist command now copies pacparser.h, pacparser.c, pac_utils.h and the quickjs sources into the archive before building it
  • A version.mk pinning the current version is written into the sdist (there is no git metadata there). pacparser_version() reads it, so the version no longer falls back to 1.0.0 when building from the sdist. This also resolves the mismatched wheel metadata from Broken metadata: 1.3.9..1.5.1 versions #253
  • When no prebuilt objects are present, setup.py compiles quickjs/libquickjs.a and pacparser.o from the shipped sources (using the compiler from sysconfig)
  • setup.py clean removes the copied C sources again
  • MANIFEST.in includes the new files and lists pacparser/init.py explicitly, so a prebuilt _pacparser .so can no longer end up in the sdist

Verified:

  • make -C src and make -C src pymod: all C and Python tests pass
  • Built the sdist, extracted it to a clean directory without git, pip wheel succeeds, the installed wheel parses tests/proxy.pac correctly and reports the pinned version
  • The CI cibuildwheel sequence (clean, copy sources, build) still works

The sdist built from src/pymod only contained pacparser_py.c and
pacparser/__init__.py, so building it from source failed: pacparser.h
was missing for compilation, and pacparser.o/libquickjs.a for linking.

The sdist command now copies pacparser.h, pacparser.c, pac_utils.h and
the quickjs sources into the archive and writes a version.mk pinning
the version (there is no git metadata in an sdist). When no prebuilt
objects are present, setup.py compiles them from the shipped sources.

This also fixes the version falling back to 1.0.0 when building the
sdist, which produced mismatched wheel metadata.
make clean removes pacparser.o before running setup.py clean --all,
which made the missing-objects check try to compile the sdist sources
that do not exist in the source tree. Require the copied pacparser.c
to be present before building the objects from source.
Only compile the C objects from source for commands that build the
extension (build, build_ext, bdist, bdist_wheel, install), so that
plain sdist/egg_info runs in the copied-sources layout do not require
a C toolchain.

clean --all now also removes pacparser.o and skips the copied-source
removal under --dry-run.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@manugarg
manugarg merged commit 1201d82 into main Aug 22, 2026
29 of 30 checks passed
@manugarg
manugarg deleted the fix/py-sdist-missing-sources branch August 30, 2026 00:20
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.

Missing pacparser.h from python dist

1 participant