Hi folks! I have setup Pants in an existing monor...
# general
f
Hi folks! I have setup Pants in an existing monorepo. I am running my tests, but, facing issues in the dependency inference for google libraries. Can anybody guide me to figure out this at a root level, so that I don't have manually add something like
module_mapping
to all the first party modules in my monorepo. Thanks in advance!
One more constraint: Since we are migrating our monorepo to Pants, each of the module has it's own requirements.txt, which we want to continue to support.
e
so that I don't have manually add something like module_mapping to all the first party modules in my monorepo.
That part doesn't make much sense. You add module mappings to third party dependencies once, where you declare them; not in first party code that consumes them.
Can you flesh out more detail of how you have set things up, what your BUILD files have in them, the issue you see?
f
My BUILD file at the root has python_sources(), and python_requirements()
e
So, you only need to add mappings to
python_requirements()
once, not to 1st party modules.
f
Correct, But we have 20+ modules, each with their own requirements. Would I repeat the mapping code in all the python_requirements() in all the modules?
e
Yes. You could use a macro though to define the mappings in 1 place and re-use. See here for more on macros: https://www.pantsbuild.org/docs/macros Or, you will get these mappings for free in 2.19.x?: + PR: https://github.com/pantsbuild/pants/pull/19684 + New built-in regexes for azure and google: https://github.com/pantsbuild/pants/blob/43828adfdbe982931ee0c79e39fce3b859c564c3/src/python/pants/backend/python/dependency_inference/default_module_mapping.py#L60-L74
f
Let me go through these links
@enough-analyst-54434 Thanks for the guidance! Your solution is working.