Hey! I'm trying to configure an existing repositor...
# general
Hey! I'm trying to configure an existing repository with pants V2. One of our dependencies is
which needs to be mapped using
. However, the
in the package name seems to prevent pants to understand how to do the mapping. Is this intended behaviour? If not, any idea how to get around this?
Hello! Welcome! Oh that's tricky. Most of us are afk today for MLK day in the US, but to debug, you would want to play around with setuptools in a REPL and it's pkg_resources.Requirement type. Use Requirement.parse() - Pants uses the property .project_name as the key for the mapping
Thanks for the quick response! So you are saying I should look for the
as defined by the 3rd party dependency I'm trying to import? Or should I let pants build a
file and figure out how it tries to resolve the dependency?
We want to understand how pkg_reources.Requirement understands that requirement string because that is how Pants will represent it internally. Specifically, the property project_name will be the key in the module mapping Once we understand how setuptools/pkg_resources works by playing with it in a REPL, we will understand how to get this working with Pants
Thanks, I'll try to play around with that a little bit then! Pretty new to pants though, so hope I can figure this out 🙂
Okay I got access to a computer for a little 🙂 Here, I'm using Pex as a CLI tool to create a REPL with the relevant third party dep loaded into it. Independently of Pants, Pex is awesome for experiments like this
Copy code
❯ pex setuptools
Python 3.9.1 (default, Jan  8 2021, 12:11:08)
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pkg_resources import Requirement
>>> req = Requirement.parse("h2o_pysparkling_2.4")
>>> req.project_name
So, this suggests to me that the key in your
dictionary should be
. Could you please try that?
🙌 1
Thanks @hundreds-father-404, that worked! I'm just started to uncover the great work of
, so thanks for sharing the example 😄 Might be good to add this as a note to the docs, as this might be the case for more 3rd party requirements 😛
❤️ 1