quiet-army-59227
07/24/2024, 5:02 PMpyproject.toml
file and a setup.cfg
file. The setup.cfg
file contains information such as the version, third-party dependencies, and so on. I read the documentation (https://www.pantsbuild.org/2.21/reference/targets/python_distribution#generate_setup) and it says the generate_setup
attribute in the python_distribution
(if set to false) will use this existing setup information.
I don't think it is able to detect the third-party dependencies since I still get warning for unowned dependencies (do I need to state them explicity? I thought pants would automatically infer them from this file). Also, how to I retrieve some information explicitly from the setup.cfg
file? For example, I want to use the version specified in that file to add to the version of the wheel distribution in the BUILD
file of that project (and so on).happy-kitchen-89482
07/24/2024, 7:01 PMimport
statements. This is for things that happen at the source level without ever building the distribution, such as running tests. Separately, when you build wheels for a distribution, Pants has to embed Requires-Dist
metadata in that wheel. If you let Pants generate the setup.py, it will use the inferred dependencies to populate this metadata. If not, you have to populate it yourself.
So, the question here is why is A) not working. And I suspect the answer is that you have no target to represent your "universe" of third-party dependencies. For example, if they were in a requirements.txt
, you would have a python_requirements()
stanza in a BUILD file with that requirements.txt
as a source, which would generate a target for each requirement listed. There are similar target generators for requirements in pyproject.toml.
But in your case, it's in setup.cfg
, and we don't have a python_setup_cfg()
target generator.
So your options are: break the requirements out into a requirements.txt and use file:path/to/requirements.txt
in setup.cfg. Or switch to pyproject.toml. Or add a python_setup_cfg()
target generator to Pants. It should be very easy.quiet-army-59227
07/24/2024, 7:59 PMfile:path/to/requirements.txt
in setup.cfg
Could you elaborate this a bit more? I need to put file:path/to/requirements.txt
in setup.cfg
?
Also, I also want to get access to other information (metadata) present in the setup.cfg
file such as the name, and version. If I use a pyproject.toml
file, how would I be able to get this information?happy-kitchen-89482
07/24/2024, 8:05 PMfile:...
as a requirement, but that is not a Pants questionhappy-kitchen-89482
07/24/2024, 8:06 PMquiet-army-59227
07/24/2024, 8:07 PMhappy-kitchen-89482
07/24/2024, 8:08 PMquiet-army-59227
07/24/2024, 8:09 PMquiet-army-59227
07/24/2024, 8:10 PMquiet-army-59227
07/24/2024, 8:37 PM[build-system]
entries (https://www.pantsbuild.org/2.21/docs/python/overview/building-distributions#pep-517)?happy-kitchen-89482
07/24/2024, 10:14 PMhappy-kitchen-89482
07/24/2024, 10:14 PMhappy-kitchen-89482
07/24/2024, 10:15 PMhappy-kitchen-89482
07/24/2024, 10:15 PMhappy-kitchen-89482
07/24/2024, 10:16 PMquiet-army-59227
07/24/2024, 11:03 PM[project]
table in pyproject.toml. I also created a requirements.txt file with the same dependecies and it is able to infer all the dependencies properly (I checked using pants dependencies
).
however, when I create the wheel using the python_distribution
target, it only adds the name and version in the wheel METADATA file. it doesn't add the dependencies under Requires-Dist
. Also, if I want to add custom METADATA to the wheel, I am not sure how to do that using pants?happy-kitchen-89482
07/25/2024, 1:16 AMhappy-kitchen-89482
07/25/2024, 1:16 AMpython_requirements(source="pyproject.toml")
targethappy-kitchen-89482
07/25/2024, 1:18 AMquiet-army-59227
07/25/2024, 3:46 PM[build-system]
table. Does pants also do that for [project]
? Because I had written the dependencies under there.
Also, If I want to add custom information into the METADATA of the wheel using pants, is there a way to do that?happy-kitchen-89482
07/25/2024, 4:19 PM