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.

System setuptools leaks into isolated build environment

See original GitHub issue

Description

My project uses a custom in-tree build backend that wraps setuptools.build_meta and its build-system hooks implementation. I’m trying to add support for editable installs. I’m running on a Fedora 36 box, and the system has setuptools 59 installed via the system package manager. Therefore, I request a higher setuptools version in pyproject.toml. Looks like pip actually installs the higher setuptools, but eventually the older one from the system is picked.

Expected behavior

pip should use the requested version of setuptools.

pip version

22.2.2

Python version

3.10

OS

Fedora Linux 36

How to Reproduce

  • pyproject.toml
[project]
name = "foo"
version = "0.0.1"

[build-system]
requires = ["setuptools >= 64"]
build-backend = "builder"
backend-path = ["."]
  • builder.py
def get_requires_for_build_editable(config_settings=None):
    import setuptools
    assert 0, f"{setuptools.__version__} {setuptools}"
    from setuptools import build_meta as backend
    return backend.get_requires_for_build_editable(
        config_settings,
    )

def prepare_metadata_for_build_editable(
    metadata_directory,
    config_settings=None,
):
    from setuptools import build_meta as backend
    return backend.prepare_metadata_for_build_editable(
        metadata_directory,
        config_settings,
    )

def build_editable(
    wheel_directory,
    config_settings=None,
    metadata_directory=None,
):
    from setuptools import build_meta as backend
    return backend.build_editable(
        wheel_directory,
        config_settings,
        metadata_directory,
    )

Note the line assert 0, f"{setuptools.__version__} {setuptools}" in get_requires_for_build_editable()! I need that line to easily show the root of the issue.

Output

Use `pip` to install in editable mode:


$ pip install -e .
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/dalcinl/tmp/pip-bug
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [10 lines of output]
      Traceback (most recent call last):
        File "/home/dalcinl/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/home/dalcinl/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/dalcinl/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 144, in get_requires_for_build_editable
          return hook(config_settings)
        File "/home/dalcinl/tmp/pip-bug/builder.py", line 3, in get_requires_for_build_editable
          assert 0, f"{setuptools.__version__} {setuptools}"
      AssertionError: 59.6.0 <module 'setuptools' from '/usr/lib/python3.10/site-packages/setuptools/__init__.py'>
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Note the AssertionError line:

AssertionError: 59.6.0 <module 'setuptools' from '/usr/lib/python3.10/site-packages/setuptools/__init__.py'>

I requested "setuptools >= 64" in my requirement, but the older system-wide setuptools is being used.



### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
pradyunsgcommented, Sep 2, 2022

I explicitly state that I DO NOT AGREE with being forced to agree with the PSF Code of Conduct to submit this issue. I ticked the box just because I cannot continue otherwise. I hope this requirement for issue submission is an oversight. If not, please close this issue and ignore my report.

It’s not an oversight. Making users explicitly opt in is an intentional choice.

Regardless of what you say, you’re expected to follow the PSF CoC while interacting in this project’s online spaces (and setuptools’). If you violate the CoC in your interactions here at any point, we’ll take action according to the CoC as well. If you have concerns around that, you’re free to not interact with the project. 😃

0reactions
pradyunsgcommented, Sep 23, 2022

Consolidating this into https://github.com/pypa/pip/issues/6264.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Packaging - Scikit-HEP
This completely changes your build process if you have Pip 10 or later (you can disable it with --no-build-isolation in special cases, like...
Read more >
Frequently Asked Questions - PyScaffold
If you still want to remove setuptools_scm (a build-time dependency we add by default), it's actually really simple: Within setup.py just remove the ......
Read more >
Example of setup.py, CMakeLists.txt and pyproject.toml
Starting with pip 10.0, pip reads the pyproject.toml file and installs the associated dependencies in an isolated environment. See the pip build system...
Read more >
Options to build the same package in different ways (with ...
For some packages, we really need to have different builds (producing different wheels), with different build dependencies.
Read more >
Easy Install - setuptools 65.6.3.post20221220 documentation
Easy Install is a python module ( easy_install ) bundled with setuptools that lets you automatically download, build, install, and manage Python packages....
Read more >

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