Buzz
Buzz

Reputation: 1422

Getting requirements to build wheel did not run successfully. Exit code: 1

I have two projects, MyPyLib and MyApp; As the made-up name suggest, MyApp needs a set of tools contained in MyLib. I'm using setuptools as build system.

The package MyPyLib, with the pyproject.toml:

[build-system]
requires = [
    "setuptools >= 42",  # At least v42 of setuptools required!
    "versioningit",
]
build-backend = "setuptools.build_meta"

[project]
name = "MyPyLib"
authors = [...]
description = "MyPyLib Description"
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.8"
classifiers = [
    "Programming Language :: Python :: 3.8",
    "License :: OSI Approved :: MIT License",
    "Operating System :: OS Independent",
]
dependencies = [
    "StrEnum"
]
dynamic = ["version"]

[project.optional-dependencies]
Video=[
    "opencv-python-headless>=4.6",
    "webcolors>=1.12",
    "numpy"
]
Maths=[
    "numpy", "scipy", "pandas", "Pillow"
]
Graphs=["pyqtgraph", "matplotlib"]
GUI=["PySide2", "pyqtgraph"]
Controller=["pyserial"]

[tool.versioningit]

[tool.versioningit.format]
distance = "{base_version}"
dirty = "{base_version}"
distance-dirty = "{base_version}"

The build command python -m build runs correctly, it generates the wheel file, and this file is correctly installed into MyApp virtual environment via pip install /path/to/wheel/MyPyLibXXXX.whl

However, since I need to install it as editable, when I run (in MyApp venv) pip install -e /path/to/mypylib (the directory is the root that contains the pyproject.toml), I got this error:

Obtaining file:///home/my-user/workspace/mypylib
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [32 lines of output]
      Traceback (most recent call last):
        File "/home/my-user/workspace/virtualenvs/MyApp/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/home/my-user/workspace/virtualenvs/MyApp/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/my-user/workspace/virtualenvs/MyApp/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 147, in get_requires_for_build_wheel
          return self._get_build_requires(
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 128, in _get_build_requires
          self.run_setup()
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 143, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 13, in <module>
          setup(
        File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 143, in setup
          _install_setup_requires(attrs)
        File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 131, in _install_setup_requires
          dist = distutils.core.Distribution(dict(
        File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 447, in __init__
          _Distribution.__init__(self, {
        File "/usr/lib/python3.8/distutils/dist.py", line 292, in __init__
          self.finalize_options()
        File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 740, in finalize_options
          ep.load()(self)
        File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2444, in load
          self.require(*args, **kwargs)
        File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2467, in require
          items = working_set.resolve(reqs, env, installer, extras=self.extras)
        File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 792, in resolve
          raise VersionConflict(dist, req).with_context(dependent_req)
      pkg_resources.VersionConflict: (importlib-metadata 1.5.0 (/usr/lib/python3/dist-packages), Requirement.parse('importlib-metadata>=3.6; python_version < "3.10"'))
      [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 wheel 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.

I'm not really sure about what's going on there.

Edit 1: include-system-site-packages = true was the problem, but...

Editable install works fine if include-system-site-packages is false in MyApp virtual environment. Still can't figure what's going on out

Upvotes: 5

Views: 33214

Answers (1)

Mike Williamson
Mike Williamson

Reputation: 3260

This is hard to mimic exactly, since as you said, you've just provided dummy examples.

But as the error says, there is a version conflict:

pkg_resources.VersionConflict: (importlib-metadata 1.5.0 (/usr/lib/python3/dist-packages), Requirement.parse('importlib-metadata>=3.6; python_version < "3.10"'))
  • It is saying that a version of importlib-metadata>=3.6 cannot be found that works with Python less than 3.10.
    • But I don't understand this, since I actually have such a thing installed:
> python3.8 -m pip show importlib-metadata
Name: importlib-metadata
Version: 4.6.4
Summary: Read metadata from Python packages
Home-page: https://github.com/python/importlib_metadata
Author: Jason R. Coombs
Author-email: [email protected]
License: UNKNOWN
Location: /usr/lib/python3/dist-packages
Requires: 
Required-by:

However, there is a backported version which maybe your machine is somehow using instead, accidentally.

If you look in the documentation there, you'll see a compatibility table that says:

importlib_metadata stdlib
7.0 3.13
6.5 3.12
4.13 3.11
4.6 3.10
1.4 3.8

So, this importlib_metadata seems to suggest that there is, indeed, no version >=3.6, as per your error. So it looks like somehow the editable version is getting confused with which importlib.metadata to import.

Upvotes: 0

Related Questions