[BE]: Add PEP621 project section to pyproject.toml (#153055)

Follow up to @ezyang's PR #153020 , but better uses PEP621 to reduce redundant fields and pass through metadata better to uv, setuptools, poetry and other tooling.

* Enables modern tooling like uv sync and better support for tools like poetry.
* Also allows us to set project wide settings that are respected by linters and IDE (in this example we are able centralize the minimum supported python version).
* Currently most of the values are dynamically fetched from setuptools, eventually we can migrate all the statically defined values to pyproject.toml and they will be autopopulated in the setuptool arguments.
* This controls what additional metadata shows up on PyPi . Special URL Names are listed here for rendering on pypi: https://packaging.python.org/en/latest/specifications/well-known-project-urls/#well-known-labels

These also clearly shows us what fields will need to be migrated to pyproject.toml over time from setup.py per #152276. Static fields be fairly easy to migrate, the dynamically built ones like requirements are a bit more challenging.

Without this, `uv sync` complains:
```
error: No `project` table found in: `pytorch/pyproject.toml`
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/153055
Approved by: https://github.com/ezyang
This commit is contained in:
Aaron Gokaslan
2025-05-12 02:16:04 +00:00
committed by PyTorch MergeBot
parent ceb009baee
commit 032ef48725
4 changed files with 37 additions and 6 deletions

View File

@ -1296,6 +1296,8 @@ def main():
install_requires=install_requires,
extras_require=extras_require,
package_data=package_data,
# TODO fix later Manifest.IN file was previously ignored
include_package_data=False, # defaults to True with pyproject.toml file
url="https://pytorch.org/",
download_url="https://github.com/pytorch/pytorch/tags",
author="PyTorch Team",