Skip to content

Commit 74bb2d3

Browse files
committed
Fix Python 3.12 container tests and simplify CI matrix
- Add conditional symlink fix for Python 3.12 on Alpine Linux - Python 3.12 expects linux-gnu extension suffix, but Alpine provides linux-musl - Create symlinks from *-linux-gnu.so to *-linux-musl.so for C extensions - Fix is only applied when PYTHON_VERSION="3.12" to avoid affecting other versions - Fix dockerfile stage reference: FROM beta AS pro → FROM pre AS pro - Completes the beta→pre rename that was missed on line 108 - Simplify GitHub Actions Python version matrix - Remove get-python-version job from both test.yml and docker-publish.yml - Hardcode Python versions as `['3.12', '3.13']` to avoid duplication - Previously, 3.13 was tested twice (hardcoded + from .python-version file) - Makes workflows cleaner and easier to understand This fixes the `ModuleNotFoundError` for `pydantic_core._pydantic_core in` Docker containers running Python 3.12, while maintaining compatibility with other Python versions. Signed-off-by: Phillip Sitbon <phillip.sitbon@gmail.com>
1 parent 2e3a37c commit 74bb2d3

File tree

3 files changed

+14
-35
lines changed

3 files changed

+14
-35
lines changed

.github/workflows/docker-publish.yml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Publish Docker Images
1+
name: Build, Test, and Publish Docker Images
22

33
on:
44
push:
@@ -13,29 +13,15 @@ env:
1313
IMAGE_NAME: ${{ github.repository }}
1414

1515
jobs:
16-
get-python-version:
17-
runs-on: ubuntu-latest
18-
outputs:
19-
version: ${{ steps.python-version.outputs.version }}
20-
steps:
21-
- name: Checkout code
22-
uses: actions/checkout@v4
23-
24-
- name: Read Python version
25-
id: python-version
26-
run: |
27-
echo "version=$(cat .python-version)" >> $GITHUB_OUTPUT
28-
29-
test-dev:
30-
needs: get-python-version
16+
test-dev-container:
3117
runs-on: ubuntu-latest
3218
permissions:
3319
contents: read
3420
packages: write
3521

3622
strategy:
3723
matrix:
38-
python-version: ['3.12', '3.13', '${{ needs.get-python-version.outputs.version }}']
24+
python-version: ['3.12', '3.13']
3925
fail-fast: false
4026

4127
steps:
@@ -101,7 +87,7 @@ jobs:
10187
cache-from: type=gha
10288

10389
build-and-push:
104-
needs: test-dev
90+
needs: test-dev-container
10591
runs-on: ubuntu-latest
10692
permissions:
10793
contents: read

.github/workflows/test.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test
1+
name: Tests
22

33
on:
44
push:
@@ -7,25 +7,11 @@ on:
77
branches: ['*']
88

99
jobs:
10-
get-python-version:
11-
runs-on: ubuntu-latest
12-
outputs:
13-
version: ${{ steps.python-version.outputs.version }}
14-
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4
17-
18-
- name: Read Python version
19-
id: python-version
20-
run: |
21-
echo "version=$(cat .python-version)" >> $GITHUB_OUTPUT
22-
2310
test:
24-
needs: get-python-version
2511
runs-on: ubuntu-latest
2612
strategy:
2713
matrix:
28-
python-version: ['3.12', '3.13', '${{ needs.get-python-version.outputs.version }}']
14+
python-version: ['3.12', '3.13']
2915
fail-fast: false # Continue testing other versions if one fails
3016

3117
steps:

dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ RUN --mount=type=cache,uid=${UID},gid=${UID},target=${HOME}/.cache/uv \
5353
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
5454
uv sync --locked --no-install-project --no-dev
5555

56+
# Fix for Python 3.12 extension suffix mismatch on Alpine
57+
# Python 3.12 expects linux-gnu but we have linux-musl wheels
58+
RUN if [ "${PYTHON_VERSION}" = "3.12" ]; then \
59+
find .venv/lib -name "*.cpython-*-x86_64-linux-musl.so" -exec sh -c \
60+
'ln -sf "$(basename "$1")" "$(dirname "$1")/$(echo "$(basename "$1")" | sed "s/-musl\.so$/-gnu.so/")"' _ {} \; ; \
61+
fi
62+
5663
# Then, add the rest of the project source code and install it
5764
# Installing separately from its dependencies allows optimal layer caching
5865
ADD --chown=${USER}:${USER} pyproject.toml uv.lock readme.md license.md ./
@@ -98,7 +105,7 @@ RUN chown -R root:${USER} ${HOME}/.venv ${HOME}/${PACKAGE} && \
98105

99106
USER ${USER}
100107

101-
FROM beta AS pro
108+
FROM pre AS pro
102109

103110
LABEL org.opencontainers.image.source=https://github.com/sitbon/magg \
104111
org.opencontainers.image.description="MAGG - The Model Context Protocol (MCP) Aggregator" \

0 commit comments

Comments
 (0)