introduce build parameters
This commit is contained in:
parent
92782f1352
commit
5600b8056b
4 changed files with 58 additions and 19 deletions
|
|
@ -25,15 +25,6 @@ FROM docker.io/library/python:${PYTHON_VERSION}-${DEBIAN_VERSION} AS pybuilder
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
ENV PIP_ROOT_USER_ACTION=ignore
|
ENV PIP_ROOT_USER_ACTION=ignore
|
||||||
|
|
||||||
RUN <<EOF
|
|
||||||
# install packages
|
|
||||||
set -e
|
|
||||||
apt update
|
|
||||||
apt -y upgrade
|
|
||||||
apt -y install libolm-dev
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
EOF
|
|
||||||
|
|
||||||
COPY --from=gobuilder /pygomx-build/libmxclient.so /usr/local/lib/libmxclient.so
|
COPY --from=gobuilder /pygomx-build/libmxclient.so /usr/local/lib/libmxclient.so
|
||||||
COPY --from=gobuilder /pygomx-build/libmxclient.h /usr/local/include/libmxclient.h
|
COPY --from=gobuilder /pygomx-build/libmxclient.h /usr/local/include/libmxclient.h
|
||||||
|
|
||||||
|
|
@ -45,7 +36,7 @@ RUN <<EOF
|
||||||
# build py module
|
# build py module
|
||||||
set -e
|
set -e
|
||||||
cd /pygomx
|
cd /pygomx
|
||||||
PYGOMX_LINK_OLM=1 python3 build_ffi.py
|
PYGOMX_BUILD_MODE=shared python3 build_ffi.py
|
||||||
ls -la *.so
|
ls -la *.so
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
|
||||||
12
README.txt
12
README.txt
|
|
@ -18,7 +18,17 @@ the bot follows each invite (autojoin) and have two commands:
|
||||||
|
|
||||||
install from source (venv):
|
install from source (venv):
|
||||||
|
|
||||||
you need go >=1.22 and libolm-dev installed
|
build configuration is done via env vars
|
||||||
|
|
||||||
|
# one of static, shared
|
||||||
|
PYGOMX_BUILD_MODE=static
|
||||||
|
|
||||||
|
# one of none, colm, goolm, vodozemac
|
||||||
|
PYGOMX_OLM_FLAVOR=colm
|
||||||
|
# for colm you need libolm-dev installed
|
||||||
|
# vodozemac is not supported yet
|
||||||
|
|
||||||
|
you need go >=1.22 installed
|
||||||
|
|
||||||
(create and activate a venv)
|
(create and activate a venv)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@ lib_list = [
|
||||||
"mxclient",
|
"mxclient",
|
||||||
]
|
]
|
||||||
|
|
||||||
if os.getenv("PYGOMX_LINK_OLM"):
|
# keep defaults in sync with setup.py
|
||||||
|
if (
|
||||||
|
os.getenv("PYGOMX_BUILD_MODE", "static") == "static"
|
||||||
|
and os.getenv("PYGOMX_OLM_FLAVOR", colm) == "colm"
|
||||||
|
):
|
||||||
lib_list += ["olm"]
|
lib_list += ["olm"]
|
||||||
|
|
||||||
print(f"liblist: {lib_list}")
|
print(f"liblist: {lib_list}")
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from setuptools import Command, setup
|
from setuptools import Command, setup
|
||||||
|
|
@ -12,12 +13,45 @@ class CustomCommand(Command):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
|
# configure the go build via env vars
|
||||||
|
# keep defaults in sync with build_ffi.py
|
||||||
|
go_tags_str = os.getenv("PYGOMX_GO_TAGS")
|
||||||
|
if go_tags_str and len(go_tags_str.strip()) > 0:
|
||||||
|
go_tags = go_tags_str.split(",")
|
||||||
|
else:
|
||||||
|
go_tags = []
|
||||||
|
|
||||||
|
match os.getenv("PYGOMX_BUILD_MODE", "static"):
|
||||||
|
case "static":
|
||||||
|
build_mode_name = "c-archive"
|
||||||
|
build_mode_ext = ".a"
|
||||||
|
case "shared":
|
||||||
|
build_mode_name = "c-shared"
|
||||||
|
build_mode_ext = ".so"
|
||||||
|
case _:
|
||||||
|
raise ValueError("Invalid PYGOMX_BUILD_MODE.")
|
||||||
|
|
||||||
|
match os.getenv("PYGOMX_OLM_FLAVOR", "colm"):
|
||||||
|
case "none":
|
||||||
|
go_tags += ["nocrypto"]
|
||||||
|
case "colm":
|
||||||
|
go_tags += ["colm"]
|
||||||
|
case "goolm":
|
||||||
|
go_tags += ["goolm"]
|
||||||
|
case "vodozemac":
|
||||||
|
go_tags += ["vodozemac"]
|
||||||
|
raise ValueError("Vodozemac not supported (yet).")
|
||||||
|
case _:
|
||||||
|
raise ValueError("Invalid PYGOMX_OLM_FLAVOR.")
|
||||||
|
|
||||||
go_call = [
|
go_call = [
|
||||||
"go",
|
"go",
|
||||||
"build",
|
"build",
|
||||||
"-buildmode=c-archive",
|
f"-buildmode=${build_mode_name}",
|
||||||
|
"-tags",
|
||||||
|
",".join(go_tags),
|
||||||
"-o",
|
"-o",
|
||||||
"../pygomx-module/libmxclient.a",
|
f"../pygomx-module/libmxclient${build_mode_ext}",
|
||||||
".",
|
".",
|
||||||
]
|
]
|
||||||
subprocess.call(go_call, cwd="../libmxclient")
|
subprocess.call(go_call, cwd="../libmxclient")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue