From 76362c81541992d5d50efc5f1cda1d17842e59e9 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Fri, 19 Mar 2021 09:37:11 -0700 Subject: [PATCH 1/2] Always include interpreter constraints in PEXes. Previously we left them off for internal only PEXes. Leaving them does no harm since PEX uses the current interpreter if it matches constraints and it aids in the debugability of process chroots. # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels] --- src/python/pants/backend/python/util_rules/pex.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/python/pants/backend/python/util_rules/pex.py b/src/python/pants/backend/python/util_rules/pex.py index ca6f649a1dd..58d0e97272b 100644 --- a/src/python/pants/backend/python/util_rules/pex.py +++ b/src/python/pants/backend/python/util_rules/pex.py @@ -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") From 6e7cfa85fec602a2cc0086a27e688edbb8c001c2 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Fri, 19 Mar 2021 09:39:06 -0700 Subject: [PATCH 2/2] Work around Xcode 12.x Python interpreter. The interpreter has a bad `-arch arm64` flag on intel that leads to compile errors for psutil. See: https://github.com/giampaolo/psutil/issues/1832 [ci skip-rust] [ci skip-build-wheels] --- .github/workflows/test-cron.yaml | 1 + .github/workflows/test.yaml | 1 + build-support/bin/generate_github_workflows.py | 7 ++++++- pants.ci.toml | 7 +++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-cron.yaml b/.github/workflows/test-cron.yaml index ffa55764cd7..fb1fd2f53c0 100644 --- a/.github/workflows/test-cron.yaml +++ b/.github/workflows/test-cron.yaml @@ -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 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d72f4456b16..f8bfebb030c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 diff --git a/build-support/bin/generate_github_workflows.py b/build-support/bin/generate_github_workflows.py index c9f732105c5..cee89398397 100644 --- a/build-support/bin/generate_github_workflows.py +++ b/build-support/bin/generate_github_workflows.py @@ -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(), diff --git a/pants.ci.toml b/pants.ci.toml index 0bd1a76a830..422f67da096 100644 --- a/pants.ci.toml +++ b/pants.ci.toml @@ -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", +]