https://pantsbuild.org/ logo
#general
Title
# general
p

plain-fireman-49959

12/22/2021, 1:50 PM
Hello everyone! Quick question: I have poetry dependencies in a pyproject.toml (at root level), my target depends on
python-magic
and the module it exposes is just
magic
. I checked the Module Mapping docs, however I don't understand how to use it. I expect to declare in the root BUILD file that such mapping exists
Copy code
poetry_requirements()

python_requirement(
    module_mapping={"python-magic": ["magic"]}
)
But I get a MappingError
Targets in root-level BUILD files must be named explicitly.
Where and what exactly should I put this mapping information?
f

flat-zoo-31952

12/22/2021, 1:57 PM
I think you're on the right track... but does the python-magic requirement come from your poetry requirements spec ?
in that case you'd need to just put the module_mapping in the poetry_requirements macro like this:
Copy code
poetry_requirements(
  module_mapping={"python-magic": ["magic"]},
)
c

curved-television-6568

12/22/2021, 2:03 PM
The error in particular above, comes from that you have an unnamed target in your root BUILD file. Simply add
name=…
to it, like:
Copy code
python_requirement(name="my-requirement", ...)
same goes for the
poetry_requirements()
target, I think… unless it gets away with being a special breed. Unsure.
p

plain-fireman-49959

12/22/2021, 2:04 PM
oh I see! i'll try right now
f

flat-zoo-31952

12/22/2021, 2:04 PM
poetry_requirements is a macro, so it should pick up its name some other way
👍 2
p

plain-fireman-49959

12/22/2021, 2:11 PM
it does indeed work! thanks, i do understand how it works now!
👍 2
w

witty-crayon-22786

12/22/2021, 4:07 PM
poetry_requirements is a macro, so it should pick up its name some other way
yea, that macro (and
python_requirements
) are both magical right now: there will be magic removal as part of #12915