如何在Alpine 3.8中安装pythonnet

时间:2019-09-24 12:39:08

标签: c# python-3.x alpine python.net

我需要在新的alpine 3.8 / python 3.7容器中安装pythonnet。我已经为Ubuntu做到了(最大的帮助是pythonnet的dockerfile)。我不能在高山中使用apt-get,只能使用apk命令,这些命令看不到任何mono-complete或nuget(我认为安装这些命令将使我能够正确安装pythonnet,尤其是mono-complete 4.8.0.520-0xamarin3版本)。我该怎么办?

1 个答案:

答案 0 :(得分:0)

Dockerfile:Stretch,Python 3.7.4,Mono 5.20.1,Pythonnet 2.4.0

# Pythonnet - Dockerfile
# ----------------------------------------------
# * based on debian stretch with python 3.7.4
# * mono 5.20.1 + pythonnet 2.4.0 
# ----------------------------------------------
FROM python:3.7.4-stretch

# [ Mono: 5.20.1 ]
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
  && echo "deb http://download.mono-project.com/repo/debian stretch/snapshots/5.20.1/. main" > /etc/apt/sources.list.d/mono-official.list \
  && apt-get update \
  && apt-get install -y clang \
  && apt-get install -y mono-complete=5.20.1\* \
  && rm -rf /var/lib/apt/lists/* /tmp/*

# [ pythonnet 2.4.0 ]
RUN pip install pycparser \
  && git clone https://github.com/pythonnet/pythonnet \
  && python pythonnet/setup.py bdist_wheel \
  && pip install --no-index --find-links=./pythonnet/dist/ pythonnet