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.happy-kitchen-89482
04/30/2022, 2:55 AMhappy-kitchen-89482
04/30/2022, 2:56 AMaiofiles but it shouldn'thappy-kitchen-89482
04/30/2022, 2:56 AMrhythmic-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 AMrhythmic-morning-87313
04/30/2022, 3:00 AMrhythmic-morning-87313
04/30/2022, 3:01 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 directoriesrhythmic-morning-87313
04/30/2022, 3:13 AMsrc/ai/backend/manager:service depends on //:reqs directly.rhythmic-morning-87313
04/30/2022, 3:14 AMhappy-kitchen-89482
04/30/2022, 3:20 AM//:reqs ? That would explain thingshappy-kitchen-89482
04/30/2022, 3:21 AMhappy-kitchen-89482
04/30/2022, 3:21 AMhappy-kitchen-89482
04/30/2022, 3:22 AM//: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!rhythmic-morning-87313
04/30/2022, 3:24 AMrhythmic-morning-87313
04/30/2022, 3:24 AMrhythmic-morning-87313
04/30/2022, 3:24 AMpython_requirements() is recognized by pantsrhythmic-morning-87313
04/30/2022, 3:25 AMhappy-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 canhappy-kitchen-89482
04/30/2022, 3:32 AM//:reqs#ansicolors for examplehappy-kitchen-89482
04/30/2022, 3:33 AM//:reqsrhythmic-morning-87313
04/30/2022, 3:33 AMrhythmic-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)rhythmic-morning-87313
04/30/2022, 3:35 AMrhythmic-morning-87313
04/30/2022, 3:38 AMrhythmic-morning-87313
04/30/2022, 3:38 AMrhythmic-morning-87313
04/30/2022, 3:39 AMrhythmic-morning-87313
04/30/2022, 3:39 AMattrs -- 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_mappingcodehappy-kitchen-89482
04/30/2022, 2:23 PMhappy-kitchen-89482
04/30/2022, 2:23 PMhappy-kitchen-89482
04/30/2022, 2:23 PMhappy-kitchen-89482
04/30/2022, 2:29 PMhappy-kitchen-89482
04/30/2022, 2:31 PMhappy-kitchen-89482
04/30/2022, 2:39 PMrhythmic-morning-87313
05/01/2022, 3:08 AM