From 0d367baa5bbc85b9738c81cbf8418da436c26b77 Mon Sep 17 00:00:00 2001 From: Hubert Chathi Date: Tue, 25 Apr 2023 18:47:37 -0400 Subject: [PATCH] add script for creating Python sdist --- python/make_sdist.sh | 32 ++++++++++++++++++++++++++++++++ python/packaging.diff | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 python/make_sdist.sh create mode 100644 python/packaging.diff diff --git a/python/make_sdist.sh b/python/make_sdist.sh new file mode 100755 index 0000000..7f157dc --- /dev/null +++ b/python/make_sdist.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e + +DIR=$(mktemp -d) +SRC=$(pwd) + +cd $DIR + +echo "Copying python module" +cp -a $SRC/* . +mkdir -p libolm +echo "Cleaning sources" +make clean > /dev/null +cp -a $SRC/include . +echo "Copying libolm sources" +for src in cmake CMakeLists.txt common.mk include lib Makefile olm.pc.in src tests; do + cp -a $SRC/../$src libolm +done +find libolm -name \*~ -delete +find libolm -name \#\*\# -delete + +echo "Building" +patch -p1 < $SRC/packaging.diff +python3 setup.py sdist + +echo "Copying result" +mkdir -p $SRC/dist +cp dist/* $SRC/dist + +echo "Cleaning up" +cd $SRC +rm -rf $DIR diff --git a/python/packaging.diff b/python/packaging.diff new file mode 100644 index 0000000..d0af5e0 --- /dev/null +++ b/python/packaging.diff @@ -0,0 +1,41 @@ +--- a/MANIFEST.in ++++ b/MANIFEST.in +@@ -1,3 +1,8 @@ + include include/olm/*.h +-include Makefile + include olm_build.py ++include libolm/* ++include libolm/cmake/* ++include libolm/include/olm/* ++recursive-include libolm/lib * ++include libolm/src/* ++recursive-include libolm/tests * +--- a/olm_build.py ++++ b/olm_build.py +@@ -25,14 +25,23 @@ + + DEVELOP = os.environ.get("DEVELOP") + +-compile_args = ["-I../include"] +-link_args = ["-L../build"] ++compile_args = ["-Ilibolm/include"] ++link_args = ["-Llibolm/build"] + + if DEVELOP and DEVELOP.lower() in ["yes", "true", "1"]: + link_args.append('-Wl,-rpath=../build') + +-headers_build = subprocess.Popen("make headers", shell=True) +-headers_build.wait() ++try: ++ subprocess.run( ++ ["cmake", ".", "-Bbuild", "-DBUILD_SHARED_LIBS=NO"], ++ cwd="libolm", check=True, ++ ) ++ subprocess.run( ++ ["cmake", "--build", "build"], ++ cwd="libolm", check=True, ++ ) ++except FileNotFoundError: ++ subprocess.run(["make", "static"], cwd="libolm", check=True) + + ffibuilder.set_source(