Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauszus committed Nov 14, 2024
1 parent 72d20dd commit 8d66c63
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
python-version: ['3.7', '3.9', '3.10', '3.11', '3.12', '3.13']
docker_images: ['balenalib/armv7hf-debian:bullseye']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
include:
- docker_images: 'balenalib/armv7hf-debian:buster'
python-version: '3.7'
steps:
- uses: actions/checkout@v4
- name: Build ${{ matrix.docker_images }} wheel
id: build
run: |
docker build -f Dockerfile.armv7l -t lauszus/socketsocketcan --build-arg PYTHON_VERSION="${{ matrix.python-version }}" .
docker build -f Dockerfile.armv7l -t lauszus/socketsocketcan --build-arg APP_IMAGE="${{ matrix.docker_images }}" PYTHON_VERSION="${{ matrix.python-version }}" .
docker cp "$(docker create lauszus/socketsocketcan)":/socketsocketcan-wheel .
# Copy over the wheel.
Expand Down
37 changes: 14 additions & 23 deletions Dockerfile.armv7l
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG APP_IMAGE=balenalib/armv7hf-debian:bullseye
ARG APP_IMAGE=balenalib/armv7hf-debian:buster
FROM $APP_IMAGE

ARG PYTHON_VERSION=3.7
Expand All @@ -8,46 +8,37 @@ COPY . /socketsocketcan

RUN [ "cross-build-start" ]

# Install build dependencies.
# I install Python even when using uv, as it pulls in dependencies for building packages.
RUN apt-get update && \
apt-get install --no-install-recommends -y \
build-essential \
python3-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install uv.
RUN curl -LsSf https://astral.sh/uv/0.5.1/install.sh | setarch armv7l sh
RUN curl -LsSf https://astral.sh/uv/0.5.1/install.sh | sh

# Make sure uv is in the path.
ENV PATH="$PATH:/root/.local/bin"

# Install Python using uv if we can not use the one installed in the system.
RUN if [ "$PYTHON_VERSION" != "3.7" ]; then \
RUN if ! uv python find "$PYTHON_VERSION" >/dev/null 2>&1; then \
uv python install "$PYTHON_VERSION"; \
apt-get update && \
apt-get install --no-install-recommends -y \
build-essential \
python3-dev \
python3-pip \
clang && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*; \
else \
apt-get update && \
apt-get install --no-install-recommends -y \
build-essential \
python3-dev \
python3-pip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
rm /usr/lib/python3.*/EXTERNALLY-MANAGED || true; \
python3 -m pip install --extra-index-url=https://www.piwheels.org/simple -U pip setuptools wheel; \
fi

# Create virtual environment.
RUN uv venv --python-preference managed

# Install Python dependencies.
RUN uv pip install --extra-index-url=https://www.piwheels.org/simple pybind11
RUN uv pip install --index=https://www.piwheels.org/simple pybind11

# Build the wheel.
RUN uv build --wheel --out-dir=/socketsocketcan-wheel /socketsocketcan

# Make sure the wheel is working.
RUN uv -v pip install --no-build socketsocketcan --find-links=/socketsocketcan-wheel socketsocketcan
RUN uv pip install --find-links=/socketsocketcan-wheel socketsocketcan
RUN uv run -- python -c "import socketsocketcan; print(dir(socketsocketcan))"

RUN [ "cross-build-end" ]

0 comments on commit 8d66c63

Please sign in to comment.