Remove setup.py in favor of pyproject.toml - #816
Open
albertvillanova wants to merge 1 commit into
Open
Conversation
albertvillanova
force-pushed
the
remove-setup-py
branch
from
August 18, 2026 15:17
ba9ec87 to
3492643
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR removes
setup.py, leavingpyproject.tomlas the single source of packaging configuration.Motivation
Since #636,
pyproject.tomldeclares a complete[project]table, which setuptools treats as authoritative for the package metadata.setup.pyhas been unused for metadata ever since, and it has drifted accordingly:install_requiresstill listsblack, andextras["quality"]still pinsblack~=22.0,isortandflake8, all replaced byruffin Modernize tooling: Replace black/isort with ruff, migrate to uv #636extras["testing"]still listsrequests, replaced byhttpxin Replace requests with httpx #754Keeping it around is actively misleading: #785 edited
setup.pyto fix a missingruffdependency and had no effect at all, because the built metadata comes frompyproject.toml(see #815).Solution
While the
[project]metadata was already coming frompyproject.toml, two settings insetup.pywere still load-bearing, and both need to be migrated.1.
package_data.setup.pydeclared:MANIFEST.indoes not covermock_deps, so without this declaration the mock-deps registry files are silently dropped from the wheel, anddoc-builder light-install <package> --checkthen fails:It is therefore ported to
pyproject.tomlas[tool.setuptools.package-data].mock_depsis the only directory undersrc/doc_builderholding non-Python files, so this is the only package data to declare.2.
is_doc_builder_repo. It identified the repo by reading the first line ofsetup.py, and it is load-bearing too:locate_kit_folderuses it as its second strategy to find thekitfolder, after looking next to the installed module. In the documentation build workflows the package is installed non-editably anddoc-builder buildruns from the repo checkout, so the first strategy fails and this second one is what resolveskitlocally. Removingsetup.pywithout touching it would silently fall through toget_cached_repo, which clonesdoc-builderfrom GitHub, adding a network dependency to every documentation build.It is switched to identify the repo from
pyproject.tomlinstead. A plain string check is used rather than parsing TOML, to avoid depending ontomllib, which is only available from Python 3.11 while the project supports 3.10.Verified by reproducing the workflow layout (non-editable install,
doc-builderinvoked from the repo checkout):locate_kit_folderstill resolves to the localkitfolder and performs no clone. With the previoussetup.py-based check it returnsFalseand would clone. No test covers this path.With both migrated, building a wheel from a clean tree on this branch and from a clean tree on
mainproduces an identical set of files, and the only metadata difference is that two legacy fields are no longer emitted:Both are already covered by their modern equivalents, which
pyproject.tomldeclares and which are what PyPI displays:Finally,
setup.pycarried the release checklist in trailing comments. It is moved toRELEASE.mdrather than dropped, with the version locations updated topyproject.tomland the deprecatedpython setup.py bdist_wheel/sdistinvocations replaced byuv build.Changes
setup.pymock_deps/*.txtas package data inpyproject.tomldoc-builderrepo frompyproject.tomlinstead ofsetup.pyinis_doc_builder_reposetup.pycomments toRELEASE.md, updated forpyproject.tomlanduv buildNotes
The documentation build workflows check out
huggingface/doc-builderwithout arefand then rungit pull origin mainbeforeuv pip install ., so they always install the currentmain, regardless of the commit a consumer pins the reusable workflow to. Pinningbuild_main_documentation.yml@<sha>freezes the workflow file only, not thedoc-buildercode it installs. This change therefore takes effect immediately for all consumers on their next build, and no consumer needs to bump anything.This PR touches
pyproject.toml, as does #815, but in a different section, so the two remain independent.