Skip to content

Conversation

@chrisnovakovic
Copy link
Contributor

The please_pex tool depends on various third-party modules for the built-in test runner bootstraps, which in turn require please_pex in order to be built. This circular dependency prevents the plugin from being built entirely from source - see #265.

The root cause of this circular dependency is the presence of the entry points in //third_party/python:{behave,pytest} - python_wheel doesn't require please_pex per se, but the use of the binary or entry_points parameters results in python_binary being used to build the outputs, which does require please_pex in order to make them executable. The entry points aren't actually necessary on these targets, though, because the generated .pex files aren't executed directly - they are just unzipped and concatenated onto the please_pex binary to form the bootstrap archive containing the built-in test runners and their transitive dependencies.

Remove the entry_points parameters from the behave and pytest targets, and refactor the //tools/please_pex dependency tree so that the test runners and all of their transitive dependencies are present when the bootstrap archive is concatenated onto the main please_pex binary.

The bootstrap archive's contents remain the same, with the following omissions:

  • .bootstrap/plz.py
    • This is written by please_pex when creating an executable .pex - its presence isn't meaningful or required in the bootstrap archive.
  • .bootstrap/py/_vendored_packages/apipkg-2.0.0.dist-info/__init__.py
  • .bootstrap/py/_vendored_packages/iniconfig-1.1.1.dist-info/__init__.py
    • These empty files were created by please_pex when creating the executable .pex for pytest - their presence isn't meaningful or required in the bootstrap archive.

Fixes #265.

The please_pex tool depends on various third-party modules for the
built-in test runner bootstraps, which in turn require please_pex in
order to be built. This circular dependency prevents the plugin from
being built entirely from source - see please-build#265.

The root cause of this circular dependency is the presence of the entry
points in `//third_party/python:{behave,pytest}` - `python_wheel`
doesn't require please_pex per se, but the use of the `binary` or
`entry_points` parameters results in `python_binary` being used to build
the outputs, which does require please_pex in order to make them
executable. The entry points aren't actually necessary on these targets,
though, because the generated .pex files aren't executed directly - they
are just unzipped and concatenated onto the please_pex binary to form
the bootstrap archive containing the built-in test runners and their
transitive dependencies.

Remove the `entry_points` parameters from the behave and pytest targets,
and refactor the `//tools/please_pex` dependency tree so that the test
runners and all of their transitive dependencies are present when the
bootstrap archive is concatenated onto the main please_pex binary.

The bootstrap archive's contents remain the same, with the following
omissions:

- `.bootstrap/plz.py`
  - This is written by please_pex when creating an executable .pex - its
    presence isn't meaningful or required in the bootstrap archive.
- `.bootstrap/py/_vendored_packages/apipkg-2.0.0.dist-info/__init__.py`
- `.bootstrap/py/_vendored_packages/iniconfig-1.1.1.dist-info/__init__.py`
  - These empty files were created by please_pex when creating the
    executable .pex for pytest - their presence isn't meaningful or
    required in the bootstrap archive.

Fixes please-build#265.
@chrisnovakovic chrisnovakovic merged commit db0a777 into please-build:master Oct 27, 2025
41 of 42 checks passed
@chrisnovakovic chrisnovakovic deleted the please_pex-no-circular-dep branch October 27, 2025 16:14
chrisnovakovic added a commit to chrisnovakovic/python-rules that referenced this pull request Oct 27, 2025
The circular dependency between please_pex and its bootstrap archive
was broken in please-build#266, allowing for the plugin to be configured to use
`//tools_please_pex` as its own pex tool. This is simpler than building
the please_pex binary in one step, copying it elsewhere in the file
system for persistence, then configuring future steps to use that binary
as the pex tool.
chrisnovakovic added a commit that referenced this pull request Oct 27, 2025
The circular dependency between please_pex and its bootstrap archive
was broken in #266, allowing for the plugin to be configured to use
`//tools/please_pex` as its pex tool. This is simpler than building the
please_pex binary in one step, copying it elsewhere in the file system
for persistence, then configuring future steps to use that binary as the
pex tool.
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.

please_pex and test framework targets are mutually dependent

2 participants