-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ee3825
commit 6718865
Showing
13 changed files
with
361 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# syntax=docker/dockerfile:1 | ||
ARG BASE_IMAGE=docker.io/polymathrobotics/buildpack-deps:noble | ||
# hadolint ignore=DL3006 | ||
FROM $BASE_IMAGE | ||
|
||
# ensure local python is preferred over distribution python | ||
ENV PATH=/usr/local/bin:$PATH | ||
|
||
# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed | ||
# last attempted removal of LANG broke many users: | ||
# https://github.com/docker-library/python/pull/570 | ||
ENV LANG=C.UTF-8 | ||
|
||
# runtime dependencies | ||
RUN set -eux; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends \ | ||
libbluetooth-dev \ | ||
tk-dev \ | ||
uuid-dev \ | ||
; \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D | ||
ENV PYTHON_VERSION=3.10.16 | ||
ENV PYTHON_SHA256=bfb249609990220491a1b92850a07135ed0831e41738cf681d63cf01b2a8fbd1 | ||
|
||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
# hadolint ignore=DL3003,DL3013,SC2015 | ||
RUN set -eux; \ | ||
\ | ||
curl -fsSL -o python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ | ||
echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ | ||
curl -fsSL -o python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ | ||
GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ | ||
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ | ||
gpg --batch --verify python.tar.xz.asc python.tar.xz; \ | ||
gpgconf --kill all; \ | ||
rm -rf "$GNUPGHOME" python.tar.xz.asc; \ | ||
mkdir -p /usr/src/python; \ | ||
tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ | ||
rm python.tar.xz; \ | ||
\ | ||
cd /usr/src/python; \ | ||
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ | ||
./configure \ | ||
--build="$gnuArch" \ | ||
--enable-loadable-sqlite-extensions \ | ||
--enable-optimizations \ | ||
--enable-option-checking=fatal \ | ||
--enable-shared \ | ||
--with-lto \ | ||
--with-ensurepip \ | ||
; \ | ||
nproc="$(nproc)"; \ | ||
EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ | ||
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ | ||
make -j "$nproc" \ | ||
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ | ||
"LDFLAGS=${LDFLAGS:-}" \ | ||
; \ | ||
# https://github.com/docker-library/python/issues/784 | ||
# prevent accidental usage of a system installed libpython of the same version | ||
rm python; \ | ||
make -j "$nproc" \ | ||
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ | ||
"LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ | ||
python \ | ||
; \ | ||
make install; \ | ||
\ | ||
# enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 | ||
bin="$(readlink -ve /usr/local/bin/python3)"; \ | ||
dir="$(dirname "$bin")"; \ | ||
mkdir -p "/usr/share/gdb/auto-load/$dir"; \ | ||
cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ | ||
\ | ||
cd /; \ | ||
rm -rf /usr/src/python; \ | ||
\ | ||
find /usr/local -depth \ | ||
\( \ | ||
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ | ||
-o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ | ||
\) -exec rm -rf '{}' + \ | ||
; \ | ||
\ | ||
ldconfig; \ | ||
\ | ||
export PYTHONDONTWRITEBYTECODE=1; \ | ||
python3 --version; \ | ||
\ | ||
pip3 install \ | ||
--disable-pip-version-check \ | ||
--no-cache-dir \ | ||
--no-compile \ | ||
'setuptools==65.5.1' \ | ||
wheel \ | ||
; \ | ||
pip3 --version | ||
|
||
# make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) | ||
RUN set -eux; \ | ||
for src in idle3 pip3 pydoc3 python3 python3-config; do \ | ||
dst="$(echo "$src" | tr -d 3)"; \ | ||
[ -s "/usr/local/bin/$src" ]; \ | ||
[ ! -e "/usr/local/bin/$dst" ]; \ | ||
ln -svT "$src" "/usr/local/bin/$dst"; \ | ||
done | ||
|
||
CMD ["python3"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
variable "TAG_PREFIX" { | ||
default = "docker.io/polymathrobotics/python" | ||
} | ||
|
||
variable "VERSION" { | ||
default = "3.10.16" | ||
} | ||
|
||
# There's no darwin-based Docker, so if we're running on macOS, change the platform to linux | ||
variable "LOCAL_PLATFORM" { | ||
default = regex_replace("${BAKE_LOCAL_PLATFORM}", "^(darwin)", "linux") | ||
} | ||
|
||
target "_common" { | ||
dockerfile = "Containerfile" | ||
tags = [ | ||
"${TAG_PREFIX}:${VERSION}-noble", | ||
"${TAG_PREFIX}:${join(".", slice(split(".", "${VERSION}"), 0, 2))}-noble", | ||
] | ||
labels = { | ||
"org.opencontainers.image.source" = "https://github.com/polymathrobotics/oci" | ||
"org.opencontainers.image.licenses" = "Apache-2.0" | ||
"org.opencontainers.image.description" = "Python is an interpreted, interactive, object-oriented, open-source programming language." | ||
"org.opencontainers.image.title" = "${TAG_PREFIX}" | ||
"org.opencontainers.image.created" = "${timestamp()}" | ||
"dev.polymathrobotics.image.readme-filepath" = "python/README.md" | ||
} | ||
} | ||
|
||
target "local" { | ||
inherits = ["_common"] | ||
platforms = ["${LOCAL_PLATFORM}"] | ||
} | ||
|
||
target "default" { | ||
inherits = ["_common"] | ||
platforms = ["linux/amd64", "linux/arm64/v8"] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
describe command('python3') do | ||
it { should exist } | ||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.