Hi, I'm not sure if I've found a bug, or I somehow...
# general
h
Hi, I'm not sure if I've found a bug, or I somehow misconfigure something. Subjects: Interpreter constraints. Details in 🧵.
When I run
pants package ::
, I get:
Copy code
14:55:09.31 [INFO] Initializing scheduler...
14:55:09.76 [INFO] Scheduler initialized.
14:55:21.90 [INFO] stdout: "environ({'PANTS_BIN_NAME': './pants'})"
14:55:21.90 [INFO] stdout: "environ({'PANTS_BIN_NAME': './pants'})"

14:55:21.90 [ERROR] 1 Exception encountered:

Engine traceback:
  in `package` goal
  in Resolve transitive targets
  in Resolve direct dependencies of target - package_a/package_a/main.py:../package-a-sources

InvalidFieldException: The target package_a/package_a/main.py:../package-a-sources has the `interpreter_constraints` ('==3.10.*',), which are not a subset of the `interpreter_constraints` of some of its dependencies:

  * ('>=3.9,<=3.10',): package_b/file_1.py:../../package-b-sources

To fix this, you should likely adjust package_a/package_a/main.py:../package-a-sources's `interpreter_constraints` to match the narrowest range in the above list.
My
pants.toml
has the line:
interpreter_constraints = ["CPython>=3.9,<=3.10"]
. Package A's BUILD file has the line:
python_sources(interpreter_constraints=["==3.10.*"],
. Package B's BUILD file has the line:
python_sources(interpreter_constraints=[">=3.9,<=3.10"],
. Did I misconfigured it?
Oh, and nothings depends on package A.
e
The message claims A depends on B and B's interpreter constraints conflict. Do you deny / dispute A does or should depend on B?
As an aside, the
>=3.9,<=3.10
constraints are odd. You must not mean
==3.9.*
though since you use that notation elsewhere in
==3.10.*
. What exactly are you trying to achieve with
>=3.9,<=3.10
?
h
A indeed depends on B.
>=3.9,<=3.10
is meant to mean
==3.9.* or ==3.10.*
. I have some packages that are 3.10 only and some that support both 3.9 and 3.10. Is there a different recommended way to support it?
e
Ok, well use
>=3.9,<3.11
the
<=3.10
was not doing what you hoped.
Ok, A depending on B is indeed the problem the error was trying to point out. Thinking on solutions...
What package does A belong to @high-magician-46188? A
pex_binary
or something else? Can you narrow down the
::
to the problematic target in other words?
h
Package A's
BUILD
file:
Copy code
python_sources(
    name="package-a-sources",
    sources=["paackage_a/**/*.py"],
    interpreter_constraints=[">=3.9,<=3.10"],
)

resource(name="pyproject", source="pyproject.toml")

python_distribution(
    name="package-a-dist-pure-wheel",
    dependencies=[
        ":pyproject",
        ":package-sources",
        # Dependencies on code to be packaged into the distribution.
    ],
    provides=python_artifact(
        name="package-a",
    ),
    wheel_config_settings={
        "--global-option": ["--python-tag", "py3"]
    },
    generate_setup=True,
    sdist=False,
    wheel=True,
)
I've done multiple experiments and I think that making it
3.9.0
and
3.10.999
in
pants.toml
fixed it. Should I submit it as a bug?
e
No, <=3.10 is just plain bad. Please use <3.11. I can explain more later.
h
Let me guess,
3.9 > 3.10
due to string comparison?
e
No
3.10 is expanded by the PyPAs packaging package to mean 3.10.0 and so <=3.10 only includes 3.10.0
This is not a Pants thing, it's a PyPA thing. If you were to experiment with packaging.version.Version in a repl you would learn a bit / be surprised.
In short there are ~0 real world situations in which you'll ever really mean to use <=, stick to <
h
🤦
thanks