In my app, I have a sub-package having sub-package...
# general
r
In my app, I have a sub-package having sub-packages that looks like the following:
Copy code
a
├── ba
│   ├── __init__.py
│   └── resources.py
├── bb
│   ├── __init__.py
│   └── resources.py
├── bc
│   ├── __init__.py
│   └── resources.py
├── bd
│   ├── __init__.py
│   └── resources.py
├── be
│   ├── __init__.py
│   └── resources.py
├── bf
│   ├── __init__.py
│   └── resources.py
└── __init__.py
a/__init__.py
uses
importlib.import_module
to load all the
resources.py
files under it (done to do auto-registration on a factory). This isn't picked up by the pants' inference system. I thought to have
a/BUILD
with something like
Copy code
python_sources(
  overrides={
    "__init__.py": {
        "dependencies": ["*/**/*.py"]
    }
  }
)
But pants is complaining. I'm not sure I can use glob on
dependencies
anyway. Therefore, I'm not sure how to handle that situation. Can you guys tell me if my approach is ok and what is missing to make it works?
h
Yeah, globs don't work with
dependencies
, unfortunately. So you have three options: 1) Rewrite the code to use something Pants can infer 2) Hardcode each dependency 3) Automate with a light weight dependency inference plugin, which will auto-detect
resource.py
in subtrees Happy to help w/ #3 if you're interested
r
ok, that's what I thought. No big deal for now but I'll probably go back to 3) soon. Meanwhile, I think I'm starting to get a grip on how the dependencies and BUILD files work: All my pytest tests are successful :-)
❤️ 1
👍 1