Hello team :wave: ! I’m having a problem with sha...
# general
r
Hello team 👋 ! I’m having a problem with sharing a
python_distribution
package across multiple resolves that need to use different python versions and different dependency version constraints. Let’s say I have the following: 1. 3rd-party dependency
foo
where I want to use v1 in python 3.8 and v2 in py3.9 2. Shared package
A
which should be compatible with both
foo==1
in py3.8 and
foo==2
in py3.9 3. Package
B
which depends on
A
, but only needs to run in py3.8 with
foo==1
4. Package
C
which depends on
A
, but only needs to run in py3.9 with
foo==2
So far, I have been able to get this to work by: 1. Creating 2 different
python_requirements
targets: a. with
foo==1
b. with
foo==2
2. Creating 2 different
python_distribution
targets for `A`: a. Name
a-38
with
interpreter_constraints=[">=3.8,<3.9"]
b. Name
a-39
with
interpreter_constraints=[">=3.9,<3.10"]
3. Use resolve
b
for
B
with
interpreter_constraints=[">=3.8,<3.9"]
4. Use resolve
c
for
C
with
interpreter_constraints=[">=3.9,<3.10"]
but this is not ideal because it requires publishing 2 different packages for
A
. What I wish would work looks more like: 1. Create 1
python_requirements
targets with requirements conditioned on the python interpreter a.
foo==1; python_version < 3.9
b.
foo==2; python_version >= 3.9
2. Create 1
python_distribution
target for
A
where
interpreter_constraints=[">=3.8,<3.10"]
3. Use resolve
b
for
B
with
interpreter_constraints=[">=3.8,<3.9"]
4. Use resolve
c
for
C
with
interpreter_constraints=[">=3.9,<3.10"]
However, whenever I try this, I get an error
Copy code
InvalidFieldException: The target root/A@resolve=b has the `interpreter_constraints` ('>=3.8,<3.10',), which are not a subset of the `interpreter_constraints` of some of its dependencies:

* ('CPython>=3.8,<3.9',): root/B/__init__.py:../lib@resolve=b
It looks like every target must have
interpreter_constraints
that are a subset of every
resolve
that it belongs to. Is the 1st scenario that I describe the correct way to manage this situation? Is there anyway to make use of conditional constraints to publish only 1
A
?