Skip to content

Commit

Permalink
Compile wheels for Raspberry Pi 1-3
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauszus committed Jan 9, 2020
1 parent 1b377ba commit e6afe6d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
11 changes: 10 additions & 1 deletion .ci/Dockerfile.armv7l
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ RUN /bin/bash -c 'source .ci/ubuntu_ci.sh && \
install_python && \
install_kivy_test_run_pip_deps'

# Download the Raspberry Pi firmware if we are targeting the Raspberry Pi 1-3.
ARG KIVY_CROSS_PLATFORM=""
ARG KIVY_CROSS_SYSROOT=""
RUN if [ "$KIVY_CROSS_PLATFORM" = "rpi" ]; then \
apt-get -y install git; \
git clone --depth=1 https://github.com/raspberrypi/firmware "$KIVY_CROSS_SYSROOT"; \
ln -s "$KIVY_CROSS_SYSROOT"/opt/vc "$KIVY_CROSS_SYSROOT"/usr; \
fi

# Build the wheel.
RUN KIVY_SPLIT_EXAMPLES=1 VIDEOCOREMESA=1 python3 -m pip -v wheel --extra-index-url https://www.piwheels.org/simple . -w /kivy-wheel
RUN KIVY_SPLIT_EXAMPLES=1 VIDEOCOREMESA=1 KIVY_CROSS_PLATFORM="$KIVY_CROSS_PLATFORM" KIVY_CROSS_SYSROOT="$KIVY_CROSS_SYSROOT" python3 -m pip -v wheel --extra-index-url https://www.piwheels.org/simple . -w /kivy-wheel

RUN [ "cross-build-end" ]
25 changes: 16 additions & 9 deletions .ci/ubuntu_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,24 @@ generate_manylinux2010_wheels() {
generate_armv7l_wheels() {
image=$1

mkdir dist dist_armv6l
docker build -f .ci/Dockerfile.armv7l -t kivy/kivy-armv7l --build-arg image="$image" .
mkdir dist
docker build -f .ci/Dockerfile.armv7l -t kivy/kivy-armv7l --build-arg image="$image" --build-arg KIVY_CROSS_PLATFORM="$2" --build-arg KIVY_CROSS_SYSROOT="$3" .
docker cp "$(docker create kivy/kivy-armv7l)":/kivy-wheel .
cp kivy-wheel/Kivy-* dist/

# Rename the special wheels for the Raspberry Pi 1-3
if [ "$#" -gt 1 ]; then
for name in dist/*.whl; do
new_name="${name/-cp/.rpi123-cp}"
mv -n "$name" "$new_name"
done
fi

# Create a copy with the armv6l suffix
cp dist/*armv7l.whl dist_armv6l/
sudo apt-get -y install rename
rename 's/armv7l/armv6l/' dist_armv6l/*armv7l.whl
mv dist_armv6l/*armv6l.whl dist/
rmdir dist_armv6l
for name in dist/*.whl; do
new_name="${name/armv7l/armv6l}"
cp -n "$name" "$new_name"
done
}

rename_wheels() {
Expand All @@ -112,12 +119,12 @@ rename_wheels() {
-c "import kivy; _, tag, n = kivy.parse_kivy_version(kivy.__version__); print(tag + n) if n is not None else print(tag or 'something')" \
--config "kivy:log_level:error")
echo "tag_name=$tag_name"
wheel_name="$tag_name.$wheel_date.$git_tag-"
wheel_name="$tag_name.$wheel_date.$git_tag"
echo "wheel_name=$wheel_name"

ls dist/
for name in dist/*.whl; do
new_name="${name/$tag_name-/$wheel_name}"
new_name="${name/$tag_name/$wheel_name}"
if [ ! -f "$new_name" ]; then
cp -n "$name" "$new_name"
fi
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/rpi_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,27 @@ on:

env:
SERVER_IP: '159.203.106.198'
KIVY_CROSS_PLATFORM: 'rpi'
KIVY_CROSS_SYSROOT: '/rpi-firmware'

jobs:
raspberrypi:
runs-on: ubuntu-18.04
if: github.event_name == 'schedule' || (github.event_name == 'create' && github.event.ref_type == 'tag') || contains(github.event.head_commit.message, '[build wheel]') || contains(github.event.head_commit.message, '[build wheel armv7l]') || contains(github.event.pull_request.title, '[build wheel]') || contains(github.event.pull_request.title, '[build wheel armv7l]')
strategy:
matrix:
platform: ['rpi123', 'rpi4']
docker_images: ['balenalib/armv7hf-debian:stretch', 'balenalib/armv7hf-debian:buster']
steps:
- uses: actions/checkout@v1
- name: Make ${{ matrix.docker_images }} wheel
run: |
source .ci/ubuntu_ci.sh
generate_armv7l_wheels ${{ matrix.docker_images }}
if [ "${{ matrix.platform }}" == "rpi123" ]; then
generate_armv7l_wheels ${{ matrix.docker_images }} "$KIVY_CROSS_PLATFORM" "$KIVY_CROSS_SYSROOT"
else
generate_armv7l_wheels ${{ matrix.docker_images }}
fi
- name: Rename wheels
if: github.event.ref_type != 'tag'
run: |
Expand Down

0 comments on commit e6afe6d

Please sign in to comment.