adamant-energy-38096
12/04/2024, 4:54 PMkubernetes
to run but it doesn't explicitly need to import it, so I added this to the BUILD
file and it seemed to work well:
python_sources(
name="myproj",
dependencies=["3rdparty/python:default#kubernetes"]
)
The problem is that I have multiple lock files (default.lock
, pipeline.lock
) and when I run with a different resolve I get this error:
NoCompatibleResolveException: The target projects/myproj/main:deps uses the `resolve` `pipeline-resolve`, but some of its dependencies are not compatible with that resolve:
* 3rdparty/python:default#kubernetes (default-resolve)
All dependencies must work with the same `resolve`. To fix this, either change the `resolve=` field on those dependencies to `pipeline-resolve`, or change the `resolve=` of the target projects/myproj/main:deps. If those dependencies should work with multiple resolves, use the `parametrize` mechanism with the `resolve=` field or manually create multiple targets for the same entity.
For more information, see <https://www.pantsbuild.org/2.21/docs/python/overview/lockfiles#multiple-lockfiles>.
I can't figure out how to dynamically make it use 3rdparty/python:default#kubernetes
or 3rdparty/python:default#kubernetes
depending on whichever resolve is selected, does anybody have any ideas?
(Full BUILD
file in the 🧵 )adamant-energy-38096
12/04/2024, 4:55 PMpython_sources(
name="myproj",
dependencies=["3rdparty/python:default#kubernetes"]
)
pex_binary(
name="deps",
entry_point="main.py",
layout="packed",
include_sources=False,
include_tools=True,
dependencies=[":myproj"]
)
pex_binary(
name="srcs",
entry_point="main.py",
layout="packed",
include_requirements=False,
include_tools=True,
dependencies=[":myproj"]
)
careful-address-89803
12/04/2024, 8:45 PM3rdparty/python:default
is defined. I'm guessing it looks something like this:
python_requirements(name="default", source="default-requirements.txt", resolve="python-default")
python_requirements(name="pipeline", source="pipeline-requirements.txt", resolve="python-pipeline")
each resolve is a different universe of dependencies. Since myproj
is in the "python-default" universe, accessing the 3rdparty/python:default#kubernetes
target works. But if you have target in a different resolve (the "python-pipeline" resolve), it's in a different universe. If you need a target to exist in both universes, the typical way to do that is through parametrize
. For example, this parametrises a Python target to both resolves:
python_sources(name="mypython",resolve=parametrize("python-default", "python-pipeline"))
In you case, you need to parametrize both the resolve and the dependency fields together. You can do that with a more advanced form of parametrisation:
python_sources(
name="myproj",
**parametrize("python-default", dependencies=[":default#kr8s"], resolve="pipeline-default"),
**parametrize("python-pipeline", dependencies=[":pipeline#kr8s"], resolve="python-pipeline"),
)
careful-address-89803
12/04/2024, 8:46 PMpex_binary(name="mypex",dependencies=[":myproj"],resolve="python-pipeline")
careful-address-89803
12/04/2024, 8:47 PMpython_requirement(name="default", requirements=["kr8s"], resolve="python-default")
python_requirement(name="pipeline", requirements=["kr8s"], resolve="python-pipeline")
python_sources(
name="myproj",
**parametrize("python-default", dependencies=[":default#kr8s"], resolve="pipeline-default"),
**parametrize("python-pipeline", dependencies=[":pipeline#kr8s"], resolve="python-pipeline"),
)
pex_binary(name="mypex", dependencies=[":myproj"], resolve="python-pipeline")
careful-address-89803
12/04/2024, 8:48 PMadamant-energy-38096
12/05/2024, 8:42 AM