Skip to content

setup.py: only link objects built inside the build tree - #269

Merged
manugarg merged 4 commits into
mainfrom
harden-sdist-objects
Nov 10, 2026
Merged

manugarg merged 4 commits into
mainfrom
harden-sdist-objects

Conversation

@manugarg

@manugarg manugarg commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

When building from an unpacked sdist, setup.py searched the parent directory for pacparser.o (and pacparser.h via include_dirs) and used whatever it found. That directory is outside the package. For pip install ./pacparser-x.tar.gz it is $TMPDIR itself, since pip unpacks local sdists to $TMPDIR/pip-req-build-*.

Changes:

  • When the C sources are next to setup.py (an unpacked sdist, or the cibuildwheel build, which copies them in), compile and link only ./pacparser.o and ./quickjs/libquickjs.a, and include only ..
  • The source-tree build (make -C src pymod) still uses the Makefile's objects in src/. The separate Windows override is removed because it now matches the default.
  • quickjs/libquickjs.a in src/Makefile now depends on quickjs.c and quickjs.h, so a stale archive gets rebuilt.
  • SECURITY.md: document what is in and out of scope for security reports.

Testing:

  • NO_INTERNET=1 make -C src, make -C src pymod, and tests/test_sdist_metadata.py pass.
  • pip install -v --no-binary pacparser ./pacparser-1.0.0.tar.gz with junk pacparser.o, pacparser.h, and quickjs/libquickjs.a planted in $TMPDIR: before this change the link used ../pacparser.o; after it, the link uses the local objects and the module imports fine.

When building from an unpacked sdist, setup.py looked for pacparser.o and
pacparser.h in the parent directory and linked/included whatever it found
there. That directory is outside the package (for pip installs of a local
sdist it is $TMPDIR itself), so in the sdist layout only use objects and
headers from the build tree, compiled from the shipped sources.

Detect the sdist layout by its generated PKG-INFO, drop the redundant
Windows object override, and make the libquickjs.a Makefile rule depend
on the QuickJS sources so a stale archive is rebuilt.

Also document the scope of security reports in SECURITY.md.
The cibuildwheel build copies the C sources into src/pymod and builds
the objects there, but has no PKG-INFO, so it was treated as the source
tree and linked against ../pacparser.o.
ubuntu-latest is now Ubuntu 26.04, for which actions/setup-python has no
Python 3.8 or 3.9 builds. Linux wheels for those versions are still
built by cibuildwheel.
@sonarqubecloud

Copy link
Copy Markdown

@manugarg
manugarg merged commit 4393598 into main Nov 10, 2026
28 checks passed
@manugarg
manugarg deleted the harden-sdist-objects branch November 10, 2026 05:54
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