flaky-artist-57016
07/02/2024, 7:45 PMpants test
? I have pinned numpy==1.26.4
in my requirements.txt
, but a test is failing with an error that indicates the test environment is using numpy>=2
. The numpy docs indicate that this error is only raised by numpy>=2
. The code in question transitively depends on numpy
by way of tensorflow
which is also pinned to tensorflow==2.11.0
in our requirements.txt
. Building a PEX that contains the module in question and interacting with it manually does not raise the same error.ancient-france-42909
07/02/2024, 8:11 PM--keep-sandboxes=always
flaky-artist-57016
07/02/2024, 8:42 PMtensorflow
because numpy
is not an explicit dependency of the code under test. By adding import numpy as np
to explicitly indicate a dependency on numpy
, it is built into the test PEX and the test passes.
It is not clear to me why/how an error message from Numpy v2 is being raised when it is not present in the environment and the distribution of tensorflow==2.11.0
I am using has not been updated since 2022. I will share a minimal repo that reproduces the error shortly in case it is of interest to anyone.ancient-france-42909
07/02/2024, 8:43 PMflaky-artist-57016
07/02/2024, 8:50 PMancient-france-42909
07/02/2024, 8:51 PMERROR: Could not find a version that satisfies the requirement tensorflow==2.11.0 (from versions: 2.13.0rc0, 2.13.0rc1, 2.13.0rc2, 2.13.0, 2.13.1, 2.14.0rc0, 2.14.0rc1, 2.14.0, 2.14.1, 2.15.0rc0, 2.15.0rc1, 2.15.0, 2.15.1, 2.16.0rc0, 2.16.1, 2.16.2, 2.17.0rc0, 2.17.0rc1)
ancient-france-42909
07/02/2024, 8:52 PMflaky-artist-57016
07/02/2024, 8:52 PMpants.toml
ancient-france-42909
07/02/2024, 8:52 PMflaky-artist-57016
07/02/2024, 8:53 PMancient-france-42909
07/02/2024, 8:54 PMflaky-artist-57016
07/02/2024, 8:55 PMimport numpy as np
to the problematic module so pants can infer the dependency and that workaround should be satisfactory for now.ancient-france-42909
07/02/2024, 8:55 PMflaky-artist-57016
07/02/2024, 8:55 PMancient-france-42909
07/02/2024, 8:56 PMancient-france-42909
07/02/2024, 8:58 PMflaky-artist-57016
07/02/2024, 8:58 PMancient-france-42909
07/02/2024, 8:59 PMancient-france-42909
07/02/2024, 8:59 PMancient-france-42909
07/02/2024, 8:59 PM__run.sh
, you'll see what it's doingancient-france-42909
07/02/2024, 9:00 PMflaky-artist-57016
07/02/2024, 9:00 PMtensorflow
requires numpy
. Unclear why that is 🤷ancient-france-42909
07/02/2024, 9:00 PMancient-france-42909
07/02/2024, 9:00 PMflaky-artist-57016
07/02/2024, 9:01 PMflaky-artist-57016
07/02/2024, 9:01 PMancient-france-42909
07/02/2024, 9:02 PMflaky-artist-57016
07/02/2024, 9:02 PMancient-france-42909
07/02/2024, 9:02 PMancient-france-42909
07/02/2024, 9:03 PMflaky-artist-57016
07/02/2024, 9:04 PMancient-france-42909
07/02/2024, 9:04 PMpip install tensorflow
, you don't say you want numpy
, but you get itflaky-artist-57016
07/02/2024, 9:04 PMancient-france-42909
07/02/2024, 9:05 PMflaky-artist-57016
07/02/2024, 9:19 PMtensorflow==2.11.0
requires numpy>=1.20
as shown here which means pip will use the latest available version of numpy
(v2+) which actually isn’t compatible.
This is similar to the chaos caused by the release of the Pydantic v2 release where consumers did not pin pydantic
to <2
. What fun.ancient-france-42909
07/02/2024, 9:20 PMconstraints.txt
will help you fix that.ancient-france-42909
07/02/2024, 9:22 PMflaky-artist-57016
07/02/2024, 9:22 PMancient-france-42909
07/02/2024, 9:23 PMflaky-artist-57016
07/02/2024, 9:24 PM