Skip to content

Commit

Permalink
Always include interpreter constraints in PEXes. (#11733)
Browse files Browse the repository at this point in the history
Previously we left them off for internal only PEXes. Leaving them in
does no harm since PEX uses the current interpreter if it matches
constraints and it aids in the debugability of process chroots.

Also work around Xcode 12.x Python interpreter issues hit in CI. These
interpreters have a bad `-arch arm64` flag on intel that leads to
compile errors for psutil.

See: giampaolo/psutil#1832
  • Loading branch information
jsirois authored Mar 19, 2021
1 parent 7a6a8df commit 43007bd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ jobs:
- 3.8.3
test_python_macos:
env:
ARCHFLAGS: -arch x86_64
PANTS_CONFIG_FILES: +['pants.ci.toml', 'pants.remote-cache.toml']
name: Test Python (MacOS)
needs: bootstrap_pants_macos
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ jobs:
- 3.7.10
test_python_macos:
env:
ARCHFLAGS: -arch x86_64
PANTS_CONFIG_FILES: +['pants.ci.toml', 'pants.remote-cache.toml']
name: Test Python (MacOS)
needs: bootstrap_pants_macos
Expand Down
7 changes: 6 additions & 1 deletion build-support/bin/generate_github_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ def test_workflow_jobs(python_versions: Sequence[str]) -> Jobs:
"runs-on": "macos-10.15",
"needs": "bootstrap_pants_macos",
"strategy": {"matrix": {"python-version": python_versions}},
"env": {**pants_config_files()},
"env": {
# Works around bad `-arch arm64` flag embedded in Xcode 12.x Python interpreters on
# intel machines. See: https://github.com/giampaolo/psutil/issues/1832
"ARCHFLAGS": "-arch x86_64",
**pants_config_files(),
},
"steps": [
{"name": "Check out code", "uses": "actions/checkout@v2"},
*setup_primary_python(),
Expand Down
7 changes: 7 additions & 0 deletions pants.ci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ ci_env_variables = [

[buildsense]
enable = true

[subprocess-environment]
env_vars.add = [
# Works around bad `-arch arm64` flag embedded in Xcode 12.x Python interpreters on intel
# machines. See: https://github.com/giampaolo/psutil/issues/1832
"ARCHFLAGS",
]
4 changes: 1 addition & 3 deletions src/python/pants/backend/python/util_rules/pex.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,14 @@ async def build_pex(
# constraints.
argv.extend(request.platforms.generate_pex_arg_list())
else:
argv.extend(request.interpreter_constraints.generate_pex_arg_list())
# NB: If it's an internal_only PEX, we do our own lookup of the interpreter based on the
# interpreter constraints, and then will run the PEX with that specific interpreter. We
# will have already validated that there were no platforms.
# Otherwise, we let Pex resolve the constraints.
if request.internal_only:
python = await Get(
PythonExecutable, PexInterpreterConstraints, request.interpreter_constraints
)
else:
argv.extend(request.interpreter_constraints.generate_pex_arg_list())

argv.append("--no-emit-warnings")

Expand Down

0 comments on commit 43007bd

Please sign in to comment.