Hi Pants team :wave: I’m evaluating Pants for a py...
# welcome
Hi Pants team 👋 I’m evaluating Pants for a python monorepo and having an issue with 3rd party dependencies. To be honest, I’m probably having some newbie python dependency issue, but it reflects with:
Copy code
./pants dependencies ::
Discover all the relevant dependencies, however
Copy code
./pants dependencies path_to_a_specific_test.py
Doesn’t “find” all the relevant dependencies in the test file, failing it accordingly for a ModuleNotFoundError. Can/Should I manually add dependencies to a BUILD file? Thanks
👋 1
Your second codeblock looks like an absolute path, is that correct, or a typo?
a typo 🙂
Can you elaborate more? What dependency are you expecting it to find? Are you importing the module? Any additional info is extremely helpful 🙂
Sure, my use case is to break this poetry project into several packages. Before refactoring it I’ve tried installing Pants as is with this toml:
Copy code
pants_version = "2.12.0"

backend_packages.add = [

enabled = false

root_patterns = ["/"]

tailor_ignore_solitary_init_files = false

inits = true
After ./pants tailor, when running
./pants test tests/test_exporter_factory.py
I get
No module named 'opentelemetry'
even-though the relevant package (opentelemetry-sdk in this case) appears under root when running
./pants dependencies ::
Also thanks for the patience and help 🙏
Since the package name
and the module name
don't match, you'll want to set `module_mapping`: https://www.pantsbuild.org/docs/python-third-party-dependencies#use-modules-and-module_mapping-when-the-module-name-is-not-standard
We'd love if you opened a PR against our default mapping: https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/python/dependency_inference/default_module_mapping.py That way when you upgrade Pants version you can stop declaring it yourself, and others benefit too!
🙏 2
Thanks! Will do
Usability take way, module not found errors could potentially drop a bread crumb about module mappings..
That's an interesting idea. But not sure how we'd do that since the error is coming from the python process we're running 🤔
Ah. I've had ideas in the past about generically looking at error messages and augment them with additional context/details etc. Such as errors from pex or its subprocesses where information may be missing at the source of an error.
👀 1