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

No longer able to install in python:alpine docker container #232

Closed
tarrenj opened this issue Mar 15, 2021 · 12 comments
Closed

No longer able to install in python:alpine docker container #232

tarrenj opened this issue Mar 15, 2021 · 12 comments

Comments

@tarrenj
Copy link

tarrenj commented Mar 15, 2021

Hello!

Late last week my containers were building fine, but they're no longer building. I've been able to reproduce the build error with docker run -it python:alpine pip3 install greenlet

It looks like the failing line is: gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python3.9 -c src/greenlet/greenlet.c -o build/temp.linux-x86_64-3.9/src/greenlet/greenlet.o resulting in error: command 'gcc' failed: No such file or directory

sprunge link of the full build error

@jamadden
Copy link
Contributor

There have been no changes to greenlet since the last release in January, so if something changed I don't think it is on greenlet's part.

It's not possible to distribute compiled, native, binary wheels on PyPI for Alpine Linux (in general, any distribution not based on glibc), so people using those platforms together with native Python extensions (typically written in C, like greenlet is) will need to be sure their platform has a functioning compiler toolchain, or arrange to build and host binary wheels somewhere else. In this case, it looks like the container is missing the basic compiler toolchain (gcc).

@tarrenj
Copy link
Author

tarrenj commented Mar 15, 2021

Thanks for the info. I'm actually installing the cryptography module into the same container, so I've added the following line: apk --no-cache add gcc musl-dev libffi-dev openssl-dev python3-dev and am still getting the same issue. You can reproduce that with this dockerfile:

from python:alpine
RUN apk --no-cache add gcc musl-dev libffi-dev openssl-dev python3-dev
RUN pip3 install greenlet

I'll start looking into what changed in the latest version of the container now.

@tarrenj
Copy link
Author

tarrenj commented Mar 15, 2021

Actually, I'm going to close this out since the change wasn't in greenlet. Thanks!

@tarrenj tarrenj closed this as completed Mar 15, 2021
@pbhoiwala
Copy link

@tarrenj Have you been able to figure out what is causing this issue? I am running into the same error. I am not sure which one of my dependencies is using greenlet but I see this error

 Building wheel for greenlet (setup.py): started
  Building wheel for greenlet (setup.py): finished with status 'error'
�[91m  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ltznfszi/greenlet_8f396f618d3448d3b7391fca38d47f87/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ltznfszi/greenlet_8f396f618d3448d3b7391fca38d47f87/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-271j_lm4
       cwd: /tmp/pip-install-ltznfszi/greenlet_8f396f618d3448d3b7391fca38d47f87/

and then this

        building 'greenlet.tests._test_extension_cpp' extension
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -Isrc/greenlet/ -I/usr/local/include/python3.8 -c src/greenlet/tests/_test_extension_cpp.cpp -o build/temp.linux-x86_64-3.8/src/greenlet/tests/_test_extension_cpp.o
  gcc: fatal error: cannot execute 'cc1plus': execvp: No such file or directory
  compilation terminated.
  error: command 'gcc' failed with exit status 1

I'd appreciate any help

@tarrenj
Copy link
Author

tarrenj commented Mar 17, 2021

@pbhoiwala This popped up in my work stuff and I'm on a tight deadline, so I just switched to the python:3.8 image for the time being.

If I had more time to look into it I'd start by looking at the latest changes to the official image and see if I notice anything that stands out. Another good option would be opening a shell in a python:alpine and checking for the missing directories manually. This may be as simple as needing to /bin/mkdir before installing greenlet.

I hope to switch back to the Alpine image soon, if I can find the time to do that I'll update here.

Also, I just saw this and it may be of interest to you: https://pythonspeed.com/articles/alpine-docker-python/

@pbhoiwala
Copy link

@tarrenj Thank you very much for the help. I appreciate it.

@tarrenj
Copy link
Author

tarrenj commented Aug 4, 2021

Does anyone know if building on the latest Alpine image is successful again?

@mholubinka1
Copy link

@tarrenj had the same issue installing greenlet as a dependency for bcrypt with flask. Adding g++ as part of the compiler toolchain fixed it.

@tarrenj
Copy link
Author

tarrenj commented Aug 10, 2021

@mholubinka1 Thanks for the additional information!

@futurerahul
Copy link

@mholubinka1 how did you add g++ compiler toolchain?

@dejurin
Copy link

dejurin commented Sep 1, 2021

@mholubinka1 how did you add g++ compiler toolchain?

RUN apk add build-base

my code below

RUN apk add build-base

RUN apk add --no-cache supervisor \
    && python -m pip install --upgrade pip \
    && pip install -r /requirements.txt

@Aatmjeet
Copy link

Aatmjeet commented Sep 7, 2021

@dejurin thanks mate, it worked for me!

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

7 participants