GOOGLE ADS

Dienstag, 26. April 2022

Docker kann Flask-Bcrypt nicht mit python:3.11-rc-alpine3.14 installieren

Ich versuche, die folgende Dockerfile mit der requirments.txt auszuführen. Anscheinend schlägt es beim Versuch fehl, Flask-bycrypt zu installieren.

Ich habe viele Antworten gelesen und versucht, die Entwicklungsbibliotheken hinzuzufügen oder sogar auf Pip 21.2.4 oder höher zu aktualisieren, kann eine mögliche Lösung sein, aber es hat bei mir nicht geklappt.

Dockerdatei:

FROM python:3.11-rc-alpine3.14
LABEL MAINTAINER="Firstname lastname <Firstname.lastname@gmail.com>"
ENV GROUP_ID=1000 \
USER_ID=1000
RUN apk add libffi-dev
RUN apk add --no-cache python3-dev && pip3 install --upgrade pip
WORKDIR /var/www/
ADD. /var/www/
RUN pip3 --no-cache-dir install -r requirements.txt
RUN pip3 install gunicorn
RUN addgroup -g $GROUP_ID www
RUN adduser -D -u $USER_ID -G www www -s /bin/sh
USER www
EXPOSE 5000
CMD [ "gunicorn", "-w", "4", "--bind", "0.0.0.0:5000", "wsgi"]

Die requirments.txt sieht wie folgt aus:

...
bcrypt==3.2.0
Flask-Bcrypt==1.0.1
Flask==2.0.3
...

Und das Folgende sind die Fehler beim Ausführen von docker compose.

RUN pip3 --no-cache-dir install -r requirements.txt:      
#13 0.907 Collecting bcrypt==3.2.0
#13 1.010 Downloading bcrypt-3.2.0-cp36-abi3-musllinux_1_1_x86_64.whl (61 kB)
#13 1.033 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.6/61.6 KB 3.1 MB/s eta 0:00:00
#13 1.148 Collecting Flask-Bcrypt==1.0.1
#13 1.167 Downloading Flask_Bcrypt-1.0.1-py3-none-any.whl (6.0 kB)
#13 1.213 Collecting Flask-JWT-Extended==4.3.1
#13 1.250 Downloading Flask_JWT_Extended-4.3.1-py2.py3-none-any.whl (20 kB)
#13 1.326 Collecting Flask-RESTful==0.3.9
#13 1.342 Downloading Flask_RESTful-0.3.9-py2.py3-none-any.whl (25 kB)
#13 1.382 Collecting python-dotenv==0.20.0
#13 1.398 Downloading python_dotenv-0.20.0-py3-none-any.whl (17 kB)
#13 1.444 Collecting flask-mongoengine==1.0.0
#13 1.462 Downloading flask_mongoengine-1.0.0-py3-none-any.whl (25 kB)
#13 1.496 Collecting mongoengine-goodjson==1.1.8
#13 1.519 Downloading mongoengine_goodjson-1.1.8.tar.gz (26 kB)
#13 1.553 Preparing metadata (setup.py): started
#13 2.007 Preparing metadata (setup.py): finished with status 'done'
#13 2.040 Collecting Flask==2.0.3
#13 2.087 Downloading Flask-2.0.3-py3-none-any.whl (95 kB)
#13 2.116 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 95.6/95.6 KB 3.7 MB/s eta 0:00:00
#13 2.333 Collecting cffi>=1.1
#13 2.354 Downloading cffi-1.15.0.tar.gz (484 kB)
#13 2.522 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 484.1/484.1 KB 2.9 MB/s eta 0:00:00
#13 2.635 Preparing metadata (setup.py): started
#13 2.906 Preparing metadata (setup.py): finished with status 'done'
#13 2.947 Collecting six>=1.4.1
#13 2.967 Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
#13 3.029 Collecting Werkzeug>=0.14
#13 3.047 Downloading Werkzeug-2.1.1-py3-none-any.whl (224 kB)
#13 3.110 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 224.7/224.7 KB 3.6 MB/s eta 0:00:00
#13 3.152 Collecting PyJWT<3.0,>=2.0
#13 3.168 Downloading PyJWT-2.3.0-py3-none-any.whl (16 kB)
#13 3.304 Collecting pytz
#13 3.329 Downloading pytz-2022.1-py2.py3-none-any.whl (503 kB)
#13 3.442 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 503.5/503.5 KB 4.5 MB/s eta 0:00:00
#13 3.484 Collecting aniso8601>=0.82
#13 3.502 Downloading aniso8601-9.0.1-py2.py3-none-any.whl (52 kB)
#13 3.510 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 52.8/52.8 KB 10.2 MB/s eta 0:00:00
#13 3.550 Collecting WTForms[email]>=2.3.1
#13 3.566 Downloading WTForms-3.0.1-py3-none-any.whl (136 kB)
#13 3.589 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 136.5/136.5 KB 6.6 MB/s eta 0:00:00
#13 3.617 Collecting Flask-WTF>=0.14.3
#13 3.630 Downloading Flask_WTF-1.0.1-py3-none-any.whl (12 kB)
#13 3.665 Collecting mongoengine>=0.20
#13 3.716 Downloading mongoengine-0.24.1-py3-none-any.whl (108 kB)
#13 3.733 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 108.9/108.9 KB 8.0 MB/s eta 0:00:00
#13 3.763 Collecting dateutils
#13 3.781 Downloading dateutils-0.6.12-py2.py3-none-any.whl (5.7 kB)
#13 3.827 Collecting Jinja2>=3.0
#13 3.860 Downloading Jinja2-3.1.1-py3-none-any.whl (132 kB)
#13 3.889 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 132.6/132.6 KB 6.0 MB/s eta 0:00:00
#13 3.943 Collecting click>=7.1.2
#13 3.959 Downloading click-8.1.2-py3-none-any.whl (96 kB)
#13 3.979 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.6/96.6 KB 5.5 MB/s eta 0:00:00
#13 4.028 Collecting itsdangerous>=2.0
#13 4.049 Downloading itsdangerous-2.1.2-py3-none-any.whl (15 kB)
#13 4.084 Collecting pycparser
#13 4.098 Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
#13 4.123 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 KB 5.5 MB/s eta 0:00:00
#13 4.216 Collecting MarkupSafe>=2.0
#13 4.230 Downloading MarkupSafe-2.1.1.tar.gz (18 kB)
#13 4.246 Preparing metadata (setup.py): started
#13 4.497 Preparing metadata (setup.py): finished with status 'done'
#13 5.036 Collecting pymongo<5.0,>=3.4
#13 5.055 Downloading pymongo-4.1.0.tar.gz (774 kB)
#13 5.231 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 774.4/774.4 KB 4.5 MB/s eta 0:00:00
#13 5.389 Preparing metadata (setup.py): started
#13 5.673 Preparing metadata (setup.py): finished with status 'done'
#13 5.724 Collecting email-validator
#13 5.737 Downloading email_validator-1.1.3-py2.py3-none-any.whl (18 kB)
#13 5.771 Collecting python-dateutil
#13 5.786 Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
#13 5.834 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 KB 5.7 MB/s eta 0:00:00
#13 5.910 Collecting idna>=2.0.0
#13 5.956 Downloading idna-3.3-py3-none-any.whl (61 kB)
#13 5.960 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 KB 87.8 MB/s eta 0:00:00
#13 5.985 Collecting dnspython>=1.15.0
#13 5.997 Downloading dnspython-2.2.1-py3-none-any.whl (269 kB)
#13 6.040 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 269.1/269.1 KB 7.0 MB/s eta 0:00:00
#13 6.098 Building wheels for collected packages: mongoengine-goodjson, cffi, MarkupSafe, pymongo
#13 6.100 Building wheel for mongoengine-goodjson (setup.py): started
#13 6.468 Building wheel for mongoengine-goodjson (setup.py): finished with status 'done'
#13 6.468 Created wheel for mongoengine-goodjson: filename=mongoengine_goodjson-1.1.8-py3-none-any.whl size=14343 sha256=4584e20f5839eacaa552ae9f9bfeeca3267bbf06afaeab0bcbc2538f532894a0
#13 6.468 Stored in directory: /tmp/pip-ephem-wheel-cache-valwcqkz/wheels/43/7f/cc/17c669e1863d0376655379c94cba6cf47ee4b58b151b34ff83
#13 6.471 Building wheel for cffi (setup.py): started
#13 6.719 Building wheel for cffi (setup.py): finished with status 'error'
#13 6.729 error: subprocess-exited-with-error
#13 6.729
#13 6.729 × python setup.py bdist_wheel did not run successfully.
#13 6.729 │ exit code: 1
#13 6.729 ╰─> [45 lines of output]
#13 6.729
#13 6.729 No working compiler found, or bogus compiler options passed to
#13 6.729 the compiler from Python's standard "distutils" module. See
#13 6.729 the error messages above. Likely, the problem is not related
#13 6.729 to CFFI but generic to the setup.py of any Python package that
#13 6.729 tries to compile C code. (Hints: on OS/X 10.8, for errors about
#13 6.729 -mno-fused-madd see http://stackoverflow.com/questions/22313407/
#13 6.729 Otherwise, see https://wiki.python.org/moin/CompLangPython or
#13 6.729 the IRC channel #python on irc.libera.chat.)
#13 6.729
#13 6.729 Trying to continue anyway. If you are trying to install CFFI from
#13 6.729 a build done in a different context, you can ignore this warning.
#13 6.729
#13 6.729 running bdist_wheel
#13 6.729 running build
#13 6.729 running build_py
#13 6.729 creating build
#13 6.729 creating build/lib.linux-x86_64-3.11
#13 6.729 creating build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/cparser.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/error.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/recompiler.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/lock.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/commontypes.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/model.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/verifier.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/api.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/__init__.py -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/_embedding.h -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.11/cffi
#13 6.729 running build_ext
#13 6.729 building '_cffi_backend' extension
#13 6.729 creating build/temp.linux-x86_64-3.11
#13 6.729 creating build/temp.linux-x86_64-3.11/c
#13 6.729 gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python3.11 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.11/c/_cffi_backend.o
#13 6.729 error: command 'gcc' failed: No such file or directory
#13 6.729 [end of output]
#13 6.729
#13 6.729 note: This error originates from a subprocess, and is likely not a problem with pip.
#13 6.730 Running setup.py clean for cffi
#13 6.730 ERROR: Failed building wheel for cffi
#13 6.953 Building wheel for MarkupSafe (setup.py): started
#13 7.305 Building wheel for MarkupSafe (setup.py): finished with status 'done'
#13 7.306 Created wheel for MarkupSafe: filename=MarkupSafe-2.1.1-py3-none-any.whl size=9669 sha256=c957cf4e73fc95740c2635e7468f1c006747c5a75c1123137241ebbfe0b85e12
#13 7.307 Stored in directory: /tmp/pip-ephem-wheel-cache-valwcqkz/wheels/f2/8e/9e/4ee907ff6fb9e145722f0506c46ad9516302d1f424b43220e5
#13 7.311 Building wheel for pymongo (setup.py): started
#13 7.740 Building wheel for pymongo (setup.py): finished with status 'done'
#13 7.743 Created wheel for pymongo: filename=pymongo-4.1.0-cp311-cp311-linux_x86_64.whl size=332405 sha256=a73a7f9c879a14d99703a7adeb4171e945f426a84a5d60e6995e58941b846698
#13 7.743 Stored in directory: /tmp/pip-ephem-wheel-cache-valwcqkz/wheels/38/43/dc/94b4627e945b4995030cddfad93cb988b1c8b87876d34cb161
#13 7.747 Successfully built mongoengine-goodjson MarkupSafe pymongo
#13 7.747 Failed to build cffi
#13 7.889 Installing collected packages: pytz, aniso8601, Werkzeug, six, python-dotenv, pymongo, PyJWT, pycparser, MarkupSafe, itsdangerous, idna, dnspython, click, WTForms, python-dateutil, mongoengine, Jinja2, email-validator, cffi, Flask, dateutils, bcrypt, mongoengine-goodjson, Flask-WTF, Flask-RESTful, Flask-JWT-Extended, Flask-Bcrypt, flask-mongoengine
#13 9.922 Running setup.py install for cffi: started
#13 10.20 Running setup.py install for cffi: finished with status 'error'
#13 10.20 error: subprocess-exited-with-error
#13 10.20
#13 10.20 × Running setup.py install for cffi did not run successfully.
#13 10.20 │ exit code: 1
#13 10.20 ╰─> [45 lines of output]
#13 10.20
#13 10.20 No working compiler found, or bogus compiler options passed to
#13 10.20 the compiler from Python's standard "distutils" module. See
#13 10.20 the error messages above. Likely, the problem is not related
#13 10.20 to CFFI but generic to the setup.py of any Python package that
#13 10.20 tries to compile C code. (Hints: on OS/X 10.8, for errors about
#13 10.20 -mno-fused-madd see http://stackoverflow.com/questions/22313407/
#13 10.20 Otherwise, see https://wiki.python.org/moin/CompLangPython or
#13 10.20 the IRC channel #python on irc.libera.chat.)
#13 10.20
#13 10.20 Trying to continue anyway. If you are trying to install CFFI from
#13 10.20 a build done in a different context, you can ignore this warning.
#13 10.20
#13 10.20 running install
#13 10.20 running build
#13 10.20 running build_py
#13 10.20 creating build
#13 10.20 creating build/lib.linux-x86_64-3.11
#13 10.20 creating build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/cparser.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/error.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/recompiler.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/lock.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/commontypes.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/model.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/verifier.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/api.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/__init__.py -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/_embedding.h -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.11/cffi
#13 10.20 running build_ext
#13 10.20 building '_cffi_backend' extension
#13 10.20 creating build/temp.linux-x86_64-3.11
#13 10.20 creating build/temp.linux-x86_64-3.11/c
#13 10.20 gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python3.11 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.11/c/_cffi_backend.o
#13 10.20 error: command 'gcc' failed: No such file or directory
#13 10.20 [end of output]
#13 10.20
#13 10.20 note: This error originates from a subprocess, and is likely not a problem with pip.
#13 10.21 error: legacy-install-failure
#13 10.21
#13 10.21 × Encountered error while trying to install package.
#13 10.21 ╰─> cffi
#13 10.21
#13 10.21 note: This is an issue with the package mentioned above, not pip.
#13 10.21 hint: See above for output from the failure.
------
failed to solve: executor failed running [/bin/sh -c pip3 --no-cache-dir install -r requirements.txt]: exit code: 1


Lösung des Problems

CFFI bietet keine vorkompilierten Binärdateien ("Wheels") für Python 3.11 an, da letzteres nur eine Vorabversion ist. Infolgedessen versucht pip, CFFI aus Quellen zu kompilieren, was fehlschlägt, da der Compiler gcc in diesem Docker-Image nicht gefunden wird.

Keine Kommentare:

Kommentar veröffentlichen

Warum werden SCHED_FIFO-Threads derselben physischen CPU zugewiesen, obwohl CPUs im Leerlauf verfügbar sind?

Lösung des Problems Wenn ich das richtig verstehe, versuchen Sie, SCHED_FIFO mit aktiviertem Hyperthreading ("HT") zu verwenden, ...