Skip to content

fix(pypi): generate namespace package initializers without a shell - #4385

Merged
aignas merged 2 commits into
bazel-contrib:mainfrom
tamird:pypi-namespace-template
Oct 31, 2026
Merged

aignas merged 2 commits into
bazel-contrib:mainfrom
tamird:pypi-namespace-template

Conversation

@tamird

@tamird tamird commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Wheel namespace packages use an init.py file generated from a
checked-in template. Skylib's copy_file invokes cp through a shell on
Unix, which fails on execution platforms that provide neither program.

Use expand_template with no substitutions. This produces a regular
file with the same bytes from the same template, without spawning a
process on the execution platform.

The namespace initializer generator was introduced in
dce512024.

Wheel namespace packages use an __init__.py file generated from a
checked-in template. Skylib's copy_file invokes cp through a shell on
Unix, which fails on execution platforms that provide neither program.

Use expand_template with no substitutions. This produces a regular
file with the same bytes from the same template, without spawning a
process on the execution platform.

The namespace initializer generator was introduced in
bazel-contrib@dce512024.
Copilot AI balanced review requested due to automatic review settings October 30, 2026 14:46
@tamird

tamird commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Codex prepared this change on behalf of @tamird. Tamir chose the approach
after comparing it with using a declared coreutils binary. I’ll monitor
this PR for feedback and bring substantive revisions and proposed replies
to Tamir for review before posting them.

This is an automatically generated agent comment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the change removing shell and cp requirements from namespace initializer generation.

No open issues 🎉

What changed in this PR

This PR removes the shell and cp requirement from wheel namespace initializer generation, allowing it to work on execution platforms without those programs.

Changes:

  • Replace Skylib’s copy_file with expand_template using no substitutions to preserve template contents.
  • Update the rule dependency and unit-test expectations.
  • Add a release note describing the fix.
File Description
tests/​pypi/​namespace_pkgs/​namespace_pkgs_tests.bzl Update mocked generator calls and expected template arguments.
python/​private/​pypi/​namespace_pkgs.bzl Generate namespace initializers with expand_template.
python/​private/​pypi/​BUILD.bazel Switch the dependency to Skylib’s expand_template.
news/​wheel-namespace-initializers.fixed.md Document removal of the shell and cp requirement.

Review effort: Balanced

@aignas aignas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aignas
aignas added this pull request to the merge queue Oct 31, 2026
Merged via the queue into bazel-contrib:main with commit 9485832 Oct 31, 2026
13 checks passed
@tamird
tamird deleted the pypi-namespace-template branch October 31, 2026 01:51
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.

3 participants