簡體   English   中英

在 alpine docker 容器上安裝 pyorc 失敗

[英]Failed to install pyorc on alpine docker container

出現編譯錯誤 - 這取決於 ORC 二進制文件。

In file included from src/_pyorc/_pyorc.cpp:1:
src/_pyorc/Reader.h:7:10: fatal error: 'orc/OrcFile.hh' file not found
#include "orc/OrcFile.hh"
         ^~~~~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1

如果我也單獨編譯apache-orc ,我該如何參考 PyOrc Pip 安裝?

任何人都有任何解決方案或想法,我們如何在高山容器內安裝pyorc package。

我在使用 ubuntu 和正常 python docker 圖像的高山圖像時遇到問題,它運行良好。

Docker 圖片: FROM python:3.7-alpine

我使用了 Docker 多階段構建:

# Dockerfile

FROM python:3.7.3
WORKDIR /app
RUN pip install pyorc -t .

FROM python:3.7.3-alpine
WORKDIR /app
RUN apk add --no-cache --virtual .build-deps g++ musl-dev gcompat
COPY --from=0 /app .

它似乎工作:

$ docker build -t test .
$ docker run -it --rm test python
Python 3.7.3 (default, Jun 27 2019, 22:53:21)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyorc
>>>
>>> with open("./new_data.orc", "wb") as data:
...     with pyorc.Writer(data, "struct<col0:int,col1:string>") as writer:
...         writer.write((1, "ORC from Python"))
...
>>> from pathlib import Path
>>> Path("./new_data.orc").read_bytes()
b'ORC\x1d\x00\x00\n\x0c\n\x04\x00\x00\x.....'

作者Noirello給了我如下指南/方向:

對於 Alpine,必須從源代碼安裝它。 文檔中有一些說明如何操作: pyOrc-Docs

我會使用多階段 Dockerfile 來構建 pyorc,然后使用應用程序的 rest 將輪子安裝到干凈的 Alpine 映像中。

像這樣的東西:

FROM python:3.8.3-alpine AS builder
RUN apk add gcc g++ musl-dev cmake make
ARG VERSION=0.3.0

RUN mkdir build
WORKDIR /build
RUN pip install pybind11 wheel
RUN pip download --no-binary :all: --no-deps pyorc==${VERSION} && tar -xvf *.tar.gz
RUN cd pyorc-${VERSION} && python3 setup.py build_orc
RUN cd pyorc-${VERSION} && python3 setup.py bdist_wheel

FROM python:3.8.3-alpine
ARG VERSION=0.3.0

COPY --from=builder /build/pyorc-${VERSION}/dist/pyorc-${VERSION}-*.whl /tmp/
# Adding libstdc++, because the wheel expects that the libstdc++.so is presented on the system.
# Adding tzdata, because the ORC C++ lib needs to have a localtime set.
RUN apk add libstdc++ tzdata
# Setting localtime to UTC.
RUN ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN pip install /tmp/pyorc-${VERSION}-*.whl && rm -rf /tmp/pyorc-${VERSION}-*.whl
# Rest of your custom image...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM