refactor pygomx-module -> pygomx

This commit is contained in:
saces 2026-03-09 17:27:43 +01:00
parent e1dfbe218d
commit 23fc397384
11 changed files with 181 additions and 34 deletions

View file

@ -4,40 +4,32 @@ ARG GOLANG_VERSION=1.24
ARG DEBIAN_VERSION=trixie
ARG PYTHON_VERSION=3.14
FROM docker.io/library/golang:${GOLANG_VERSION}-${DEBIAN_VERSION} AS gobuilder
RUN apt update
RUN apt -y install libolm-dev
RUN --mount=type=bind,source=./libmxclient/go.mod,target=/libmxclient/build/go.mod --mount=type=bind,source=./libmxclient/go.sum,target=/libmxclient/build/go.sum <<EOF
cd /libmxclient/build
go mod download
EOF
RUN --mount=type=bind,source=./libmxclient,target=/libmxclient/build <<EOF
# building go lib
set -e
cd /libmxclient/build
CGO_ENABLED=1 GOARCH=${GOARCH} go build -buildmode=c-shared -o /pygomx-build/libmxclient.so .
EOF
FROM docker.io/library/python:${PYTHON_VERSION}-${DEBIAN_VERSION} AS pybuilder
ENV PYTHONUNBUFFERED=1
ENV PIP_ROOT_USER_ACTION=ignore
COPY --from=gobuilder /pygomx-build/libmxclient.so /usr/local/lib/libmxclient.so
COPY --from=gobuilder /pygomx-build/libmxclient.h /usr/local/include/libmxclient.h
RUN <<EOF
# install packages
set -eu
apt update
apt -y upgrade
apt -y install golang libolm-dev
EOF
RUN pip install cffi setuptools
RUN pip install cffi setuptools build
COPY pygomx-module /pygomx
#RUN --mount=type=bind,source=.,target=/pygomx <<EOF
COPY libmxclient /pygomx/libmxclient
COPY pygomx /pygomx/pygomx
RUN <<EOF
# build py module
set -e
cd /pygomx
PYGOMX_BUILD_MODE=shared python3 build_ffi.py
ls -la *.so
set -eu
cd /pygomx/pygomx
python3 -m build --verbose --wheel --outdir /pygomx-wheel
ls -la /pygomx-wheel
EOF
FROM docker.io/library/python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION} AS develop
@ -54,9 +46,7 @@ apt -y install libolm3
rm -rf /var/lib/apt/lists/*
EOF
COPY --from=gobuilder /pygomx-build/libmxclient.so /usr/local/lib/
COPY --from=pybuilder /pygomx/_pygomx.cpython-314-x86_64-linux-gnu.so /usr/local/lib/python3.14/site-packages/
RUN ldconfig
RUN --mount=type=bind,from=pybuilder,source=/pygomx-wheel,target=/pygomx-wheel pip install /pygomx-wheel/*.whl
FROM develop AS demobot
WORKDIR /smal