3

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

Buzz
  • 1,102
  • 1
  • 9
  • 24
  • Hey, I actually get the same error when trying to run pip install -e my_package_path. Is there any chance you found a solution to the problem? – mayool Sep 15 '22 at 16:03
  • 2
    For a project using `pyproject.toml` only, editable installation s require `pip>=21.3`. MAYBE this can help. See this answer for a better understanding https://stackoverflow.com/a/69711730/5321862 – Buzz Sep 16 '22 at 04:51

0 Answers0