Skip to content

fix(packaging): keep the wheel to an explicit product allowlist - #317

Merged
Zongwei9888 merged 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/dist-package-allowlist
Nov 23, 2026
Merged

Zongwei9888 merged 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/dist-package-allowlist

Conversation

@raymondginger2018-sudo

Copy link
Copy Markdown
Contributor

Summary

setuptools.find_packages() enumerates the working tree, not the tracked files, so
ignored experiments or local helper directories at the repository root can end up in a
wheel. This pins the release surface explicitly and asserts the same list against the
built wheel.

Changes

  • setup.py: replace find_packages(exclude=...) with
    find_packages(include=PRODUCT_PACKAGES).
  • scripts/verify_python_distribution.py: add PRODUCT_TOP_LEVEL_PACKAGES and
    verify_wheel_packages(), called from verify_artifacts() on the wheel namelist.
  • tests/test_python_distribution_release.py: two cases - a product package is
    accepted, a working-tree experiment is rejected.

The published surface does not change

The allowlist reproduces exactly what the previous exclude-based call selected on this
checkout: find_packages(exclude=...) -> 40 packages,
find_packages(include=...) -> 40 packages, set difference empty in both directions.

Tests

  • pytest tests/test_python_distribution_release.py -q -> 15 passed
  • local CI replay run-ci-jobs.sh package (COMPARE_FROM=80634442) ->
    build_rc=0 twine_rc=0 verify_rc=0: the wheel was built and the verifier (including
    the new check) ran and passed
  • ruff pinned to this repo's pre-commit rev (0.15.21): check clean,
    format --check clean
  • positive/negative control on verify_wheel_packages: product package accepted,
    quant_trading/ rejected with the allowlist error

NOT RUN

  • Full local preflight. The full local pytest suite needs ~83 minutes on my machine
    while the harness caps the test leg at 2400s, so it can only ever end as rc=124.
    I did not want to present a truncated run as a verdict; upstream CI is the
    authoritative gate for this revision.
  • desktop/bundle are out of scope for this diff: scripts/ci_scope.py reports
    desktop_changed=false (with runtime_changed=true).

setuptools.find_packages() enumerates the working tree rather than the
tracked files, so ignored experiments or local helper directories at the
repository root can enter a wheel. Pin the release surface with an
include allowlist in setup.py, and assert the same list against the built
wheel in scripts/verify_python_distribution.py.

The allowlist reproduces exactly what the previous exclude-based call
selected (40 packages, identical set on this checkout), so the published
surface does not change for a clean tree.

Tests: tests/test_python_distribution_release.py - 15 passed, plus a
positive/negative control on verify_wheel_packages (product package
accepted, working-tree experiment rejected).
@Zongwei9888
Zongwei9888 merged commit 8e78a7a into HKUDS:main Nov 23, 2026
12 checks passed
@Zongwei9888

Copy link
Copy Markdown
Contributor

Thanks @raymondginger2018-sudo, merged on 2026-11-23 as 8e78a7a. We built wheels from main and from the merge, and both contain the same 439 files.

One follow-up (a5da104):

  • find_packages include patterns are fnmatch patterns, so "core*" also matched a sibling such as core_experiments, which the new wheel check would then reject. Packages are now listed by name, each with its subpackages (name, name.*).
  • A test checks that setup.py and scripts/verify_python_distribution.py list the same packages, so the two lists cannot drift.

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.

2 participants