Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with pip install in 3.12 slim #869

Closed
sudhirbits opened this issue Oct 3, 2023 · 7 comments
Closed

Issue with pip install in 3.12 slim #869

sudhirbits opened this issue Oct 3, 2023 · 7 comments

Comments

@sudhirbits
Copy link

Hi I am using gitlab ci for build. which uses the python:slim image (which is currently version 3.12)

Building wheels for collected packages: aiohttp, frozenlist, multidict, yarl
Building wheel for aiohttp (pyproject.toml): started
Building wheel for aiohttp (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error

× Building wheel for aiohttp (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [97 lines of output]
...
gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/usr/local/include/python3.12 -c aiohttp/_websocket.c -o build/temp.linux-x86_64-cpython-312/aiohttp/_websocket.o
error: command 'gcc' failed: No such file or directory
[end of output]

Please note that using python:3.11-slim for the gitlab ci docker image solves the issue.

@ad-m-ss
Copy link

ad-m-ss commented Oct 3, 2023

I do not think gcc is expected for any *-slim image. I suggest to use multi-stage build images and create wheel from 3.11 and using it in 3.11-slim. Something like:

ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION} AS build
COPY ./requirements.txt .
RUN --mount=type=cache,target=/var/cache/buildkit/pip \
    pip wheel --wheel-dir /wheels -r requirements.txt

FROM python:${PYTHON_VERSION}-slim
COPY requirements.txt ./
COPY --from=build /wheels /wheels
RUN --mount=type=cache,target=/var/cache/buildkit/pip \
    pip install --find-links /wheels --no-index -r requirements.txt

@rowanho
Copy link

rowanho commented Oct 4, 2023

Getting the same issue for slim-bullseye, gcc doesn't work on 3.12 but does on the 3.11 image.

@WestleyB
Copy link

WestleyB commented Oct 4, 2023

Hello,
I have the same issue since yesterday with the image python:latest.

I got the following issue related to gcc during the build:

`gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/usr/local/include/python3.12 -c src/pymssql/_mssql.c -o build/temp.linux-x86_64-cpython-312/src/pymssql/_mssql.o -DMSDBLIB
src/pymssql/_mssql.c:1197:10: fatal error: sqlfront.h: No such file or directory
1197 | #include "sqlfront.h"
| ^~~~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1

...

Failed to build uamqp aiohttp pymssql
ERROR: Could not build wheels for uamqp, aiohttp, pymssql, which is required to install pyproject.toml-based projects

failed to solve: process "/bin/sh -c pip3 install --no-cache-dir -r requirements.txt" did not complete successfully: exit code: 1`

@Nitrousoxide
Copy link

I was able to build the application successfully on python:3-alpine but it would fail in the test phase.

$ docker run --entrypoint /usr/local/bin/jncep $CI_REGISTRY_IMAGE:$TAG_COMMIT
Traceback (most recent call last):
  File "/usr/local/bin/jncep", line 5, in <module>
    from jncep.jncep import main
  File "/usr/local/lib/python3.12/site-packages/jncep/jncep.py", line 6, in <module>
    from .cli.config import config_manage
  File "/usr/local/lib/python3.12/site-packages/jncep/cli/config.py", line 5, in <module>
    from .. import config, track, utils
  File "/usr/local/lib/python3.12/site-packages/jncep/track.py", line 11, in <module>
    from . import config, core, jncweb, spec, utils
  File "/usr/local/lib/python3.12/site-packages/jncep/core.py", line 17, in <module>
    from . import epub, jnclabs, jncweb, spec, utils
  File "/usr/local/lib/python3.12/site-packages/jncep/jnclabs.py", line 6, in <module>
    import asks
  File "/usr/local/lib/python3.12/site-packages/asks/__init__.py", line 5, in <module>
    from .base_funcs import *
  File "/usr/local/lib/python3.12/site-packages/asks/base_funcs.py", line 8, in <module>
    from .sessions import Session
  File "/usr/local/lib/python3.12/site-packages/asks/sessions.py", line 16, in <module>
    from .request_object import RequestProcessor
  File "/usr/local/lib/python3.12/site-packages/asks/request_object.py", line 31, in <module>
    _BOUNDARY = "8banana133744910kmmr13a56!102!" + str(randint(1e3, 9e3))
                                                       ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/random.py", line 336, in randint
    return self.randrange(a, b+1)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/random.py", line [30](https://{gitlab-selfhosted-url}/-/jobs/4278#L30)1, in randrange
    istart = _index(start)
             ^^^^^^^^^^^^^
TypeError: 'float' object cannot be interpreted as an integer

Rolling back to 3.11-alpine has it successfully build and test though.

@avh03
Copy link

avh03 commented Oct 7, 2023

Just wanted to confirm that 3.12 broke my builds with all sorts of rather cryptographic errors, rolled back to 3.11-slim and everything went back to normal.

@LaurentGoderre
Copy link
Member

@sudhirbits It seems to be a known issue with aiohttp in 3.12. Someone has a workaround here but I have not tested it

aio-libs/aiohttp#7229 (comment)

@tianon
Copy link
Member

tianon commented Dec 7, 2023

See #862 (comment) and #882 (comment):

Earlier versions of 3.11 accidentally included dev packages that weren't mean to be part of the image and it was fix in #858.

The non-slim images are "batteries included" based on https://hub.docker.com/_/buildpack-deps, ...:

The main tags of this image are the full batteries-included approach. With them, a majority of arbitrary gem install / npm install / pip install should be successful without additional header/development packages.

...

The "slim" tags are then the antithesis to that: namely, not batteries included, and having only the bare minimum installed.

@tianon tianon closed this as completed Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants