Skip to content

Commit

Permalink
Ensure custom flags get passed to python modules for macOS
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Nov 8, 2023
1 parent f02f89c commit 4587dad
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 16 deletions.
36 changes: 20 additions & 16 deletions bootstrap-mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -275,20 +275,22 @@ build_waf lvtk1 "${LVTK1_VERSION}" "${LVTK1_EXTRAFLAGS}"

AGGDRAW_VERSION="1.3.11"

if [ "${WIN32}" -eq 1 ]; then
export AGGDRAW_FREETYPE_ROOT="${PAWPAW_PREFIX}"
export EXTRA_CFLAGS="$(${PAWPAW_PREFIX}/bin/pkg-config --cflags python3 freetype2 libpng)"
export EXTRA_LDFLAGS="-shared $(${PAWPAW_PREFIX}/bin/pkg-config --libs python3 freetype2 libpng) -lgdi32 -lkernel32 -luser32"
export LDSHARED="${TARGET_CXX}"
export EXTRA_CFLAGS="$(${PAWPAW_PREFIX}/bin/pkg-config --cflags python3 freetype2 libpng)"
export EXTRA_LDFLAGS="$(${PAWPAW_PREFIX}/bin/pkg-config --libs python3 freetype2 libpng) -shared"
if [ "${MACOS}" -eq 1 ]; then
export EXTRA_LDFLAGS+=" -Wl,-undefined,dynamic_lookup"
elif [ "${WIN32}" -eq 1 ]; then
export EXTRA_LDFLAGS+=" -lgdi32 -lkernel32 -luser32"
fi

export AGGDRAW_FREETYPE_ROOT="${PAWPAW_PREFIX}"
export LDSHARED="${TARGET_CXX}"

download aggdraw "${AGGDRAW_VERSION}" "https://files.pythonhosted.org/packages/ef/29/fddf555c68920bb0aff977425af786226db2a78379e706951ff32b4492ef"
build_python aggdraw "${AGGDRAW_VERSION}"

if [ "${WIN32}" -eq 1 ]; then
unset AGGDRAW_FREETYPE_ROOT
unset LDSHARED
fi
unset AGGDRAW_FREETYPE_ROOT
unset LDSHARED

if [ "${WIN32}" -eq 1 ] && [ "${CROSS_COMPILING}" -eq 1 ]; then
PYTHONPATH="${PAWPAW_PREFIX}/lib/python3.8/site-packages"
Expand Down Expand Up @@ -325,12 +327,16 @@ fi

PILLOW_VERSION="8.2.0"

if [ "${WIN32}" -eq 1 ]; then
export EXTRA_CFLAGS="$(${PAWPAW_PREFIX}/bin/pkg-config --cflags python3 freetype2 libpng)"
export EXTRA_LDFLAGS="-shared $(${PAWPAW_PREFIX}/bin/pkg-config --libs python3 freetype2 libpng) -lgdi32 -lkernel32 -lpsapi -luser32"
export LDSHARED="${TARGET_CXX}"
export EXTRA_CFLAGS="$(${PAWPAW_PREFIX}/bin/pkg-config --cflags python3 freetype2 libpng)"
export EXTRA_LDFLAGS="$(${PAWPAW_PREFIX}/bin/pkg-config --libs python3 freetype2 libpng) -shared"
if [ "${MACOS}" -eq 1 ]; then
export EXTRA_LDFLAGS+=" -Wl,-undefined,dynamic_lookup"
elif [ "${WIN32}" -eq 1 ]; then
export EXTRA_LDFLAGS+=" -lgdi32 -lkernel32 -lpsapi -luser32"
fi

export LDSHARED="${TARGET_CXX}"

PILLOW_EXTRAFLAGS=""
PILLOW_EXTRAFLAGS+=" --enable-freetype"
PILLOW_EXTRAFLAGS+=" --enable-zlib"
Expand All @@ -349,9 +355,7 @@ fi
download Pillow "${PILLOW_VERSION}" "https://files.pythonhosted.org/packages/21/23/af6bac2a601be6670064a817273d4190b79df6f74d8012926a39bc7aa77f"
build_python Pillow "${PILLOW_VERSION}" "${PILLOW_EXTRAFLAGS}"

if [ "${WIN32}" -eq 1 ]; then
unset LDSHARED
fi
unset LDSHARED

if [ "${WIN32}" -eq 1 ] && [ "${CROSS_COMPILING}" -eq 1 ]; then
PYTHONPATH="${PAWPAW_PREFIX}/lib/python3.8/site-packages"
Expand Down
28 changes: 28 additions & 0 deletions patches/Python/macos/9001-pawpaw-needed-changes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
index f159586..004e89f 100644
--- a/Lib/distutils/unixccompiler.py
+++ b/Lib/distutils/unixccompiler.py
@@ -200,6 +200,10 @@ class UnixCCompiler(CCompiler):

if sys.platform == 'darwin':
linker = _osx_support.compiler_fixup(linker, ld_args)
+ if target_lang == "c++" and self.compiler_cxx:
+ ld_args += linker[i+offset+1:]
+ else:
+ ld_args += linker[1:]

self.spawn(linker + ld_args)
except DistutilsExecError as msg:
diff --git a/setup.py b/setup.py
index 3a7a2e7..88e116a 100644
--- a/setup.py
+++ b/setup.py
@@ -2289,7 +2289,7 @@ class PyBuildExt(build_ext):
# poor man's shlex, the re module is not available yet.
value = config_vars.get(name)
if not value:
- return ()
+ return []
# This trick works because ax_check_openssl uses --libs-only-L,
# --libs-only-l, and --cflags-only-I.
value = ' ' + value

0 comments on commit 4587dad

Please sign in to comment.