Search code examples
pythondockerpip-tools

pip-compile raising AssertionError on its logging handler


I have a dockerfile that currently only installs pip-tools

FROM python:3.9

RUN pip install --upgrade pip && \
    pip install pip-tools

COPY ./ /root/project

WORKDIR /root/project

ENTRYPOINT ["tail", "-f", "/dev/null"]

I build and open a shell in the container using the following commands:

docker build -t brunoapi_image .
docker run --rm -ti --name brunoapi_container --entrypoint bash brunoapi_image

Then, when I try to run pip-compile inside the container I get this very weird error (full traceback):

root@727f1f38f095:~/project# pip-compile
Traceback (most recent call last):
  File "/usr/local/bin/pip-compile", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/piptools/scripts/compile.py", line 342, in cli
    repository = PyPIRepository(pip_args, cache_dir=cache_dir)
  File "/usr/local/lib/python3.9/site-packages/piptools/repositories/pypi.py", line 106, in __init__
    self._setup_logging()
  File "/usr/local/lib/python3.9/site-packages/piptools/repositories/pypi.py", line 455, in _setup_logging
    assert isinstance(handler, logging.StreamHandler)
AssertionError

I have no clue what's going on and I've never seen this error before. Can anyone shed some light into this?

Running on macOS Monterey


Solution

  • It is a bug, you can downgrade using:

    pip install "pip<22"

    https://github.com/jazzband/pip-tools/issues/1558