Skip to content

Commit

Permalink
2025 updates for RobotPy (#30)
Browse files Browse the repository at this point in the history
* Drop python 3.8

* Include year in Python docker images

* Add Python 3.13
  • Loading branch information
virtuald authored Oct 16, 2024
1 parent e12b01a commit 9278b1c
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 78 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ jobs:
- raspbian
- aarch64
pyversion:
- py38
- py39
- py310
- py311
- py312
- py313
include:
- type: roborio
pyversion: py312
pyversion: py313

steps:
- uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ FROM wpilib/${ARCH}-cross-ubuntu-minimal:${VERSION}-${UBUNTU} AS pycompile

ARG TARGET_HOST=invalid-target-host
ARG AC_TARGET_HOST=invalid-ac-target-host
ARG EXTRA_CROSS_CONFIGURE_ARGS=

ENV TARGET_HOST=${TARGET_HOST}
ENV AC_TARGET_HOST=${AC_TARGET_HOST}
ENV EXTRA_CROSS_CONFIGURE_ARGS=${EXTRA_CROSS_CONFIGURE_ARGS}
ENV BUILD_HOST="x86_64"
ENV WORKING_DIRECTORY="/build"
ENV INSTALL_DIRECTORY="/build/crosspy"
ENV PYTHON_VERSION="3.8.16"
ENV PYTHON_VERSION="3.13.0"
ENV PYTHON_FTP_VERSION="3.13.0"
ENV PYTHON_EXE="python3.13"
ENV SOURCE_DIRECTORY="Python-$PYTHON_VERSION"
ENV PYTHON_ARCHIVE="Python-$PYTHON_VERSION.tar.xz"
ENV PREFIX="$INSTALL_DIRECTORY"
Expand All @@ -33,38 +37,45 @@ RUN set -xe; \
# Python cross-compilation
#

COPY 0001-bpo-41916-allow-cross-compiled-python-to-have-pthrea.patch /
COPY 0001-Use-specified-host_cpu-when-cross-compiling-for-Linu.patch /

RUN set -xe; \
mkdir -p "$PREFIX"; \
# Download
cd $WORKING_DIRECTORY; \
wget -c https://www.python.org/ftp/python/$PYTHON_VERSION/$PYTHON_ARCHIVE; \
wget -c https://www.python.org/ftp/python/$PYTHON_FTP_VERSION/$PYTHON_ARCHIVE; \
rm -rf $SOURCE_DIRECTORY; \
tar -xf $PYTHON_ARCHIVE; \
cd $SOURCE_DIRECTORY; \
# patch -pthread CXX issue
patch -p1 < /0001-bpo-41916-allow-cross-compiled-python-to-have-pthrea.patch; \
# patch arm cpu hardcoding
patch -p1 < /0001-Use-specified-host_cpu-when-cross-compiling-for-Linu.patch; \
# Build python for host
cd $WORKING_DIRECTORY;cd $SOURCE_DIRECTORY; \
./configure --enable-optimizations --with-ensurepip=install; \
make -j altinstall; \
make -j; \
make -j altinstall

RUN set -xe; \
# Remove build dependencies -- compilation uses host for some reason
apt-get remove -y libreadline-dev libncursesw5-dev libssl-dev \
libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev liblzma-dev lzma-dev libffi-dev zlib1g-dev; \
apt-get autoremove -y;

RUN set -xe; \
# cross-compile
cd $WORKING_DIRECTORY;cd $SOURCE_DIRECTORY; make distclean; \
cd $WORKING_DIRECTORY; \
rm -rf $SOURCE_DIRECTORY; \
tar -xf $PYTHON_ARCHIVE; \
cd $SOURCE_DIRECTORY; \
./configure --host=$TARGET_HOST --build=$BUILD_HOST --prefix=$PREFIX \
--disable-ipv6 --enable-unicode=ucs4 \
--with-build-python=$(which $PYTHON_EXE) \
--disable-ipv6 \
ac_cv_host=$AC_TARGET_HOST \
ac_cv_buggy_getaddrinfo=no \
ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no \
ac_cv_have_long_long_format=yes \
ac_cv_pthread_is_default=no ac_cv_pthread=yes ac_cv_cxx_thread=yes; \
ac_cv_pthread_is_default=no ac_cv_pthread=yes ac_cv_cxx_thread=yes \
${EXTRA_CROSS_CONFIGURE_ARGS}; \
make -j; \
# make install here is fine because we include --prefix in the configure statement
make install


#
# Minimal cross-compilation environment
Expand All @@ -84,11 +95,12 @@ COPY --from=pycompile /build/crosspy /build/crosspy

ARG ARCH=invalid-arch
ARG TARGET_HOST=invalid-target-host
ARG MACHINE_ARG=

RUN set -xe; \
ldconfig; \
python3.8 -m pip install crossenv==1.4.0; \
python3.8 -m crossenv /build/crosspy/bin/python3.8 /build/venv --sysroot=$(${TARGET_HOST}-gcc -print-sysroot) --env UNIXCONFDIR=/build/venv/cross/etc; \
python3.13 -m pip install 'crossenv~=1.5.0'; \
python3.13 -m crossenv /build/crosspy/bin/python3.13 /build/venv ${MACHINE_ARG} --sysroot=$(${TARGET_HOST}-gcc -print-sysroot) --env UNIXCONFDIR=/build/venv/cross/etc; \
/build/venv/bin/cross-pip install wheel;

COPY pip-${ARCH}.conf /build/venv/cross/pip.conf
Expand Down
6 changes: 3 additions & 3 deletions cross-ubuntu-py/os-release-roborio
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ID="nilrt-academic"
NAME="NI Linux Real-Time - Academic"
VERSION="8.14"
VERSION_ID="8.14"
PRETTY_NAME="NI Linux Real-Time - Academic 8.14"
VERSION="8.15"
VERSION_ID="8.15"
PRETTY_NAME="NI Linux Real-Time - Academic 8.15"
2 changes: 1 addition & 1 deletion cross-ubuntu-py/pip-aarch64.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

[global]
extra-index-url = https://wpilib.jfrog.io/artifactory/api/pypi/wpilib-python-release-2024/simple
extra-index-url = https://wpilib.jfrog.io/artifactory/api/pypi/wpilib-python-release-2025/simple
2 changes: 1 addition & 1 deletion cross-ubuntu-py/pip-raspbian.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

[global]
extra-index-url =
https://wpilib.jfrog.io/artifactory/api/pypi/wpilib-python-release-2024/simple
https://wpilib.jfrog.io/artifactory/api/pypi/wpilib-python-release-2025/simple
https://www.piwheels.org/simple
2 changes: 1 addition & 1 deletion cross-ubuntu-py/pip-roborio.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

[global]
extra-index-url = https://wpilib.jfrog.io/artifactory/api/pypi/wpilib-python-release-2024/simple
extra-index-url = https://wpilib.jfrog.io/artifactory/api/pypi/wpilib-python-release-2025/simple
130 changes: 76 additions & 54 deletions cross-ubuntu-py/py.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

UBUNTU?=22.04
YEAR?=2025
DOCKER_USER?=wpilib

TYPE_RASPBIAN=raspbian
Expand All @@ -19,46 +20,11 @@ AC_TARGET_HOST_ROBORIO=armv7l-frc2024-linux-gnueabi


.PHONY: build/cross-python
build/cross-python: build/cross-raspbian-py38 build/cross-aarch64-py38 build/cross-raspbian-py39 build/cross-aarch64-py39 build/cross-raspbian-py310 build/cross-aarch64-py310 build/cross-raspbian-py311 build/cross-aarch64-py311 build/cross-roborio-py312 build/cross-raspbian-py312 build/cross-aarch64-py312

.PHONY: push/cross-python
push/cross-python: push/cross-raspbian-py38 push/cross-aarch64-py38 push/cross-raspbian-py39 push/cross-aarch64-py39 push/cross-raspbian-py310 push/cross-aarch64-py310 push/cross-raspbian-py311 push/cross-aarch64-py311 push/cross-roborio-py312 push/cross-raspbian-py312 push/cross-aarch64-py312


#
# Python 3.8
#

.PHONY: build/cross-raspbian-py38
build/cross-raspbian-py38:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(VERSION_RASPBIAN)-$(UBUNTU)-py38 \
--build-arg ARCH=$(TYPE_RASPBIAN) \
--build-arg TARGET_HOST=$(TARGET_HOST_RASPBIAN) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_RASPBIAN) \
--build-arg VERSION=$(VERSION_RASPBIAN) \
-f Dockerfile.py38

.PHONY: push/cross-raspbian-py38
push/cross-raspbian-py38:
docker push wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(VERSION_RASPBIAN)-$(UBUNTU)-py38
build/cross-python: build/cross-raspbian-py39 build/cross-aarch64-py39 build/cross-raspbian-py310 build/cross-aarch64-py310 build/cross-raspbian-py311 build/cross-aarch64-py311 build/cross-raspbian-py312 build/cross-aarch64-py312 build/cross-roborio-py313 build/cross-raspbian-py313 build/cross-aarch64-py313


.PHONY: build/cross-aarch64-py38
build/cross-aarch64-py38:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py38 \
--build-arg ARCH=$(TYPE_AARCH64) \
--build-arg TARGET_HOST=$(TARGET_HOST_AARCH64) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_AARCH64) \
--build-arg VERSION=$(VERSION_AARCH64) \
-f Dockerfile.py38

.PHONY: push/cross-aarch64-py38
push/cross-aarch64-py38:
docker push wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py38
.PHONY: push/cross-python
push/cross-python: push/cross-raspbian-py39 push/cross-aarch64-py39 push/cross-raspbian-py310 push/cross-aarch64-py310 push/cross-raspbian-py311 push/cross-aarch64-py311 push/cross-raspbian-py312 push/cross-aarch64-py312 push/cross-roborio-py313 push/cross-raspbian-py313 push/cross-aarch64-py313


#
Expand All @@ -69,7 +35,7 @@ push/cross-aarch64-py38:
build/cross-raspbian-py39:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(VERSION_RASPBIAN)-$(UBUNTU)-py39 \
-t wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(YEAR)-$(VERSION_RASPBIAN)-$(UBUNTU)-py39 \
--build-arg ARCH=$(TYPE_RASPBIAN) \
--build-arg TARGET_HOST=$(TARGET_HOST_RASPBIAN) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_RASPBIAN) \
Expand All @@ -78,14 +44,14 @@ build/cross-raspbian-py39:

.PHONY: push/cross-raspbian-py39
push/cross-raspbian-py39:
docker push wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(VERSION_RASPBIAN)-$(UBUNTU)-py39
docker push wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(YEAR)-$(VERSION_RASPBIAN)-$(UBUNTU)-py39


.PHONY: build/cross-aarch64-py39
build/cross-aarch64-py39:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py39 \
-t wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(YEAR)-$(VERSION_AARCH64)-$(UBUNTU)-py39 \
--build-arg ARCH=$(TYPE_AARCH64) \
--build-arg TARGET_HOST=$(TARGET_HOST_AARCH64) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_AARCH64) \
Expand All @@ -94,7 +60,7 @@ build/cross-aarch64-py39:

.PHONY: push/cross-aarch64-py39
push/cross-aarch64-py39:
docker push wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py39
docker push wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(YEAR)-$(VERSION_AARCH64)-$(UBUNTU)-py39


#
Expand All @@ -105,7 +71,7 @@ push/cross-aarch64-py39:
build/cross-raspbian-py310:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(VERSION_RASPBIAN)-$(UBUNTU)-py310 \
-t wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(YEAR)-$(VERSION_RASPBIAN)-$(UBUNTU)-py310 \
--build-arg ARCH=$(TYPE_RASPBIAN) \
--build-arg TARGET_HOST=$(TARGET_HOST_RASPBIAN) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_RASPBIAN) \
Expand All @@ -114,14 +80,14 @@ build/cross-raspbian-py310:

.PHONY: push/cross-raspbian-py310
push/cross-raspbian-py310:
docker push wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(VERSION_RASPBIAN)-$(UBUNTU)-py310
docker push wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(YEAR)-$(VERSION_RASPBIAN)-$(UBUNTU)-py310


.PHONY: build/cross-aarch64-py310
build/cross-aarch64-py310:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py310 \
-t wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(YEAR)-$(VERSION_AARCH64)-$(UBUNTU)-py310 \
--build-arg ARCH=$(TYPE_AARCH64) \
--build-arg TARGET_HOST=$(TARGET_HOST_AARCH64) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_AARCH64) \
Expand All @@ -130,7 +96,7 @@ build/cross-aarch64-py310:

.PHONY: push/cross-aarch64-py310
push/cross-aarch64-py310:
docker push wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py310
docker push wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(YEAR)-$(VERSION_AARCH64)-$(UBUNTU)-py310


#
Expand All @@ -141,7 +107,7 @@ push/cross-aarch64-py310:
build/cross-raspbian-py311:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(VERSION_RASPBIAN)-$(UBUNTU)-py311 \
-t wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(YEAR)-$(VERSION_RASPBIAN)-$(UBUNTU)-py311 \
--build-arg ARCH=$(TYPE_RASPBIAN) \
--build-arg TARGET_HOST=$(TARGET_HOST_RASPBIAN) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_RASPBIAN) \
Expand All @@ -150,14 +116,14 @@ build/cross-raspbian-py311:

.PHONY: push/cross-raspbian-py311
push/cross-raspbian-py311:
docker push wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(VERSION_RASPBIAN)-$(UBUNTU)-py311
docker push wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(YEAR)-$(VERSION_RASPBIAN)-$(UBUNTU)-py311


.PHONY: build/cross-aarch64-py311
build/cross-aarch64-py311:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py311 \
-t wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(YEAR)-$(VERSION_AARCH64)-$(UBUNTU)-py311 \
--build-arg ARCH=$(TYPE_AARCH64) \
--build-arg TARGET_HOST=$(TARGET_HOST_AARCH64) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_AARCH64) \
Expand All @@ -166,7 +132,7 @@ build/cross-aarch64-py311:

.PHONY: push/cross-aarch64-py311
push/cross-aarch64-py311:
docker push wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py311
docker push wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(YEAR)-$(VERSION_AARCH64)-$(UBUNTU)-py311



Expand All @@ -178,7 +144,7 @@ push/cross-aarch64-py311:
build/cross-raspbian-py312:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(VERSION_RASPBIAN)-$(UBUNTU)-py312 \
-t wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(YEAR)-$(VERSION_RASPBIAN)-$(UBUNTU)-py312 \
--build-arg ARCH=$(TYPE_RASPBIAN) \
--build-arg TARGET_HOST=$(TARGET_HOST_RASPBIAN) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_RASPBIAN) \
Expand All @@ -187,7 +153,7 @@ build/cross-raspbian-py312:

.PHONY: push/cross-raspbian-py312
push/cross-raspbian-py312:
docker push wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(VERSION_RASPBIAN)-$(UBUNTU)-py312
docker push wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(YEAR)-$(VERSION_RASPBIAN)-$(UBUNTU)-py312


.PHONY: build/cross-roborio-py312
Expand All @@ -212,7 +178,7 @@ push/cross-roborio-py312:
build/cross-aarch64-py312:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py312 \
-t wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(YEAR)-$(VERSION_AARCH64)-$(UBUNTU)-py312 \
--build-arg ARCH=$(TYPE_AARCH64) \
--build-arg TARGET_HOST=$(TARGET_HOST_AARCH64) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_AARCH64) \
Expand All @@ -221,4 +187,60 @@ build/cross-aarch64-py312:

.PHONY: push/cross-aarch64-py312
push/cross-aarch64-py312:
docker push wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py312
docker push wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(YEAR)-$(VERSION_AARCH64)-$(UBUNTU)-py312



#
# Python 3.13
#

.PHONY: build/cross-raspbian-py313
build/cross-raspbian-py313:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(YEAR)-$(VERSION_RASPBIAN)-$(UBUNTU)-py313 \
--build-arg ARCH=$(TYPE_RASPBIAN) \
--build-arg TARGET_HOST=$(TARGET_HOST_RASPBIAN) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_RASPBIAN) \
--build-arg VERSION=$(VERSION_RASPBIAN) \
--build-arg EXTRA_CROSS_CONFIGURE_ARGS="ac_cv_libatomic_needed=yes" \
-f Dockerfile.py313

.PHONY: push/cross-raspbian-py313
push/cross-raspbian-py313:
docker push wpilib/$(TYPE_RASPBIAN)-cross-ubuntu:$(YEAR)-$(VERSION_RASPBIAN)-$(UBUNTU)-py313


.PHONY: build/cross-roborio-py313
build/cross-roborio-py313:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_ROBORIO)-cross-ubuntu:$(YEAR)-$(UBUNTU)-py313 \
--build-arg ARCH=$(TYPE_ROBORIO) \
--build-arg TARGET_HOST=$(TARGET_HOST_ROBORIO) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_ROBORIO) \
--build-arg VERSION=$(VERSION_ROBORIO) \
--build-arg MACHINE_ARG="--machine=roborio" \
-f Dockerfile.py313

.PHONY: push/cross-roborio-py313
push/cross-roborio-py313:
docker push wpilib/$(TYPE_ROBORIO)-cross-ubuntu:$(YEAR)-$(UBUNTU)-py313



.PHONY: build/cross-aarch64-py313
build/cross-aarch64-py313:
cd cross-ubuntu-py && \
docker build . \
-t wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py313 \
--build-arg ARCH=$(TYPE_AARCH64) \
--build-arg TARGET_HOST=$(TARGET_HOST_AARCH64) \
--build-arg AC_TARGET_HOST=$(AC_TARGET_HOST_AARCH64) \
--build-arg VERSION=$(VERSION_AARCH64) \
-f Dockerfile.py313

.PHONY: push/cross-aarch64-py313
push/cross-aarch64-py313:
docker push wpilib/$(TYPE_AARCH64)-cross-ubuntu:$(VERSION_AARCH64)-$(UBUNTU)-py313

0 comments on commit 9278b1c

Please sign in to comment.