shy-magazine-15006
07/03/2024, 6:49 AMshy-magazine-15006
07/03/2024, 6:49 AM$ pants --no-pantsd dependencies lib/py/email/_sender.py
13:47:34.44 [WARN] Pants cannot infer owners for the following imports in the target lib/py/email/_sender.py:
* aiosmtplib (line: 8)
If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see <https://www.pantsbuild.org/2.21/docs/using-pants/troubleshooting-common-issues#import-errors-and-missing-dependencies> for common problems.
lib/py/dns/__init__.py
lib/py/email/__init__.py
lib/py/email/pyproject.toml:reqs
lib/py/email:reqs#aiosmtplib
lib/py/email:reqs#email-validator
shy-magazine-15006
07/03/2024, 6:50 AMpyproject.toml
:
[project]
name = "lib.py.email"
version = "0"
dependencies = [
"aiosmtplib",
"email_validator",
]
shy-magazine-15006
07/03/2024, 6:51 AMpython_requirements(
name="reqs",
source="pyproject.toml",
)
python_sources(
dependencies=[
":reqs",
"lib/py/dns:dns",
]
)
shy-magazine-15006
07/03/2024, 6:58 AM$ ls -lah dist/export/python/virtualenvs/python-default/3.11.9/lib/python3.11/site-packages | grep aiosmtplib
drwxr-xr-x - ph 2 Jul 23:37 aiosmtplib
drwxr-xr-x - ph 2 Jul 23:37 aiosmtplib-3.0.1.dist-info
shy-magazine-15006
07/03/2024, 6:59 AM$ cat 3rdparty/python/default.lock | grep aiosmtplib
// "aiosmtplib",
"url": "<https://files.pythonhosted.org/packages/3b/2a/31fbf4dcfb7ad018e9148b94d5280f2fdb3b6657e9db562a58da7ef31a9f/aiosmtplib-3.0.1-py3-none-any.whl>"
"url": "<https://files.pythonhosted.org/packages/4f/b4/f91e0715e81bfa56e17850357b7d603861ebb1fdd92481d68c8fedf6bf5a/aiosmtplib-3.0.1.tar.gz>"
"project_name": "aiosmtplib",
"aiosmtplib",
curved-television-6568
07/03/2024, 8:07 AM❯ pants dependencies lib/py/email/_sender.py
lib/py/email/pyproject.toml:reqs
lib/py/email:reqs#aiosmtplib
lib/py/email:reqs#email-validator
❯ tree
.
├── default.lock
├── lib
│ └── py
│ └── email
│ ├── BUILD
│ ├── _sender.py
│ └── pyproject.toml
└── pants.toml
4 directories, 7 files
curved-television-6568
07/03/2024, 8:09 AM__defaults__
?
also, you don't need to depend on the entire resolve (the :reqs
dependency you have in there) as that will unconditionally pull in all thirdparty deps, even unused ones.shy-magazine-15006
07/03/2024, 8:25 AM__defaults__
, I created a copy of monorepo and found how to reproduce it without all the code. When you add those two files the warning starts to appear:
lib/py/mailgen/BUILD
:
python_requirements(
name="reqs",
source="pyproject.toml",
)
`lib/py/mailgen/pyproject.toml`:
[project]
name = "lib.py.mailgen"
version = "0"
dependencies = ["aiosmtplib", "backoff"]
curved-television-6568
07/03/2024, 2:41 PMaiosmtplib
in the same resolve, Pants doesn't know which one of them it should infer a dependency to. If those two projects doesn't share code, but you want to continue using separate requirements for them, put them in dedicated resolves to fix the issue.