I’d need some help understanding this error: ```pa...
# development
c
I’d need some help understanding this error:
Copy code
pants.engine.target.InvalidFieldException: The target testprojects/src/python/native:main has the `interpreter_constraints` ('==3.9.*',), which are not a subset of the `interpreter_constraints` of some of its dependencies:

  * ('==3.7.*',): testprojects/src/python/native/main.py:main_lib
  * ('==3.7.*',): testprojects/src/python/native:dist

To fix this, you should likely adjust testprojects/src/python/native:main's `interpreter_constraints` to match the narrowest range in the above list.
from https://github.com/pantsbuild/pants/actions/runs/5018907494/jobs/9008981047?pr=17671#step:8:346 for https://github.com/pantsbuild/pants/pull/17671
e
The 3.7.* pin is here: https://github.com/pantsbuild/pants/actions/runs/5018907494/jobs/9008981047?pr=17671#step:4:1 The 3.9.* pin is here: https://github.com/pantsbuild/pants/blob/main/testprojects/src/python/native/BUILD#L25 Your test is running under the former and it sees the latter (probably because visibility rules checks need to see whole repo)
c
Ah.. hmm.
The test itself doesn’t need to see the whole repo though… 🤔
thought the test was running in isolation with only the files added that I explicitly add with the RuleRunner instance
e
I don't understand Pants really, just pointing out the ~obvious bits.
👍 1
c
thanks yea, I’ll need to dig into that. realize I should be able to repro locally using that first pin you pointed at, thanks.
anything obvious here? in trying to line up the ICs for the testproject so all use
3.9.*
, I get another error:
Copy code
pants.engine.process.ProcessExecutionFailure: Process 'Find interpreter for constraints: CPython==3.7.*,==3.9.*' failed with exit code 102.
stdout:

stderr:
Could not find a compatible interpreter.

Examined the following interpreters:
1.)                                         /Users/andreas.stenius/.pyenv/versions/3.9.13/bin/python3.9 CPython==3.9.13
2.)                                        /Users/andreas.stenius/.pyenv/versions/3.11.1/bin/python3.11 CPython==3.11.1
3.)                                         /Users/andreas.stenius/.pyenv/versions/3.7.13/bin/python3.7 CPython==3.7.13
4.)                                         /Users/andreas.stenius/.pyenv/versions/3.8.13/bin/python3.8 CPython==3.8.13
5.)    /opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/bin/python3.11 CPython==3.11.3
6.)   /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/bin/python3.10 CPython==3.10.11
7.) /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9 CPython==3.9.6

No interpreter compatible with the requested constraints was found:

  Version matches CPython==3.7.*,==3.9.*



Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
Seems Pants tried to find an interpreter that would satisfy both 3.7 and 3.9 at the same time, which obviously is a futile endeavour.
Copy code
diff --git a/testprojects/src/python/native/BUILD b/testprojects/src/python/native/BUILD
index a224fb460f..cca8a17be3 100644
--- a/testprojects/src/python/native/BUILD
+++ b/testprojects/src/python/native/BUILD
@@ -1,6 +1,12 @@
 # Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
 # Licensed under the Apache License, Version 2.0 (see LICENSE).

+__defaults__(
+    all=dict(
+        interpreter_constraints=["==3.9.*"],
+    )
+)
+
 python_sources(name="lib", sources=["name.py", "setup.py"])

 resources(name="impl", sources=["*.c"])
@@ -22,5 +28,4 @@ pex_binary(
     name="main",
     entry_point="main.py",
     dependencies=[":dist", ":main_lib"],
-    interpreter_constraints=["==3.9.*"],
 )
Now running pants with:
Copy code
❯ export PY=python3.7
❯ export PANTS_PYTHON_INTERPRETER_CONSTRAINTS="['==3.7.*']"
wondering if this is a bug, or how else do we specify deviating ICs from the defaults for a part of the repo?
w
@curved-television-6568: the stack makes it look like:
check_visibility_rule_violations
->
resolve_dependencies
->
validate_python_dependencies
… is causing something to be checked that wasn’t before…? so possibly you exposed a bug in that validation?>
does it fail for
./pants dependencies testprojects/src/python/native:main
on your branch?
c
that works fine:
Copy code
❯ pants dependencies testprojects/src/python/native:main
There is no pantsd metadata at /Users/andreas.stenius/src/github/kaos/pants/.pids/f2b095de0b47/pantsd.
12:52:48.05 [INFO] waiting for pantsd to start...
12:52:48.78 [INFO] pantsd started
12:52:50.32 [INFO] Starting: Resolving plugins: hdrhistogram, toolchain.pants.plugin==0.27.0
12:53:11.22 [INFO] Completed: Resolving plugins: hdrhistogram, toolchain.pants.plugin==0.27.0
12:53:17.26 [INFO] Initializing scheduler...
12:53:27.81 [INFO] Scheduler initialized.
testprojects/src/python/native/main.py:main_lib
testprojects/src/python/native:dist
w
afaict, it shouldn’t.
c
(I’ve started to observe those pantsd metadata msgs since yesterday, haven’t had time to dig into that yet)
w
so that’s likely the bug.
(I’ve started to observe those pantsd metadata msgs since yesterday, haven’t had time to dig into that yet)
those are expected: the native client is used by default now on
main
👍 1
c
oh, ok
w
the message won’t render in production… should probably just remove it.
1
c
peeking the targets, they all present a consistent IC of:
Copy code
❯ pants peek testprojects/src/python/native/:: | grep -A 2 interpreter
    "interpreter_constraints": [
      "==3.9.*"
    ],
--
    "interpreter_constraints": [
      "==3.9.*"
    ],
--
    "interpreter_constraints": [
      "==3.9.*"
    ],
--
    "interpreter_constraints": [
      "==3.9.*"
    ],
--
    "interpreter_constraints": [
      "==3.9.*"
    ],
w
…oh. yea, but they won’t on that CI shard
c
really? I’ve setup the same env vars
PY and PANTS_PYTHON_INTERPRETER_CONSTRAINTS
w
that shard sets
3.7
, right?
c
yea
Copy code
❯ pants python --help-advanced | grep interpreter -A 20
  --python-interpreter-constraints="[<requirement>, <requirement>, ...]"
  PANTS_PYTHON_INTERPRETER_CONSTRAINTS
  interpreter_constraints
      default: []
      current value: [
          "==3.7.*"
      ] (from env var PANTS_PYTHON_INTERPRETER_CONSTRAINTS)
          overrode: [
              ">=3.7,<3.10"
          ] (from pants.toml)
oh, hmmm
Copy code
PANTS_PYTHON_RESOLVES_TO_INTERPRETER_CONSTRAINTS
  resolves_to_interpreter_constraints
      default: {}
      current value: {
          "python-default": [
              ">=3.7,<3.10"
          ]
      } (from pants.toml)
w
afaict,
./pants dependencies testprojects/src/python/native:main
should be failing with those global ICs, because you have a
3.9
target depending on two
3.7
targets. so the fact that it didn’t before your PR is a bug =(
c
aha..
but my attempt to make them all be 3.9 targets didn’t seem to bite
OK, I think I’m able to narrow this down slightly. If I attempt to
lint
a
python_sources
target with IC != default IC I hit this.
just to be clear,
pants dependencies
still doesn’t fail, only
lint
Copy code
❯ pants lint testprojects/src/python/native::
fails for me on
main
using the 3.7 shard setup.
ah, maybe cache issue, running without pantsd worked on
main
.