rhythmic-morning-87313
04/30/2022, 2:51 AMrequirements.txt
using python_requirements()
seems to put all the same external dependencies to different packages defined as python_distribution()
in multiple different BUILD
files.
Through my Q5/A5, I expected that pants automatically include the actual direct dependencies only, but it seems not doing any filtering like that. How do I achieve it?
Example:
pkg "manager" depends on "aiofiles" but pkg "common" does not. They both depends on "aiohttp".
Both "aiofiles" and "aiohttp" are included in the unified requirements.txt
.
"manager" depends on "common".
I just removed pyproject.toml
and let pants generate setup.py using generate_setup=True
.
-> expected: METADATA
of the "manager" pkg include "aiofiles" while the "common" pkg's does not. Both include "aiohttp".
(because although "manager" depends on "common", only the direct requirements of "manager" should be added to "manager"'s pkg metadata, not both "manager" and "common"'s direct requirements)
-> actual result: Both include "aiofiles" and "aiohttp".happy-kitchen-89482
04/30/2022, 2:55 AMdependencies=
part of a target.aiofiles
but it shouldn'trhythmic-morning-87313
04/30/2022, 2:56 AMhappy-kitchen-89482
04/30/2022, 2:56 AMrhythmic-morning-87313
04/30/2022, 2:57 AMhappy-kitchen-89482
04/30/2022, 2:59 AMrhythmic-morning-87313
04/30/2022, 3:00 AM./pants package src/ai/backend/common:dist
and ./pants package src/ai/backend/manager:dist
, unzip dist/*.whl
, and inspect the package's METADATA from *.egg_info
directoriessrc/ai/backend/manager:service
depends on //:reqs
directly.happy-kitchen-89482
04/30/2022, 3:20 AM//:reqs
? That would explain things//:reqs
generates a separate target for each requirement in the file, but if you depend on the generator itself, you're telling Pants to depend on everything it generates)rhythmic-morning-87313
04/30/2022, 3:23 AM//:reqs
dependency from python_sources()
makes the correct wheel!python_requirements()
is recognized by pantshappy-kitchen-89482
04/30/2022, 3:31 AMdependencies
for you, mostly based on import
statements. If you do need to add a specific one that couldn't be inferred from static analysis you can//:reqs#ansicolors
for example//:reqs
rhythmic-morning-87313
04/30/2022, 3:33 AMhappy-kitchen-89482
04/30/2022, 3:33 AMrhythmic-morning-87313
04/30/2022, 3:33 AMrequirments.txt
? (e.g., those are imported in the code but requirements does not have it yet)attrs
-- exposing attr
and attrs
)happy-kitchen-89482
04/30/2022, 2:22 PMfrom foo import bar
it will look for something that provides foo.bar
, and that something can be either code in your repo (for example src/foo/bar.py
) or a third party requirement. Often that will be called foo
on PyPI, but if it's not (say it's called foolib
) then you can add that mapping in the python_requirements
target in the BUILD file: https://www.pantsbuild.org/docs/reference-python_requirements#codemodule_mappingcoderhythmic-morning-87313
05/01/2022, 3:08 AM