wooden-ability-49079
12/19/2023, 10:45 PMpython_sources(resolve=parametrize("python-default", "new-deps"))
python_distribution(
name="commons",
dependencies=["src/python/commons/libs/commons"],
provides=python_artifact(
name="commons",
version="1.0",
),
)
And I also have a library using the library: libA
above like so
python_sources()
python_distribution(
name="libA",
dependencies=["src/python/commons/libs/commons"],
provides=python_artifact(
name="libA",
version="1.0",
),
)
when I run package on libA pants package src/python/qe/libs//libA:libA
. I get the following error:
ValueError: The explicit dependency `src/python/commons/libs/commons:commons` of the target at `src/python/qe/libs/libA:libA` does not provide enough address parameters to identify which parametrization of the dependency target should be used.
….
what I would like to do is use the version of commons
that uses the python-default
resolve, any idea how I can do that?? thanks Allsquare-psychiatrist-19087
12/19/2023, 10:56 PMsrc/python/commons/libs/commons:commons@your-resolve
try running pants list ::
it will show you the addresseswooden-ability-49079
12/19/2023, 10:59 PMwooden-ability-49079
12/19/2023, 11:04 PMcommons
library like so
python_sources(resolve=parametrize("python-default", "new-deps"))
python_distribution(
name="commons",
dependencies=["src/python/commons/libs/commons@resolve=python-default"],
provides=python_artifact(
name="commons",
version="1.0",
),
)
wooden-ability-49079
12/19/2023, 11:10 PMlibB
that needs to work with the other resolve, which now breaks, is the solution to have two python_distributions
one with each resolve, and use the appropiate one on a case by case basis?wooden-ability-49079
12/19/2023, 11:12 PMpython_distribution
of the shared lib "commons" should also be parametrized over the resolves is that possible?square-psychiatrist-19087
12/19/2023, 11:29 PMwooden-ability-49079
12/19/2023, 11:31 PMpython_distributions
for example in order for other libraries to consume the new-deps
version of commons, I would need to something like this?
python_sources(resolve=parametrize("python-default", "new-deps"))
python_distribution(
name="commons",
dependencies=["src/python/commons/libs/commons@resolve=python-default"],
provides=python_artifact(
name="commons",
version="1.0",
),
)
python_distribution(
name="commons-new-deps",
dependencies=["src/python/commons/libs/commons@resolve=new-deps"],
provides=python_artifact(
name="commons",
version="1.0",
),
)
perhaps I am missing somethigsquare-psychiatrist-19087
12/19/2023, 11:34 PMpython_sources(resolve=parametrize("python-default", "new-deps"))
kwargs = dict(
provides=python_artifact(
name="commons",
version="1.0",
),
)
python_distribution(
name="commons",
dependencies=["src/python/commons/libs/commons@resolve=python-default"],
**kwargs,
)
python_distribution(
name="commons-new-deps",
dependencies=["src/python/commons/libs/commons@resolve=new-deps"],
**kwargs,
)
square-psychiatrist-19087
12/19/2023, 11:39 PMwooden-ability-49079
12/19/2023, 11:44 PMsquare-psychiatrist-19087
12/19/2023, 11:47 PMwooden-ability-49079
12/19/2023, 11:51 PMsquare-psychiatrist-19087
12/19/2023, 11:52 PMwooden-ability-49079
12/19/2023, 11:53 PMwooden-ability-49079
12/19/2023, 11:54 PMsquare-psychiatrist-19087
12/19/2023, 11:56 PMnop i just need libA, and libB to be installableyeah, if you need both to be installable in a single venv then you probably need 3 python_distribution-s
wooden-ability-49079
12/19/2023, 11:59 PMwooden-ability-49079
12/19/2023, 11:59 PMsquare-psychiatrist-19087
12/20/2023, 12:01 AMwooden-ability-49079
12/20/2023, 12:02 AMpython_distribu..
?wooden-ability-49079
12/20/2023, 12:03 AMwooden-ability-49079
12/20/2023, 12:03 AMsquare-psychiatrist-19087
12/20/2023, 12:09 AMcurved-television-6568
12/20/2023, 12:15 AMcurved-television-6568
12/20/2023, 12:16 AMpython_artifact
name as well.. otherwise how do you pick the correct one when installing it as a dependency?wooden-ability-49079
12/20/2023, 12:16 AMwooden-ability-49079
12/20/2023, 12:19 AMfor i in resolvers:
python_distribution(
name="commons",
dependencies=["src/python/commons/libs/commons@resolve={i}"],
provides=python_artifact(
name=f"commons{i}",
version="1.0",
),
)
curved-television-6568
12/20/2023, 12:19 AMwooden-ability-49079
12/20/2023, 12:19 AMcurved-television-6568
12/20/2023, 12:20 AMwooden-ability-49079
12/20/2023, 12:20 AMcurved-television-6568
12/20/2023, 12:20 AMcurved-television-6568
12/20/2023, 12:22 AMwooden-ability-49079
12/20/2023, 12:24 AMresolves = ['python-default', 'new-dep']
vs
resolves = get_resolves() # magcally returns all the resolves?
curved-television-6568
12/20/2023, 12:24 AMget_resolves
be defined?curved-television-6568
12/20/2023, 12:25 AMcurved-television-6568
12/20/2023, 12:25 AMwooden-ability-49079
12/20/2023, 12:25 AMcurved-television-6568
12/20/2023, 12:25 AMcurved-television-6568
12/20/2023, 12:26 AMwooden-ability-49079
12/20/2023, 12:26 AMparametrize
curved-television-6568
12/20/2023, 12:26 AMbuild_file_dir()
wooden-ability-49079
12/20/2023, 12:27 AMwooden-ability-49079
12/20/2023, 12:28 AMcurved-television-6568
12/20/2023, 12:29 AMwooden-ability-49079
12/20/2023, 12:29 AMcurved-television-6568
12/20/2023, 12:30 AMcurved-television-6568
12/20/2023, 12:31 AM__defaults__
and __dependency_rules__
/ __dependents_rules__
.happy-kitchen-89482
12/20/2023, 4:04 PMhappy-kitchen-89482
12/20/2023, 4:04 PMhappy-kitchen-89482
12/20/2023, 4:05 PMhappy-kitchen-89482
12/20/2023, 4:05 PMhappy-kitchen-89482
12/20/2023, 4:05 PMwooden-ability-49079
12/20/2023, 5:31 PMpython_distribution
macro? (primitive? don't know how you all refer to those functions) enforces single ownership so commons
(libA, libB, etc), thus I have to model commons
as a distribution so that it can be used by other libs, eg libA, libB, etc.
One idea I explored was to not use python_distribtuion
and just use a custom setup.py
but honestly haven't gone that far down the road, I would like to avoid recalculating dependencies that pants already know how to create, I guess I want something like this.
# The below showcases a non-existent "overrides" argument to specify how to package a given dependency.
python_distribution(
name="libA",
dependencies=["src/python/commons/libs/commons"],
overrides= {"source": "src/python/commons/libs/commons"} # which tells pants to include the source of the dep as opposed to model it as installable dependency
provides=python_artifact(
name="libA",
version="1.0",
),
)
Yes 90% of the time this is not what you want to do, as you point out, but there are ocassions in which you might need to do something like the above.curved-television-6568
12/20/2023, 5:38 PMpython_distribution
is a “target type”) 😉happy-kitchen-89482
12/20/2023, 8:04 PMwooden-ability-49079
12/20/2023, 8:07 PM