question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FR] User configurable get_requires_for_build_wheel and get_requires_for_build_sdist

See original GitHub issue

What’s the problem this feature will solve?

https://github.com/pypa/setuptools/issues/2823 proposes to remove the legacy setup_requires option. Currently, setup_requires can be set statically (which has been replaced by the requires key in pyproject.toml), or dynamically during the running of the setup.py file. This latter method of dynamically setting the build requirements can be replaced more cleanly by the two optional PEP 517 hooks get_requires_for_build_wheel and get_requires_for_build_sdist. Currently setuptools does not allow users to override and/or set the output of these hooks.

Describe the solution you’d like

I’m not proposing a specific solution (I suspect the best solution will be the one that best matches what users need, and aligns with the internal design of setuptools), but here are three possible designs:

  1. Add two new arguments to setuptools.setup: sdist_requires and wheel_requires. These would be lists of requirements, similar to install_requirements. This would likely be the least change to existing setup.py files, but what that implies for the internal flow of setuptools is unclear. Additionally, this does not pass config_settings to the user code, which could be desired by users. It would be assumed that the presence of sdist_requires and wheel_requires would override setup_requires whilst that option was allowed.

  2. Like 1, but instead of the options being lists of requirements, instead a function matching the interface of the PEP 517 hooks would be given. This does require more changes to user code, but means that the user code can handle config_settings. I’m not sure there’s much difference between 1 and 2 from a setuptools internal-design perspective though (as both are being handled completely within the setup.py module).

  3. Add sdist_requires and wheel_requires to setup.cfg. The values would follow the same format as build-backend from PEP 517, with the callables being pointed to matching the interface of the relevant hook. Depending on the internals of setuptools, this could allow setuptools to only run the setup.py file on the mandatory hooks.

Alternative Solutions

No response

Additional context

This came from https://github.com/pypa/setuptools/issues/2823, from what I can see there’s not been a discussion around this.

I’m also not aware of build backends using this in anger, last time I surveyed the ecosystem none of the backends provided a way to set this, so I wouldn’t be surprised if this causes some breakage in some frontends (even if it is part of PEP 517).

Code of Conduct

  • I agree to follow the PSF Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
laydaycommented, Nov 19, 2021

(Please don’t put . on the path, create a dedicated folder.)

1reaction
abravalhericommented, Nov 19, 2021

Hi @aragilar, have you considered adding a thin layer on top of setuptools.build_meta as defined in https://www.python.org/dev/peps/pep-0517/#in-tree-build-backends?

For example, you could have a _build_backend.py file:

from setuptools import build_meta as _orig

prepare_metadata_for_build_wheel = _orig.prepare_metadata_for_build_wheel
build_wheel = _orig.build_wheel
build_sdist = _orig.build_sdist


def get_requires_for_build_wheel(self, config_settings=None):
    return _orig.get_requires_for_build_wheel(config_settings) + [...]


def get_requires_for_build_sdist(self, config_settings=None):
    return _orig.get_requires_for_build_sdist(config_settings) + [...]

and then tell the front-end to use it via pyproject.toml

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "_build_backend"
backend-path = ["."]
Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found