Skip to content

Instantly share code, notes, and snippets.

@zgoda
Created July 14, 2018 17:00
Show Gist options
  • Save zgoda/7a9fd9749b80d343c50c48463bd2f0e1 to your computer and use it in GitHub Desktop.
Save zgoda/7a9fd9749b80d343c50c48463bd2f0e1 to your computer and use it in GitHub Desktop.
Build Python 3.7 for ARMv7 from source on amd64
FROM resin/armv7hf-debian-qemu
VOLUME /src
VOLUME /target
RUN echo "deb http://deb.debian.org/debian/ oldstable main contrib non-free" > /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian/ oldstable-updates main contrib non-free" >> /etc/apt/sources.list && \
echo "deb http://deb.debian.org/debian-security oldstable/updates main" >> /etc/apt/sources.list && \
apt-get update && \
apt-get install -qy --no-install-recommends \
python3-minimal curl wget apt-transport-https dirmngr build-essential \
libsqlite3-dev libgnutls28-dev libgnutls-openssl27 libssl-dev libbz2-dev libreadline-dev \
zlib1g-dev xz-utils liblzma-dev libffi-dev
ENTRYPOINT wget -q -O /src/Python-3.7.0.tgz https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz && \
cd /src && tar -zxvf Python-3.7.0.tgz && cd Python-3.7.0 && \
./configure --prefix=/target/python-3.7.0 --disable-shared && \
MAKEFLAGS="-j 4" make && \
MAKEFLAGS="-j 4" make install
# invocation:
# docker build -t py37-builder .
# docker run -v "$(pwd)"/src:/src -v "$(pwd)"/target py37-builder
# at the end you'll get ARMv7 binary installation of Python 3.7 in "$(pwd)"/target/python-3.7.0
@Henistein
Copy link

I got this error: standard_init_linux.go:228: exec user process caused: exec format error

@zgoda
Copy link
Author

zgoda commented Jun 30, 2021

You need qemu with ARMv7 support on host system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment