Hello everyone! Quick question: I have poetry depe...
# general
p
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
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
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
oh I see! i'll try right now
f
poetry_requirements is a macro, so it should pick up its name some other way
👍 2
p
it does indeed work! thanks, i do understand how it works now!
👍 2
w
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