pip-tools
pip-tools copied to clipboard
`pip-compile` fails, if package `pre-commit` is in requirements
This may sound odd, but it was the only way to reproduce this bug. When using the latest pip-tools (6.8.0), any pip-compile command fails as long as the package pre-commit is installed alongside. So this may be a problem with this 3rd party package. But it worked before and the bug was introduced somewhere between pip-tools 6.6.2 and 6.8.0 (edit: introduced in 6.7.0).
Sorry for this weird description. I tried to boil it down to a more digestible description. It was quite confusing to figure this out.
Environment Versions
- OS: Ubuntu 22.04 (
Linux 5.15.0-41-generic #44-Ubuntu SMP Wed Jun 22 14:20:53 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux) - Python version: 3.10.4
- pip version: 22.0.2
- pip-tools version: 6.8.0
Steps to replicate
Example repo: https://github.com/hofrob/test-pip-tools-upgrade
- check out the repo
- create a virtual env:
python -m venv venv - activate venv:
. venv/bin/activate - install packages:
pip install -r requirements.txt(it's onlypip-toolsandpre-commitplus dependencies) - run
pip-compile -o requirements.txt - or
pip-compile --upgrade --quiet - or
pip-compile --upgrade-package pip-tools --quiet
Expected result
pip-compile does not produce output and does not change the requirements file.
Actual result
$ pip-compile -o requirements.txt
Requirement already satisfied: setuptools>=40.8.0 in /usr/local/lib/python3.10/dist-packages (from -r /tmp/build-reqs-f
vosl3ot.txt (line 1)) (63.2.0)
Collecting wheel
Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/usr/local/lib/python3.10/dist-pack
ages/wheel'
Consider using the `--user` option or check the permissions.
--- Logging error ---
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/utils/logging.py", line 177, in emit
self.console.print(renderable, overflow="ignore", crop=False, style=style)
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/rich/console.py", line 1752, in print
extend(render(renderable, render_options))
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/rich/console.py", line 1390, in render
for render_output in iter_render:
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/utils/logging.py", line 134, in __rich_console__
for line in lines:
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/rich/segment.py", line 245, in split_lines
for segment in segments:
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/rich/console.py", line 1368, in render
renderable = rich_cast(renderable)
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/rich/protocol.py", line 36, in rich_cast
renderable = cast_method()
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/self_outdated_check.py", line 130, in __rich__
pip_cmd = get_best_invocation_for_this_pip()
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/utils/entrypoints.py", line 58, in get_best_invocation_fo
r_this_pip
if found_executable and os.path.samefile(
File "/usr/lib/python3.10/genericpath.py", line 101, in samefile
s2 = os.stat(f2)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/pip'
Call stack:
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.10/dist-packages/pip/__main__.py", line 31, in <module>
sys.exit(_main())
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/cli/main.py", line 70, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/cli/base_command.py", line 101, in main
return self._main(args)
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/cli/base_command.py", line 223, in _main
self.handle_pip_version_check(options)
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/cli/req_command.py", line 148, in handle_pip_version_chec
k
pip_self_version_check(session, options)
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/self_outdated_check.py", line 237, in pip_self_version_ch
eck
logger.info("[present-rich] %s", upgrade_prompt)
File "/usr/lib/python3.10/logging/__init__.py", line 1477, in info
self._log(INFO, msg, args, **kwargs)
File "/usr/lib/python3.10/logging/__init__.py", line 1624, in _log
self.handle(record)
File "/usr/lib/python3.10/logging/__init__.py", line 1634, in handle
self.callHandlers(record)
File "/usr/lib/python3.10/logging/__init__.py", line 1696, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.10/logging/__init__.py", line 968, in handle
self.emit(record)
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/utils/logging.py", line 179, in emit
self.handleError(record)
Message: '[present-rich] %s'
Arguments: (UpgradePrompt(old='22.1.2', new='22.2.1'),)
Traceback (most recent call last):
File "/home/[USERNAME]/test-pip-tools-upgrade/venv/bin/pip-compile", line 8, in <module>
sys.exit(cli())
File "/home/[USERNAME]/test-pip-tools-upgrade/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/home/[USERNAME]/test-pip-tools-upgrade/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/home/[USERNAME]/test-pip-tools-upgrade/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/[USERNAME]/test-pip-tools-upgrade/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/[USERNAME]/test-pip-tools-upgrade/venv/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/[USERNAME]/test-pip-tools-upgrade/venv/lib/python3.10/site-packages/piptools/scripts/compile.py", line 421, in cli
metadata = project_wheel_metadata(
File "/home/[USERNAME]/test-pip-tools-upgrade/venv/lib/python3.10/site-packages/build/util.py", line 53, in project_wheel_metadata
env.install(builder.build_system_requires)
File "/home/[USERNAME]/test-pip-tools-upgrade/venv/lib/python3.10/site-packages/build/env.py", line 215, in install
_subprocess(cmd)
File "/home/[USERNAME]/test-pip-tools-upgrade/venv/lib/python3.10/site-packages/build/env.py", line 80, in _subprocess
raise e
File "/home/[USERNAME]/test-pip-tools-upgrade/venv/lib/python3.10/site-packages/build/env.py", line 77, in _subprocess
subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
File "/usr/lib/python3.10/subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/tmp/build-env-cuwvmpr1/local/bin/python', '-Im', 'pip', 'install', '--use-pe
p517', '--no-warn-script-location', '-r', '/tmp/build-reqs-fvosl3ot.txt']' returned non-zero exit status 1.
By stepping back one commit and running pip-sync, I could verify that this worked before.
git reset --hard HEAD^pip-sync- run any of the above
pip-compilecommands
Eu adicionei --no-cache-dir ao final do comando e funcionou...
pip-tools 6.7.0 is also affected. Last working version is 6.6.2.
The same thing happened to me. I just uninstalled and installed the pip. The old version was installed, I have upgraded and it already works. Hope you can fix it :)
# uninstall pip
sudo pip uninstall pip
# install pip through apt
sudo apt install python3-pip
# upgrade pip to the latest version
python3 -m pip install --user --upgrade pip
Fixed this, thx @tatiana-tam.
I was not able to reproduce this on a fresh Ubuntu 22.04 VM.