docker-library / python

Docker Official Image packaging for Python

Home Page:https://www.python.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inexplicable pip install caching behavior

maxupp opened this issue · comments

I have been bashing my head against this for hours. I build my Docker image based on python:3.12, and then install my package like this:

FROM python:3.12

RUN mkdir /build
COPY pyproject.toml /build/pyproject.toml
COPY src /build/src

# set up access token usage
ARG ACCESS_TOKEN=*******************************
RUN git config --global url."https://${ACCESS_TOKEN}@github".insteadOf ssh://git@github

WORKDIR build
RUN pip install --force-reinstall --no-cache-dir .

One of my dependencies in the pyproject.toml is directly from a git repository, with a specified version tag.

dependencies = [ "boto3", "itsdangerous", "jsonref", "pydantic", "python-dotenv", "PyYAML", "typing", "websockets", "*** @ git+ssh://git@github.com/********@v2.2.0" ]

But whatever I do, I can't get pip to install the correct version of the package. I have cleared any cache I can think of, but for some reason I always end up with an old version.

PROBABLE FACTOR: The old version and the tagged version share the same version number within the pyproject.toml, due to an oversight I cannot fix right now. I will bump the version in the near future and I suspect that will make this whole issue go away.

But I really need to know what is happening here, since I'm questioning my sanity.

I'm afraid I'm at a total loss -- you'll possibly have better luck in a dedicated support forum, especially one with deeper PIP experience. 😅

The best I can offer is perhaps trying docker build --no-cache which should disable any Docker cache (and your Dockerfile shouldn't have any other cache available unless it's inside src itself)?