Reputation: 139
Docker-compose failed during build because one the python module in the requirement is dependent on pycairo. Is there a way around this? Here is the error message.
Failed to build pycairo
failed Pip subprocess error: WARNING: The candidate selected for download or install is a yanked version: 'pylinac' candidate (version 3.1.0 at https://files.pythonhosted.org/packages/74/08/0d997f173cac47624b0800dff04e21059ade94662e59e09c808fd1950dfc/pylinac-3.1.0-py3-none-any.whl (from https://pypi.org/simple/pylinac/) (requires-python:>=3.6)) Reason for being yanked: wrong version in package error: subprocess-exited-with-error
Building wheel for pycairo (pyproject.toml) did not run successfully. exit code: 1 [14 lines of output] running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-cpython-38 creating build/lib.linux-x86_64-cpython-38/cairo copying cairo/init.py -> build/lib.linux-x86_64-cpython-38/cairo copying cairo/init.pyi -> build/lib.linux-x86_64-cpython-38/cairo copying cairo/py.typed -> build/lib.linux-x86_64-cpython-38/cairo warning: build_py: byte-compiling is disabled, skipping.
running build_ext 'pkg-config' not found. Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10'] [end of output]
note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pycairo ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects
CondaEnvException: Pip failed
The command '/bin/sh -c conda env create -f /tmp/environment.yml' returned a non-zero code: 1 ERROR: Service 'django' failed to build : Build failed
Here is the docker compose file:
FROM continuumio/miniconda3
ARG APP_HOME=/app
WORKDIR ${APP_HOME}
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"
# Install apt packages
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# Pour authentification via LDAP
python3-dev python2.7-dev libldap2-dev libsasl2-dev ldap-utils tox lcov valgrind \
# psycopg2 dependencies
libpq-dev \
# OpenCV dependencies \
ffmpeg libsm6 libxext6 \
# miniconda 3
wget bash \
# To allow python to use zlib
zlib1g-dev \
# To build local conda dependencies
git \
# For pypx
dcmtk sudo \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
# Config proxy à enlever si en télétravail.
ENV http_proxy http://proxy13.regional.reg13.rtss.qc.ca:8080
ENV https_proxy http://proxy13.regional.reg13.rtss.qc.ca:8080
ENV no_proxy ${QAT_IP}
## Pour installer PyMesh2 pour Python 3.7 (Enlever quand PyMesh2 supporte python 3.7)
#ARG BRANCH="main"
#ARG NUM_CORES=2
## RUN echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list &&\
#RUN apt-get update && apt-get install -y \
# gcc \
# g++ \
# git \
# cmake \
# libgmp-dev \
# libmpfr-dev \
# libgmpxx4ldbl \
# libboost-dev \
# libboost-thread-dev \
# zip unzip patchelf && \
# apt-get clean && \
# git clone --single-branch -b $BRANCH https://github.com/PyMesh/PyMesh.git
ADD ./requirements/environment.yml /tmp/environment.yml
ADD ./requirements/environment.production.yml /tmp/environment.production.yml
ADD ./requirements/pymesh2-0.3-cp38-cp38-linux_x86_64.whl /tmp/pymesh2-0.3-cp38-cp38-linux_x86_64.whl
RUN conda env create -f /tmp/environment.yml
RUN conda env update -n qatrain -f /tmp/environment.production.yml
RUN echo "source activate qatrain" > ~/.bashrc
ENV PATH /opt/conda/envs/qatrain/bin:$PATH
## Pour installer PyMesh2 pour Python 3.7 (suite) (Enlever quand PyMesh2 supporte python 3.7)
#ENV PYMESH_PATH /app/PyMesh
#ENV NUM_CORES $NUM_CORES
#WORKDIR $PYMESH_PATH
#RUN git submodule update --init && \
# pip install -r $PYMESH_PATH/python/requirements.txt
#RUN sed -i '1s/^/#include <stdint.h> \n/' $PYMESH_PATH/third_party/draco/src/draco/core/hash_utils.h
#RUN sed -i '1s/^/#include <stddef.h> \n/' $PYMESH_PATH/third_party/draco/src/draco/core/hash_utils.h
#RUN sed -i '21s/^/#include <limits> \n/' $PYMESH_PATH/third_party/draco/src/draco/io/parser_utils.cc
#RUN sed -i '1s/^/SET(CMAKE_C_FLAGS " -fcommon ${CMAKE_C_FLAGS}") \n/' $PYMESH_PATH/third_party/mmg/CMakeLists.txt
#
#RUN ./setup.py bdist_wheel && \
# rm -rf build_3.8 third_party/build && \
# # python $PYMESH_PATH/docker/patches/patch_wheel.py dist/pymesh2*.whl && \
# pip install dist/pymesh2*.whl && \
# python -c "import pymesh; pymesh.test()"
##
# Apply fix to PyPx
##
RUN echo && echo && echo "Applying fix to PyPx ..."
COPY ./compose/production/django/pypx_fix .
RUN ["chmod", "+x", "./pypx_fix"]
RUN ./pypx_fix
##
# Apply fix to PyLinac for Catphan analysis
##
RUN echo && echo && echo "Applying fix to PyLinac ..."
ADD ./qatrain/blocs/ct_catphan_phantom/pylinac_mod/ct.py /opt/conda/envs/qatrain/lib/python3.8/site-packages/pylinac/ct.py
ADD ./qatrain/blocs/ct_catphan_phantom/pylinac_mod/winston_lutz.py /opt/conda/envs/qatrain/lib/python3.8/site-packages/pylinac/winston_lutz.py
ADD ./qatrain/blocs/ct_catphan_phantom/pylinac_mod/mtf.py /opt/conda/envs/qatrain/lib/python3.8/site-packages/pylinac/core/mtf.py
# All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction
# copy python dependency wheels from python-build-stage
#COPY --from=python-build-stage /usr/src/app/wheels /wheels/
# use wheels to install python dependencies
#RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
# && rm -rf /wheels/
COPY ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint
RUN chmod +x /entrypoint
COPY ./compose/production/django/start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start
COPY ./compose/production/django/celery/worker/start /start-celeryworker
RUN sed -i 's/\r$//g' /start-celeryworker
RUN chmod +x /start-celeryworker
COPY ./compose/production/django/celery/beat/start /start-celerybeat
RUN sed -i 's/\r$//g' /start-celerybeat
RUN chmod +x /start-celerybeat
COPY ./compose/production/django/celery/flower/start /start-flower
RUN sed -i 's/\r$//g' /start-flower
RUN chmod +x /start-flower
COPY ./compose/production/django/storescp/start /start-storescp
RUN sed -i 's/\r$//g' /start-storescp
RUN chmod +x /start-storescp
# copy application code to WORKDIR
COPY . ${APP_HOME}
ENTRYPOINT ["/entrypoint"]
and the environment file:
name: qatrain
channels:
- conda-forge
- anaconda
- jrkerns
- menpo
- bioconda
dependencies:
- python=3.8
- dcmtk=3.6.1 # Pour service de réception fichiers DICOM
- matplotlib=3.3.3 # Tracer graphiques
- opencv=4.5.0 # Frédéric Girard
- pydicom=2.1.0 # Travailler avec des fichiers DICOM
- scipy=1.5.3 # Frédéric Girard
- numpy=1.19.4 # Frédéric Girard
- bullet=2.89 # Frédéric Girard
# - pymesh2=0.3 # Frédéric Girard - Installé direct via dockerfile car non compilé pour python 3.8
- peakutils=1.3.3 # Détection de pics en traitement de signal
- setuptools=49.6.0
- pip
- pip:
- django==3.1.3 # Framework
- psycopg2==2.9.3 # Base de donnée PortgreSQL
- celery==5.1.2 # Jobber
- django-celery-beat==2.2.1 # Jobber periodic trigger
- redis==4.1.4 # Gestion de l'exécution des tâches de Celery
- djangorestframework==3.13.1 # API web
- django-cors-headers==3.10.1 # Cross origin requests
- django-environ==0.8.1 # Configurer l'application via variables d'environnement
- whitenoise==5.3.0 # Simplifie la publication de fichiers statics
- flower==1.0.0 # GUI web pour affichage des tâches Celery en cours
- pypx==1.0.2.0 # Communication avec PACS
- pyldap==3.0.0.post1 # Authentification avec LDAP
- django-auth-ldap==2.2.0 # Authentification avec LDAP
- requests==2.25.0 # Permet de faire des requêtes à l'API de QATrack+
- pyquaternion==0.9.9 # Frédéric Girard
- pyacvd==0.2.5 # Frédéric Girard
- pyvista==0.28.1 # Frédéric Girard
- fuzzywuzzy==0.18.0 # Frédéric Girard
- pycairo==1.23.0
- pylinac==3.1.0 # Utilisation des fonctions par blocs.
- scikit-learn==0.24.2 # Pour bloc linac_adjust_table_wl
- scikit-image==0.20.0 # Frédéric Girard
- ./pymesh2-0.3-cp38-cp38-linux_x86_64.whl # Frédéric Girard
- pynetdicom==2.0.2 # Pour l'envoi de fichiers DCM à des device dicom externe (dcm_mod)
Upvotes: 1
Views: 665
Reputation: 139
I was able to solve the problem by adding libcairo2-dev in the dockerfile:
# Install apt packages
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# Pour authentification via LDAP
python3-dev python2.7-dev libldap2-dev libsasl2-dev ldap-utils tox lcov valgrind libcairo2-dev\
# psycopg2 dependencies
libpq-dev \
# OpenCV dependencies \
ffmpeg libsm6 libxext6 \
# miniconda 3
wget bash \
# To allow python to use zlib
zlib1g-dev \
# To build local conda dependencies
git \
# For pypx
dcmtk sudo \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
Upvotes: 0