Skip to content

Commit db0a777

Browse files
Break mutual dependency between please_pex and test runners (#266)
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.
1 parent d584c6e commit db0a777

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

third_party/python/BUILD

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ python_wheel(
232232
"_pytest",
233233
"pytest",
234234
],
235-
entry_points = "pytest:main",
236235
hashes = ["1d881c6124e08ff0a1bb75ba3ec0bfd8b5354a01c194ddd5a0a870a48d99b002"],
237236
licences = ["MIT"],
238237
version = "7.4.2",
@@ -271,10 +270,6 @@ python_wheel(
271270
outs = [
272271
"behave",
273272
],
274-
entry_points = {
275-
"behave": "behave.__main__:main",
276-
"behave_test": "setuptools_behave:behave_test",
277-
},
278273
hashes = ["ebda1a6c9e5bfe95c5f9f0a2794e01c7098b3dde86c10a95d8621c5907ff6f1c"],
279274
licences = ["BSD-2-Clause"],
280275
version = "1.2.6",
@@ -417,31 +412,31 @@ python_wheel(
417412

418413
# This is the minimum set of third-party packages required for the built-in test runners to work
419414
# with "plz test" and "plz cover". All built-in test runners should include this as a source.
420-
filegroup(
415+
python_library(
421416
name = "test_bootstrap",
422417
deps = [
423418
":coverage",
424419
":portalocker",
425420
],
426421
)
427422

428-
filegroup(
423+
python_library(
429424
name = "unittest_bootstrap",
430425
deps = [
431426
":test_bootstrap",
432427
":xmlrunner",
433428
],
434429
)
435430

436-
filegroup(
431+
python_library(
437432
name = "pytest_bootstrap",
438433
deps = [
439434
":pytest",
440435
":test_bootstrap",
441436
],
442437
)
443438

444-
filegroup(
439+
python_library(
445440
name = "behave_bootstrap",
446441
deps = [
447442
":behave",

tools/please_pex/BUILD

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,30 @@ go_binary(
2222
genrule(
2323
name = "please_pex",
2424
srcs = {
25-
"bootstraps": [
26-
"//third_party/python:coverage",
27-
"//third_party/python:portalocker",
28-
"//third_party/python:pytest",
29-
"//third_party/python:xmlrunner",
30-
"//third_party/python:behave",
31-
],
3225
"main": [":pex_main"],
3326
},
3427
outs = ["please_pex"],
3528
binary = True,
3629
cmd = [
37-
'for i in $SRCS_BOOTSTRAPS; do if echo "$i" | grep -q \'\\.pex$\'; then "$TOOL" x -o . "$i"; rm -f "$i"; fi; done',
30+
'for i in third_party/python/*.pex.zip; do "$TOOL" x -o . "$i"; rm -f "$i"; done',
3831
"rm -f third_party/python/__*_main__.py*",
3932
# Have to make sure these exist.
4033
"touch third_party/__init__.py third_party/python/__init__.py",
4134
"touch tools/__init__.py tools/please_pex/__init__.py",
35+
"mkdir -p .bootstrap",
4236
"mv third_party/python/* .bootstrap",
4337
# A little cleanup.
4438
"rm -rf third_party .bootstrap/xmlrunner/extra .bootstrap/coverage/htmlfiles .bootstrap/.*.pex.zip",
4539
'"$TOOL" z -d -i .bootstrap -o "$OUTS" --preamble_file $(location :pex_main)',
4640
],
41+
needs_transitive_deps = True,
4742
tools = [CONFIG.ARCAT_TOOL],
4843
visibility = ["PUBLIC"],
44+
deps = [
45+
"//third_party/python:behave_bootstrap",
46+
"//third_party/python:pytest_bootstrap",
47+
"//third_party/python:unittest_bootstrap",
48+
],
4949
)
5050

5151
python_test(

0 commit comments

Comments
 (0)