Created
June 19, 2023 11:20
-
-
Save mhaimes/b93659b522812f24f9558010b32fe436 to your computer and use it in GitHub Desktop.
Dockerfile to custom build an aarch64 linux python 3.11 distribution (can be inherited in other dockerfiles that need a fully featured, freely distributable (not bound by GPL) custom python distribution)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM --platform=linux/arm64 ubuntu:20.04 as custom-python3.11 | |
| ## Set timezone to avoid anything too weird/produce builds with correct timestamps | |
| RUN rm -rf /etc/localtime | |
| RUN ln -s /usr/share/zoneinfo/America/New_York /etc/localtime | |
| #? COPY /usr/bin/qemu-system-aarch64 /usr/bin/qemu-system-aarch64 | |
| ## Install all dependencies | |
| RUN apt-get update | |
| # Get core languages & tools for python build | |
| RUN apt-get install -y build-essential git pkg-config | |
| # Needed for built-in ssl module | |
| RUN apt-get install -y libssl-dev | |
| # Needed for built-in sqlite3 module | |
| RUN apt-get install -y libsqlite3-dev | |
| # Needed for built-in zlib module | |
| RUN apt-get install -y zlib1g-dev | |
| # Needed for built-in bz2 module | |
| RUN apt-get install -y libbz2-dev | |
| # Needed for built-in lzma module | |
| RUN apt-get install -y liblzma-dev | |
| # Needed for built-in uuid module | |
| RUN apt-get install -y uuid-dev | |
| # Needed for built-in ctypes module | |
| RUN apt-get install -y libffi-dev | |
| # Needed for built-in curses module | |
| RUN apt-get install -y libncurses-dev | |
| # Specifically avoid libreadline, it's GPL | |
| RUN apt-get install -y libeditline-dev | |
| ## Copy in repository contents | |
| #ADD . /usr/src/cpython/ | |
| RUN mkdir -p /usr/src | |
| WORKDIR /usr/src | |
| RUN apt-get install -y curl | |
| RUN curl -o Python.tar.xz https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tar.xz | |
| RUN tar -xvf Python.tar.xz | |
| RUN rm Python.tar.xz | |
| WORKDIR /usr/src/Python-3.11.4 | |
| ## Configure python to build just the executable + optimizations, no shared or static libpythons | |
| RUN ./configure --prefix=/usr/local/python \ | |
| --enable-optimizations \ | |
| --with-lto \ | |
| --without-static-libpython \ | |
| --enable-loadable-sqlite-extensions \ | |
| --with-readline=editline | |
| RUN make -j $(nproc) | |
| #RUN make test | |
| RUN make install | |
| RUN echo "Python configured, built & installed to /usr/local/python successfully!" | |
| ENV PATH="/usr/local/python/bin:$PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment