Skip to content

Support building from sdists#2163

Open
matthewfeickert wants to merge 2 commits intoPlasmaControl:masterfrom
matthewfeickert:build/pacakge-build-requirements
Open

Support building from sdists#2163
matthewfeickert wants to merge 2 commits intoPlasmaControl:masterfrom
matthewfeickert:build/pacakge-build-requirements

Conversation

@matthewfeickert
Copy link
Copy Markdown

@matthewfeickert matthewfeickert commented Apr 15, 2026

Current building from sdists are broken as desc-opt's requirements are read in from a requirements file

DESC/setup.py

Lines 14 to 15 in 03637dd

with open(os.path.join(here, "requirements.txt"), encoding="utf-8") as f:
requirements = f.read().splitlines()

and that requirements.txt file is not packaged

DESC/MANIFEST.in

Lines 1 to 3 in 03637dd

include versioneer.py
include desc/_version.py
include desc/examples/*.h5

$ docker run --rm -ti ghcr.io/prefix-dev/pixi:latest 
root@01c631f2ee1c:/# pixi global install uv
└── uv: 0.11.6 (installed)
    └─ exposes: uv, uvx
root@01c631f2ee1c:/# uv venv
Using CPython 3.14.4
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
root@01c631f2ee1c:/# . .venv/bin/activate
(.venv) root@01c631f2ee1c:/# uv pip install --no-binary desc-opt desc-opt
Resolved 73 packages in 2.56s
      Built pylatexenc==2.10
      Built nvgpu==0.10.0
  x Failed to build `desc-opt==0.17.1`
  |-> The build backend returned an error
  `-> Call to `setuptools.build_meta.build_wheel` failed (exit status: 1)

      [stderr]
      Traceback (most recent call last):
        File "<string>", line 14, in <module>
          requires = get_requires_for_build({})
        File "/root/.cache/uv/builds-v0/.tmpf5EHdi/lib/python3.14/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/root/.cache/uv/builds-v0/.tmpf5EHdi/lib/python3.14/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
          self.run_setup()
          ~~~~~~~~~~~~~~^^
        File "/root/.cache/uv/builds-v0/.tmpf5EHdi/lib/python3.14/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
          ~~~~^^^^^^^^^^^^^^^^
        File "<string>", line 14, in <module>
          requires = get_requires_for_build({})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/uv/sdists-v9/pypi/desc-opt/0.17.1/_C0PgcgtxBLzcxbueY_K1/src/requirements.txt'

      hint: This usually indicates a problem with the package or the build environment.
(.venv) root@01c631f2ee1c:/#

In addition to noticing requirements.txt absence from MANIFEST.in we can also manually check

$ curl -sLO https://files.pythonhosted.org/packages/88/86/1057bcddd2648f492b2820b1eca06ed9e77626ab8b7fcfede06b2c4b8ec1/desc_opt-0.17.1.tar.gz
$ tar -ztvf ./desc_opt-0.17.1.tar.gz | grep requirements.txt  # no output

We can see that this works now as expected by building the sdist and wheel distributions and then inspecting the sdist

$ rm -rf dist/* *.egg* && uvx --from build pyproject-build
$ python -m tarfile --list dist/*.tar.gz | grep requirements
desc_opt-0.17.1+14.gfebd4184c/requirements.txt

This PR fixes that by ensuring the required packages are include in setuptools manifest.


  • requirements-dev.txt is not used anywhere in the setuptools build system implementation and is not packaged so it should not be used in setup.py.
  • Remove wheel from build-system.requires as that is now redundant.
  • Update setuptools to v42 to conform with modern standards.
  • Add requirements.txt to setuptools manifest.

Note, this is effectively the same PR as f0uriest/orthax#92.

* requirements-dev.txt is not used anywhere in the setuptools build system
  implimentation and is not packaged so it should not be used in setup.py.
* Remove wheel from build-system.requires as that is now redundant.
   - c.f. https://learn.scientific-python.org/development/guides/packaging-classic/
* Update setuptools to v42 to conform with modern standards.
* As requirements.txt is read in the setuptools-based build to provide
  the install_require it must be pacakged with the sdist to provide a non-broken
  sdist.
@matthewfeickert
Copy link
Copy Markdown
Author

This is ready for review, but needs a maintainer to approve the CI runs. Let me know if you have any questions. 👍

Comment thread pyproject.toml
[build-system]
# These are the assumed default build requirements from pip:
# https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
requires = ["setuptools>=40.8.0", "wheel", "versioneer-518"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How recently did wheel become redundant? Some clusters come with an old version of pip, unless you update it manually (I am not sure if our users do). If this is not causing any trouble (or big overhead), I am fine keeping it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YigitElma pip has nothing to do with wheel. Note from https://learn.scientific-python.org/development/guides/packaging-classic/#pep-517518-support-high-priority (in the context of PEP 517/518 support)

Note that "wheel" is never required; it was injected automatically by setuptools in older versions, and is no longer used at all.

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.

2 participants