Проблема с библиотекой eccodes в образе Docker на macos
Я новичок в Docker, и я пытаюсь создать следующий образ на своем MacOS Monterey:
ARG IMAGE_TAG=3.10.0-slim-bullseye
FROM python:${IMAGE_TAG}
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get autoremove -y \
&& apt-get install -y \
gcc g++ \
# Needed for pygrib on osx
# libeccodes-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip \
&& pip install pygrib==2.1.4 \
Но это не работает, если я не раскомментируюlibeccodes-dev
линия.
Я установил eccodes какbrew install eccodes
и я нахожусь в среде conda, где я побежалconda install -c conda-forge eccodes
а также пробовалpip install pygrib
, но, кажется, ничего не работает. Я продолжаю получать следующую ошибку при попытке сборки, жалуясь на отсутствие eccodes:
=> ERROR [3/3] RUN pip install --upgrade pip && pip install pygrib==2.1.4 14.8s
------
> [3/3] RUN pip install --upgrade pip && pip install pygrib==2.1.4:
#6 1.093 Requirement already satisfied: pip in /usr/local/lib/python3.10/site-packages (21.2.4)
#6 1.484 Collecting pip
#6 1.549 Downloading pip-22.1.2-py3-none-any.whl (2.1 MB)
#6 1.890 Installing collected packages: pip
#6 1.890 Attempting uninstall: pip
#6 1.891 Found existing installation: pip 21.2.4
#6 1.966 Uninstalling pip-21.2.4:
#6 2.105 Successfully uninstalled pip-21.2.4
#6 2.713 Successfully installed pip-22.1.2
#6 2.713 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#6 3.024 Collecting pygrib==2.1.4
#6 3.081 Downloading pygrib-2.1.4.tar.gz (21.8 MB)
#6 6.127 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 21.8/21.8 MB 6.9 MB/s eta 0:00:00
#6 6.484 Installing build dependencies: started
#6 11.90 Installing build dependencies: finished with status 'done'
#6 11.90 Getting requirements to build wheel: started
#6 12.03 Getting requirements to build wheel: finished with status 'done'
#6 12.03 Preparing metadata (pyproject.toml): started
#6 12.14 Preparing metadata (pyproject.toml): finished with status 'done'
#6 12.28 Collecting numpy
#6 12.31 Using cached numpy-1.23.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (13.9 MB)
#6 12.39 Collecting pyproj
#6 12.40 Downloading pyproj-3.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.8 MB)
#6 13.66 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.8/5.8 MB 4.6 MB/s eta 0:00:00
#6 13.70 Collecting certifi
#6 13.95 Downloading certifi-2022.6.15-py3-none-any.whl (160 kB)
#6 13.97 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 160.2/160.2 kB 11.7 MB/s eta 0:00:00
#6 13.97 Building wheels for collected packages: pygrib
#6 13.98 Building wheel for pygrib (pyproject.toml): started
#6 14.68 Building wheel for pygrib (pyproject.toml): finished with status 'error'
#6 14.68 error: subprocess-exited-with-error
#6 14.68
#6 14.68 × Building wheel for pygrib (pyproject.toml) did not run successfully.
#6 14.68 │ exit code: 1
#6 14.68 ╰─> [29 lines of output]
#6 14.68 eccodes not found, build may fail...
#6 14.68 running bdist_wheel
#6 14.68 running build
#6 14.68 running build_py
#6 14.68 creating build
#6 14.68 creating build/lib.linux-aarch64-cpython-310
#6 14.68 creating build/lib.linux-aarch64-cpython-310/pygrib
#6 14.68 copying src/pygrib/__init__.py -> build/lib.linux-aarch64-cpython-310/pygrib
#6 14.68 running build_ext
#6 14.68 cythoning src/pygrib/_pygrib.pyx to src/pygrib/_pygrib.c
#6 14.68 /tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/pip-install-ewf87o4j/pygrib_0cec9ea4e92e455fbd34ba265ffd15b2/src/pygrib/_pygrib.pyx
#6 14.68 tree = Parsing.p_module(s, pxd, full_module_name)
#6 14.68 building 'pygrib._pygrib' extension
#6 14.68 creating build/temp.linux-aarch64-cpython-310
#6 14.68 creating build/temp.linux-aarch64-cpython-310/src
#6 14.68 creating build/temp.linux-aarch64-cpython-310/src/pygrib
#6 14.68 gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.10 -I/tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/numpy/core/include -c src/pygrib/_pygrib.c -o build/temp.linux-aarch64-cpython-310/src/pygrib/_pygrib.o
#6 14.68 In file included from /tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1948,
#6 14.68 from /tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
#6 14.68 from /tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5,
#6 14.68 from src/pygrib/_pygrib.c:698:
#6 14.68 /tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#6 14.68 17 | #warning "Using deprecated NumPy API, disable it with " \
#6 14.68 | ^~~~~~~
#6 14.68 src/pygrib/_pygrib.c:708:10: fatal error: grib_api.h: No such file or directory
#6 14.68 708 | #include "grib_api.h"
#6 14.68 | ^~~~~~~~~~~~
#6 14.68 compilation terminated.
#6 14.68 error: command '/usr/bin/gcc' failed with exit code 1
#6 14.68 [end of output]
#6 14.68
#6 14.68 note: This error originates from a subprocess, and is likely not a problem with pip.
#6 14.68 ERROR: Failed building wheel for pygrib
#6 14.68 Failed to build pygrib
#6 14.68 ERROR: Could not build wheels for pygrib, which is required to install pyproject.toml-based projects
------
executor failed running [/bin/sh -c pip install --upgrade pip && pip install pygrib==2.1.4]: exit code: 1
Однако, если я устанавливаю и импортирую pygrib в той же среде conda (без Docker), он проходит без проблем, а это означает, что eccodes на самом деле правильно установлен.
Также образ можно успешно собрать с любого компьютера под управлением Linux.
Меня немного смущает такое поведение, любая идея о том, как обойти это, будет очень признательна.