chainguard-images / images

Public Chainguard Images
https://chainguard.dev/chainguard-images
Apache License 2.0
544 stars 144 forks source link

Fix python:latest-dev image #149

Closed dlorenc closed 1 year ago

dlorenc commented 1 year ago

What software would you like us to add to our image catalog? (one per issue please)

The existing python image doesn't contain pip or a shell, making it hard to use as a build container. Ideally we should be able to model a Dockerfile like this:


FROM cgr.dev/chainguard/python-dev as builder
COPY . /app
RUN pip install -r requirements.txt

FROM cgr.dev/chainguard/python
COPY --from=builder /app /app
CMD ["python", "/app/main.py"]

Or something similar.

which versions of the containerized software do you need?

No response

Add some justification for why this specific image and versions are important.

No response

tuananh commented 1 year ago

pip is there. just need to add shell i guess.

image

simon-sk commented 1 year ago

@tuananh I ran your command:

 docker run -it --rm --entrypoint pip cgr.dev/chainguard/python --version

but got the following error indicating that pip is not installed:

Traceback (most recent call last):
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 563, in from_name
    return next(cls.discover(name=name))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pip", line 33, in <module>
    sys.exit(load_entry_point('pip==22.3.1', 'console_scripts', 'pip')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/pip", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 981, in distribution
    return Distribution.from_name(distribution_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 565, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for pip
tuananh commented 1 year ago

@simon-sk lol i seriously dont know why. as you can see from the screenshot.

i just pulled the latest image and got the same message as yours

simon-sk commented 1 year ago

@tuananh I suspect that you might've had an older version of the image before that still had pip installed?

patflynn commented 1 year ago

@amouat to prioritise

nikaro commented 1 year ago

The cgr.dev/chainguard/python:latest-dev does have a shell, but not pip:

> docker run -it --rm cgr.dev/chainguard/python:latest-dev sh
/ $ python -m pip
/usr/bin/python: No module named pip
/ $ pip
Traceback (most recent call last):
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 563, in from_name
    return next(cls.discover(name=name))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pip", line 33, in <module>
    sys.exit(load_entry_point('pip==22.3.1', 'console_scripts', 'pip')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/pip", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 981, in distribution
    return Distribution.from_name(distribution_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 565, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for pip
/ $ python -c 'import pip'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pip'
amouat commented 1 year ago

Yeah, there's something broken in the pip3 package. Let's get this fixed.

patflynn commented 1 year ago

I think @kaniini mentioned this may be fixed by a build that was happening today.

patflynn commented 1 year ago

related https://github.com/chainguard-images/images/issues/241

patflynn commented 1 year ago

should be fixed in our latest build.