Skip to content

Remove setup.py in favor of pyproject.toml - #816

Open
albertvillanova wants to merge 1 commit into
mainfrom
remove-setup-py
Open

Remove setup.py in favor of pyproject.toml#816
albertvillanova wants to merge 1 commit into
mainfrom
remove-setup-py

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Aug 18, 2026

Copy link
Copy Markdown
Member

This PR removes setup.py, leaving pyproject.toml as the single source of packaging configuration.

Motivation

Since #636, pyproject.toml declares a complete [project] table, which setuptools treats as authoritative for the package metadata. setup.py has been unused for metadata ever since, and it has drifted accordingly:

Keeping it around is actively misleading: #785 edited setup.py to fix a missing ruff dependency and had no effect at all, because the built metadata comes from pyproject.toml (see #815).

Solution

While the [project] metadata was already coming from pyproject.toml, two settings in setup.py were still load-bearing, and both need to be migrated.

1. package_data. setup.py declared:

package_data={"doc_builder": ["mock_deps/*.txt"]},

MANIFEST.in does not cover mock_deps, so without this declaration the mock-deps registry files are silently dropped from the wheel, and doc-builder light-install <package> --check then fails:

No mock-deps registry entry for `accelerate` (expected .../site-packages/doc_builder/mock_deps/accelerate.txt); do a full install instead.

It is therefore ported to pyproject.toml as [tool.setuptools.package-data]. mock_deps is the only directory under src/doc_builder holding 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 of setup.py, and it is load-bearing too: locate_kit_folder uses it as its second strategy to find the kit folder, after looking next to the installed module. In the documentation build workflows the package is installed non-editably and doc-builder build runs from the repo checkout, so the first strategy fails and this second one is what resolves kit locally. Removing setup.py without touching it would silently fall through to get_cached_repo, which clones doc-builder from GitHub, adding a network dependency to every documentation build.

It is switched to identify the repo from pyproject.toml instead. A plain string check is used rather than parsing TOML, to avoid depending on tomllib, which is only available from Python 3.11 while the project supports 3.10.

Verified by reproducing the workflow layout (non-editable install, doc-builder invoked from the repo checkout): locate_kit_folder still resolves to the local kit folder and performs no clone. With the previous setup.py-based check it returns False and 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 main produces an identical set of files, and the only metadata difference is that two legacy fields are no longer emitted:

- Home-page: https://github.com/huggingface/doc-builder
- Author: Hugging Face, Inc.

Both are already covered by their modern equivalents, which pyproject.toml declares and which are what PyPI displays:

Author-email: "Hugging Face, Inc." <docs@huggingface.co>
Project-URL: Homepage, https://github.com/huggingface/doc-builder

Finally, setup.py carried the release checklist in trailing comments. It is moved to RELEASE.md rather than dropped, with the version locations updated to pyproject.toml and the deprecated python setup.py bdist_wheel/sdist invocations replaced by uv build.

Changes

  • Remove setup.py
  • Declare mock_deps/*.txt as package data in pyproject.toml
  • Identify the doc-builder repo from pyproject.toml instead of setup.py in is_doc_builder_repo
  • Move the release checklist from setup.py comments to RELEASE.md, updated for pyproject.toml and uv build

Notes

The documentation build workflows check out huggingface/doc-builder without a ref and then run git pull origin main before uv pip install ., so they always install the current main, regardless of the commit a consumer pins the reusable workflow to. Pinning build_main_documentation.yml@<sha> freezes the workflow file only, not the doc-builder code 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant