Hi folks, I could use some help figuring out how t...
# general
f
Hi folks, I could use some help figuring out how to debug an issue. My team is using pants, and some of our newer employees have had trouble running the coverage tool. We’re using pants 2.10.0 on python 3.9, which everyone is installing via pyenv. We are all on the same M1 macbook pros at the same OS version. We’re using the default lockfile for coverage and pytest. The relevant section of the pants.toml is:
Copy code
[test]
use_coverage = true

[pytest]
args = ["--no-header", "-vv", "--log-cli-level", "INFO"]

[coverage-py]
report = ["html", "xml", "console"]
config="tooling_configs/.coveragerc"
When they run
./pants test
on a python tests target, pytest runs successfully, and then crashes trying to build the coverage pex:
Copy code
11:08:42.69 [INFO] Completed: Run Pytest - src/stages/qc_metrics/tests/test_qc_math.py:../tests succeeded.
11:08:42.70 [INFO] Completed: Run Pytest - src/stages/qc_metrics/tests/test_qc_metrics.py:../tests succeeded.

✓ src/stages/qc_metrics/tests/test_qc_math.py:../tests succeeded in 4.91s (memoized).
✓ src/stages/qc_metrics/tests/test_qc_metrics.py:../tests succeeded in 18.90s (memoized).

Wrote test XML to `dist/test_results`
11:08:46.73 [INFO] Completed: Building coverage.pex from coverage-py_default_lockfile.txt
11:08:46.73 [ERROR] 1 Exception encountered:

  ProcessExecutionFailure: Process 'Building coverage.pex from coverage-py_default_lockfile.txt' failed with exit code 1.
stdout:
(see thread for more)
It’s very odd that it’s looking for cp38, since we are on 3.9. 3.8 is the system default. And, I don’t have this problem personally, it’s only shown up for two people, but it’s consistently reproducible for them. They’ve already tried clearing the ~/.cache/pants directory to no effect. Does anyone know anything about this, or have an idea how we could go about debugging it further? Any help appreciated.
1
Moving the longer output to the thread to avoid clogging up the channel
Copy code
stderr:
Traceback (most recent call last):
  File "/Users/redacted/.cache/pants/named_caches/pex_root/unzipped_pexes/3c037481d92e64c70b4c4d598b63e24e6c2bb819/.bootstrap/pex/pex.py", line 503, in execute
    exit_value = self._wrap_coverage(self._wrap_profiling, self._execute)
  File "/Users/redacted/.cache/pants/named_caches/pex_root/unzipped_pexes/3c037481d92e64c70b4c4d598b63e24e6c2bb819/.bootstrap/pex/pex.py", line 408, in _wrap_coverage
    return runner(*args)
  File "/Users/redacted/.cache/pants/named_caches/pex_root/unzipped_pexes/3c037481d92e64c70b4c4d598b63e24e6c2bb819/.bootstrap/pex/pex.py", line 439, in _wrap_profiling
    return runner(*args)
  File "/Users/redacted/.cache/pants/named_caches/pex_root/unzipped_pexes/3c037481d92e64c70b4c4d598b63e24e6c2bb819/.bootstrap/pex/pex.py", line 559, in _execute
    return self.execute_entry(self._pex_info.entry_point)
  File "/Users/redacted/.cache/pants/named_caches/pex_root/unzipped_pexes/3c037481d92e64c70b4c4d598b63e24e6c2bb819/.bootstrap/pex/pex.py", line 695, in execute_entry
    return self.execute_pkg_resources(entry_point)
  File "/Users/redacted/.cache/pants/named_caches/pex_root/unzipped_pexes/3c037481d92e64c70b4c4d598b63e24e6c2bb819/.bootstrap/pex/pex.py", line 727, in execute_pkg_resources
    return runner()
  File "/Users/redacted/.cache/pants/named_caches/pex_root/installed_wheels/9fb4bc59f7085c6133bed415fd8806a166d6f472798f2350158f7f0a710ec0f6/pex-2.1.71-py2.py3-none-any.whl/pex/bin/pex.py", line 724, in main
    do_main(
  File "/Users/redacted/.cache/pants/named_caches/pex_root/installed_wheels/9fb4bc59f7085c6133bed415fd8806a166d6f472798f2350158f7f0a710ec0f6/pex-2.1.71-py2.py3-none-any.whl/pex/bin/pex.py", line 770, in do_main
    seed_info = seed_cache(options, pex, verbose=options.seed == Seed.VERBOSE)
  File "/Users/redacted/.cache/pants/named_caches/pex_root/installed_wheels/9fb4bc59f7085c6133bed415fd8806a166d6f472798f2350158f7f0a710ec0f6/pex-2.1.71-py2.py3-none-any.whl/pex/bin/pex.py", line 808, in seed_cache
    venv_pex = ensure_venv(pex)
  File "/Users/redacted/.cache/pants/named_caches/pex_root/installed_wheels/9fb4bc59f7085c6133bed415fd8806a166d6f472798f2350158f7f0a710ec0f6/pex-2.1.71-py2.py3-none-any.whl/pex/pex_bootstrapper.py", line 461, in ensure_venv
    shebang = populate_venv(
  File "/Users/redacted/.cache/pants/named_caches/pex_root/installed_wheels/9fb4bc59f7085c6133bed415fd8806a166d6f472798f2350158f7f0a710ec0f6/pex-2.1.71-py2.py3-none-any.whl/pex/venv/pex.py", line 121, in populate_venv
    record_provenance(_populate_deps(venv, pex, venv_python, symlink))
  File "/Users/redacted/.cache/pants/named_caches/pex_root/installed_wheels/9fb4bc59f7085c6133bed415fd8806a166d6f472798f2350158f7f0a710ec0f6/pex-2.1.71-py2.py3-none-any.whl/pex/venv/pex.py", line 117, in record_provenance
    for src, dst in src_to_dst:
  File "/Users/redacted/.cache/pants/named_caches/pex_root/installed_wheels/9fb4bc59f7085c6133bed415fd8806a166d6f472798f2350158f7f0a710ec0f6/pex-2.1.71-py2.py3-none-any.whl/pex/venv/pex.py", line 205, in _populate_deps
    for dist in pex.resolve():
  File "/Users/redacted/.cache/pants/named_caches/pex_root/installed_wheels/9fb4bc59f7085c6133bed415fd8806a166d6f472798f2350158f7f0a710ec0f6/pex-2.1.71-py2.py3-none-any.whl/pex/pex.py", line 120, in resolve
    for dist in env.resolve():
  File "/Users/redacted/.cache/pants/named_caches/pex_root/installed_wheels/9fb4bc59f7085c6133bed415fd8806a166d6f472798f2350158f7f0a710ec0f6/pex-2.1.71-py2.py3-none-any.whl/pex/environment.py", line 495, in resolve
    for fingerprinted_distribution in self.resolve_dists(all_reqs)
  File "/Users/redacted/.cache/pants/named_caches/pex_root/installed_wheels/9fb4bc59f7085c6133bed415fd8806a166d6f472798f2350158f7f0a710ec0f6/pex-2.1.71-py2.py3-none-any.whl/pex/environment.py", line 519, in resolve_dists
    for qualified_req_or_not_found in self._root_requirements_iter(reqs):
  File "/Users/redacted/.cache/pants/named_caches/pex_root/installed_wheels/9fb4bc59f7085c6133bed415fd8806a166d6f472798f2350158f7f0a710ec0f6/pex-2.1.71-py2.py3-none-any.whl/pex/environment.py", line 460, in _root_requirements_iter
    raise ResolveError(message)
pex.environment.ResolveError: A distribution for coverage could not be resolved in this environment.Found 1 distribution for coverage that do not apply:
1.) The wheel tags for coverage 5.5 are cp38-cp38-macosx_10_14_arm64 which do not match the supported tags of /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/bin/python3.8:
e
@few-arm-93065 the simplest answer will be to configure Pants to use interpreter constraints of
==3.9.*
or
>=3.9
or some such to simply gloss over a host of issues with Mac system interpreters generally. But that only makes sense as a quick step if that sort of interpreter constraint actually makes sense for the code under developement.
If it does make sense I can point to more info on that config.
f
Hi John, thank you for the reply - sorry, I should have mentioned that in my original message. We are already doing that:
Copy code
[python]
interpreter_constraints = ["CPython==3.9.*"]
e
Ah, right - this issue is not for the code under development but the coverage tool; so that means ... just a sec ...
This is an unsatisfying answer for 2 reasons: + Whac-a-mole with interpreter constraints for different tools is a possibility and you'll have to do this again for another tool. + Using an interpreter constraint to route around Mac system interpreters won't always work - say you did need 3.8 support for example. That all said, it may work for you as a quick solution.
f
oh! I can’t believe I didn’t see that!
Thanks, I’ll have the team give it a try.
e
I think that may require also configuring https://www.pantsbuild.org/docs/reference-coverage-py#section-lockfile and re-generating a lockfile for coverage different from the one Pants ships with. But an error should prompt you in that direction.
f
Yup, that totally fixed it. I didn’t even have to make a custom lockfile for it. Thank you so much!