uv icon indicating copy to clipboard operation
uv copied to clipboard

Using uv with internal libraries fails with `No module named 'pip'`

Open wsantos opened this issue 1 year ago • 2 comments

We are trying to implement UV in our pip line bot we are getting this error for one of out libraries:

error: Failed to build editables
  Caused by: Failed to build editable: file:///Users/wsantos/projetos/xxxxxx/xxxxxxx
  Caused by: Build backend failed to build wheel through `build_editable()`:
--- stdout:

--- stderr:
Traceback (most recent call last):
  File "<string>", line 12, in <module>
ModuleNotFoundError: No module named 'pip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "/private/var/folders/x_/cw97nxxx13q_f1fscwrs7g9r0000gn/T/.tmphBj6Wg/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 436, in build_editable
    return self._build_with_temp_dir(
  File "/private/var/folders/x_/cw97nxxx13q_f1fscwrs7g9r0000gn/T/.tmphBj6Wg/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 389, in _build_with_temp_dir
    self.run_setup()
  File "/private/var/folders/x_/cw97nxxx13q_f1fscwrs7g9r0000gn/T/.tmphBj6Wg/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 480, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/private/var/folders/x_/cw97nxxx13q_f1fscwrs7g9r0000gn/T/.tmphBj6Wg/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 311, in run_setup
    exec(code, locals())
  File "<string>", line 14, in <module>
ModuleNotFoundError: No module named 'pip'

How can I fix it, I see some others issues about it but none told how we can fix it.

wsantos avatar Feb 16 '24 23:02 wsantos

Thanks! Is this a library you all control? It looks like it depends on "pip". Does it declare "pip" as a build requirement, in the pyproject.toml?

charliermarsh avatar Feb 16 '24 23:02 charliermarsh

Thanks! Is this a library you all control? It looks like it depends on "pip". Does it declare "pip" as a build requirement, in the pyproject.toml?

Yeap we control it, we don't have a pyproject.toml how should I do it, we do have setup.py

wsantos avatar Feb 17 '24 02:02 wsantos

This is a surprising workaround:

➜  uv pip install pip
Resolved 1 package in 176ms
Installed 1 package in 16ms
 + pip==24.0

ArturFormella avatar Mar 23 '24 22:03 ArturFormella

Add a pyproject.toml with something like:

[build-system]
requires = ["setuptools", "wheel", "pip"]
build-backend = "setuptools.build_meta"

(and keep your existing setup.py as-is)

hauntsaninja avatar Mar 23 '24 22:03 hauntsaninja

Closing since @hauntsaninja suggestion is what you're looking for!

charliermarsh avatar Apr 04 '24 03:04 charliermarsh