Browse Source

Cleanup for python/pyqt windows packages

Signed-off-by: falkTX <falktx@falktx.com>
tags/v1.1
falkTX 2 years ago
parent
commit
86db5e14cf
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
8 changed files with 173 additions and 110 deletions
  1. +58
    -81
      bootstrap-carla.sh
  2. +4
    -4
      bootstrap-qt.sh
  3. +15
    -24
      patches/PyQt5_gpl/win32/01_cfg-env-vars.patch
  4. +33
    -0
      patches/PyQt5_gpl/win32/02_qmake-xspec.patch
  5. +36
    -0
      patches/sip/001-use-env-vars.patch
  6. +13
    -0
      patches/sip/002-module-extension.patch
  7. +1
    -1
      patches/sip/win32/0001-mingw-python.patch
  8. +13
    -0
      patches/sip/win32/9001-pawpaw-needed-changes.patch

+ 58
- 81
bootstrap-carla.sh View File

@@ -41,7 +41,7 @@ function build_conf_python() {
local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}"

if [ "${CROSS_COMPILING}" -eq 1 ]; then
extraconfrules+=" --host=${TOOLCHAIN_PREFIX} --build=x86_64-linux-gnu"
extraconfrules+=" --host=${TOOLCHAIN_PREFIX} --build=$(gcc -dumpmachine)"
fi

_prebuild "${name}" "${pkgdir}"
@@ -71,18 +71,10 @@ function build_conf_python() {
if [ ! -f "${pkgdir}/.stamp_built" ]; then
pushd "${pkgdir}"
if [ "${WIN32}" -eq 1 ]; then
# adds -Wl,-Bdynamic so we link to shared python lib
sed -i -e 's|BLDLIBRARY= -L.|BLDLIBRARY= -Wl,-Bdynamic -L.|' Makefile
# EXE suffix missing
sed -i -e 's|./Programs/_freeze_importlib zipimport|./Programs/_freeze_importlib$(EXE) zipimport|' Makefile
# inject exe-wrapper
if [ -n "${EXE_WRAPPER}" ]; then
sed -i -e "s|\t./Programs/_freeze_importlib|\t${EXE_WRAPPER} ./Programs/_freeze_importlib|" Makefile
fi
# use toolchain prefix on windres tool if cross-compiling
if [ "${CROSS_COMPILING}" -eq 1 ]; then
sed -i -e "s|\twindres|\t${TOOLCHAIN_PREFIX_}windres|" Makefile
fi
make regen-importlib
fi
make ${MAKE_ARGS}
@@ -119,70 +111,38 @@ function build_pyqt() {
export CXXFLAGS="$(echo ${CXXFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"
export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,-dead_strip -Wl,-dead_strip_dylibs//')"
export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,--strip-all//')"
export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-Wl,--gc-sections//')"
export LDFLAGS="$(echo ${LDFLAGS} | sed -e 's/-fdata-sections -ffunction-sections//')"

if [ "${WIN32}" -eq 1 ]; then
export CXXFLAGS+=" -Wno-deprecated-copy"
fi

# non-standard vars used by sip/pyqt
export LFLAGS="${LDFLAGS}"
export LINK="${CXX}"

if [ ! -f "${pkgdir}/.stamp_configured" ]; then
pushd "${pkgdir}"

local python="python$(echo ${PYTHON_VERSION} | cut -b 1,2,3)"

# Place link to Qt DLLs for PyQt tests
if [ "${WIN32}" -eq 1 ] && [ "${name}" = "PyQt5_gpl" ]; then
mkdir -p release
if [ "${WIN32}" -eq 1 ] && [ -d "pyuic" ] && [ ! -d "release" ]; then
mkdir release
ln -sf "${PAWPAW_PREFIX}/bin"/Qt* release/
fi

local python3=python3
${python} configure.py ${extraconfrules}

if [ "${CROSS_COMPILING}" -eq 1 ]; then
python3=python3.8
fi

${python3} configure.py ${extraconfrules}

# build sip as host tool first
if [ "${CROSS_COMPILING}" -eq 1 ] && [ "${name}" = "sip" ]; then
pushd "sipgen"
PATH="${OLD_PATH}" make sip LFLAGS="-Wl,-s" ${MAKE_ARGS}
popd
if [ "${WIN32}" -eq 1 ]; then
sed -i -e "s/sip.so/sip.pyd/" installed.txt
fi
fi

# use env vars
sed -i -e 's/CC = gcc/CC ?= gcc/' */Makefile
sed -i -e 's/CXX = g++/CXX ?= g++/' */Makefile
sed -i -e 's/LINK = g++/LINK = $(CXX)/' */Makefile
sed -i -e 's/CFLAGS *=/CFLAGS +=/' */Makefile
sed -i -e 's/CXXFLAGS *=/CXXFLAGS +=/' */Makefile
sed -i -e 's/LIBS *=/LIBS += $(LDFLAGS)/' */Makefile

if [ -f "QtCore/Makefile.Release" ]; then
sed -i -e 's/CFLAGS *=/CFLAGS +=/' */Makefile.Release
sed -i -e 's/CXXFLAGS *=/CXXFLAGS +=/' */Makefile.Release
sed -i -e 's/LIBS *=/LIBS += $(LDFLAGS)/' */Makefile.Release
fi

# use abstract python3 path
sed -i -e 's|/usr/bin/python3|python3|g' Makefile

# use PREFIX var
sed -i -e "s|/usr|${PAWPAW_PREFIX}|g" installed.txt Makefile */Makefile
# use abstract python3 path
sed -i -e 's|/usr/bin/python3|python3|g' Makefile

if [ -f "QtCore/Makefile.Release" ]; then
sed -i -e "s|/usr|${PAWPAW_PREFIX}|g" */Makefile.Release
fi

# fix win32 linkage
if [ "${WIN32}" -eq 1 ]; then
sed -i -e 's|config -lpython3.8|config-3.8 -Wl,-Bdynamic -lpython3.8 -Wl,-Bstatic|' */Makefile
# use PREFIX var
sed -i -e "s|/usr|${PAWPAW_PREFIX}|g" installed.txt Makefile */Makefile
if [ -f "QtCore/Makefile.Release" ]; then
for mak in $(find -maxdepth 2 -type f -name Makefile.Release); do
echo "LIBS += -L${PAWPAW_PREFIX}/lib/python3.8/config-3.8 -Wl,-Bdynamic -lpython3.8 -Wl,-Bstatic" >> ${mak}
done
sed -i -e "s|/usr|${PAWPAW_PREFIX}|g" */Makefile.Release
fi
fi

@@ -192,6 +152,14 @@ function build_pyqt() {

if [ ! -f "${pkgdir}/.stamp_built" ]; then
pushd "${pkgdir}"

# build sip as host tool first
if [ "${CROSS_COMPILING}" -eq 1 ] && [ -d "sipgen" ] && [ ! -f "sipgen/sip" ]; then
pushd "sipgen"
PATH="${OLD_PATH}" make sip CC="gcc" LINK="gcc" LFLAGS="-Wl,-s" ${MAKE_ARGS}
popd
fi

make PREFIX="${PAWPAW_PREFIX}" PKG_CONFIG="${TARGET_PKG_CONFIG}" ${MAKE_ARGS}
touch .stamp_built
popd
@@ -200,22 +168,18 @@ function build_pyqt() {
if [ ! -f "${pkgdir}/.stamp_installed" ]; then
pushd "${pkgdir}"
make PREFIX="${PAWPAW_PREFIX}" PKG_CONFIG="${TARGET_PKG_CONFIG}" ${MAKE_ARGS} -j 1 install

if [ "${name}" = "PyQt5_gpl" ]; then
if [ "${CROSS_COMPILING}" -eq 1 ]; then
sed -i -e "s|/usr|${PAWPAW_PREFIX}|g" ${PAWPAW_PREFIX}/bin/py*5
if [ -n "${APP_EXT}" ]; then
sed -i -e "s|3.8 -m|3.8${APP_EXT} -m|" ${PAWPAW_PREFIX}/bin/py*5
fi
if [ -n "${EXE_WRAPPER}" ]; then
sed -i -e "s|exec /|exec ${EXE_WRAPPER} /|" ${PAWPAW_PREFIX}/bin/py*5
fi
if [ "${WIN32}" -eq 1 ]; then
sed -i -e "s|d ||" ${PAWPAW_PREFIX}/lib/pkgconfig/Qt5*.pc
fi
fi
if [ -n "${EXE_WRAPPER}" ]; then
sed -i -e "s|exec /|exec ${EXE_WRAPPER} /|" ${PAWPAW_PREFIX}/bin/py*5
fi
touch .stamp_installed
popd
fi

unset LFLAGS
unset LINK
}

# ---------------------------------------------------------------------------------------------------------------------
@@ -245,7 +209,6 @@ elif [ "${WIN32}" -eq 1 ]; then
PYTHON_EXTRAFLAGS="--with-nt-threads"
PYTHON_EXTRAFLAGS+=" --without-ensurepip"
PYTHON_EXTRAFLAGS+=" --without-c-locale-coercion"
# PYTHON_EXTRAFLAGS+=" --enable-optimizations"
# Workaround for conftest error on 64-bit builds
PYTHON_EXTRAFLAGS+=" ac_cv_working_tzset=no"
# Workaround for when dlfcn exists on Windows, which causes
@@ -260,7 +223,6 @@ elif [ "${WIN32}" -eq 1 ]; then
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_MEMBER=no"
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NODELETE=no"
PYTHON_EXTRAFLAGS+=" ac_cv_have_decl_RTLD_NOLOAD=no"
PYTHON_EXTRAFLAGS+=" OPT="
fi

download Python "${PYTHON_VERSION}" "https://www.python.org/ftp/python/${PYTHON_VERSION}" "tgz"
@@ -280,7 +242,10 @@ else
fi

if [ "${WIN32}" -eq 1 ]; then
SIP_EXTRAFLAGS+=" --platform win32-g++ EXTENSION_PLUGIN=pyd"
SIP_EXTRAFLAGS="--platform win32-g++"
SIP_EXTRAFLAGS+=" EXTENSION_PLUGIN=pyd"
SIP_EXTRAFLAGS+=" INCDIR=${PAWPAW_PREFIX}/include/python3.8"
SIP_EXTRAFLAGS+=" LIBDIR=${PAWPAW_PREFIX}/lib/python3.8/config-3.8"
fi

download sip "${SIP_VERSION}" "${SIP_DOWNLOAD_URL}"
@@ -297,10 +262,26 @@ else
PYQT5_SUFFIX="_gpl"
fi

# qmake needs this
if [ "${CROSS_COMPILING}" -eq 1 ]; then
export PKG_CONFIG_LIBDIR="${TARGET_PKG_CONFIG_PATH}"
export PKG_CONFIG_SYSROOT_DIR="/"
fi

PYQT5_EXTRAFLAGS="--qmake ${PAWPAW_PREFIX}/bin/qmake --sip ${PAWPAW_PREFIX}/bin/sip"

download PyQt5${PYQT5_SUFFIX} "${PYQT5_VERSION}" "${PYQT5_DOWNLOAD_URL}"
build_pyqt PyQt5${PYQT5_SUFFIX} "${PYQT5_VERSION}" "${PYQT5_EXTRAFLAGS} --concatenate --confirm-license -c"
build_pyqt PyQt5${PYQT5_SUFFIX} "${PYQT5_VERSION}" "${PYQT5_EXTRAFLAGS} --concatenate --confirm-license"

if [ "${CROSS_COMPILING}" -eq 1 ]; then
unset PKG_CONFIG_LIBDIR
unset PKG_CONFIG_SYSROOT_DIR
fi

# TODO: finish this
if [ "${WIN32}" -eq 1 ]; then
exit 0
fi

# ---------------------------------------------------------------------------------------------------------------------
# cython (optional)
@@ -313,24 +294,20 @@ fi
# ---------------------------------------------------------------------------------------------------------------------
# pyliblo

export EXTRA_CFLAGS="$(${PAWPAW_PREFIX}/bin/python3-config --cflags | awk 'sub("-ne","")')"
export EXTRA_CFLAGS+=" $(pkg-config --cflags liblo)"
export EXTRA_LDFLAGS="-shared -L/home/falktx/PawPawBuilds/targets/win64/bin $(${PAWPAW_PREFIX}/bin/python3-config --ldflags | awk 'sub("-ne","")' | awk 'sub("/lib -lpython3.8","/lib -Wl,-Bdynamic -lpython3.8")')"
export EXTRA_LDFLAGS+=" -Wl,-Bstatic $(pkg-config --libs liblo)"
if [ "${WIN32}" -eq 1 ]; then
export EXTRA_CFLAGS="$(${PAWPAW_PREFIX}/bin/pkg-config --cflags python3 liblo)"
export EXTRA_LDFLAGS="-shared $(${PAWPAW_PREFIX}/bin/pkg-config --libs python3 liblo)"
export LDSHARED="${TARGET_CXX}"
fi

# export LINK="${TARGET_CXX}"
# export LINKER="${TARGET_CXX}"
export LDSHARED="${TARGET_CXX}"

# export PYTHONPATH="/home/falktx/PawPawBuilds/targets/win64/lib/python3.8"

download pyliblo "${PYLIBLO_VERSION}" "http://das.nasophon.de/download"
build_python pyliblo "${PYLIBLO_VERSION}"

# TODO: finish this
if [ "${WIN32}" -eq 1 ]; then
exit 0
unset LDSHARED
fi

# ---------------------------------------------------------------------------------------------------------------------


+ 4
- 4
bootstrap-qt.sh View File

@@ -76,7 +76,7 @@ function build_qt_conf() {
export PKG_CONFIG="${TARGET_PKG_CONFIG}"
export PKG_CONFIG_LIBDIR="${TARGET_PKG_CONFIG_PATH}"
export PKG_CONFIG_PATH="${TARGET_PKG_CONFIG_PATH}"
export PKG_CONFIG_SYSROOT_DIR="${TARGET_PKG_CONFIG_PATH}"
export PKG_CONFIG_SYSROOT_DIR="/"

if [ -d "${PAWPAW_ROOT}/patches/${name}" ]; then
for p in $(ls "${PAWPAW_ROOT}/patches/${name}/" | grep "\.patch" | sort); do
@@ -100,9 +100,6 @@ function build_qt_conf() {
pushd "${pkgdir}"
./configure ${extraconfrules}
touch .stamp_configured
#sed -i -e 's/sub-tests //' Makefile
#sed -i -e 's/sub-tests-all //' Makefile
#sed -i -e 's/sub-tests-qmake_all //' Makefile
popd
fi

@@ -121,6 +118,9 @@ function build_qt_conf() {
if [ ! -f "${pkgdir}/.stamp_installed" ]; then
pushd "${pkgdir}"
make ${MAKE_ARGS} -j 1 install
if [ "${WIN32}" -eq 1 ]; then
sed -i -e "s|d ||" ${PAWPAW_PREFIX}/lib/pkgconfig/Qt5*.pc
fi
touch .stamp_installed
popd
fi


+ 15
- 24
patches/PyQt5_gpl/win32/01_cfg-env-vars.patch View File

@@ -2,35 +2,12 @@ diff --git a/configure.py b/configure.py
index d893ae8..7d13747 100644
--- a/configure.py
+++ b/configure.py
@@ -1558,7 +1558,7 @@ def generate_makefiles(target_config, verbose, parts, tracing, fatal_warnings, d
inf = open_for_writing('__init__.py')
inf.write(contents)
- if target_config.py_platform == 'win32':
+ if target_config.py_platform == 'win32' or True:
# On Windows we try and make sure the Qt DLLs can be found, either any
# bundled copies or an existing installation (using the traditional
# Windows DLL search). We don't raise an exception in case the
@@ -2124,11 +2124,8 @@ def run_make(target_config, verbose, exe, makefile_name):
# Guess the name of make and set the default target and platform specific
# name of the executable.
- if target_config.py_platform == 'win32':
- if target_config.qmake_spec == 'win32-g++':
- make = 'mingw32-make'
- else:
- make = 'nmake'
+ if target_config.py_platform == 'win32' or True:
+ make = 'make'
if target_config.debug:
makefile_target = 'debug'
@@ -2421,6 +2418,10 @@ def compile_test_program(target_config, verbose, mname, source=None, debug=None)
pro_lines.append('TARGET = %s' % name)
pro_lines.append('SOURCES = %s' % qmake_quote(name_source))
+ pro_lines.append('QMAKE_CXXFLAGS += $$(CXXFLAGS)')
+ pro_lines.append('QMAKE_CFLAGS += $$(CFLAGS)')
+ pro_lines.append('QMAKE_CXXFLAGS += $$(CXXFLAGS)')
+ pro_lines.append('QMAKE_LFLAGS += $$(LDFLAGS)')
+
@@ -51,3 +28,17 @@ index d893ae8..7d13747 100644
if not os.access(out_file, os.F_OK):
error("%s failed to create %s. Make sure your Qt installation is correct." % (test, out_file))
@@ -2751,6 +2751,13 @@ def generate_module_makefile(target_config, verbose, mname, include_paths=None,
# qmake is run otherwise the install and uninstall targets are not
# generated.
shared = '''
+CONFIG += link_pkgconfig
+PKGCONFIG += python3
+
+QMAKE_CFLAGS += $$(CFLAGS)
+QMAKE_CXXFLAGS += $$(CXXFLAGS)
+QMAKE_LFLAGS += $$(LDFLAGS)
+
win32 {
PY_MODULE = %s%s.pyd
PY_MODULE_SRC = $(DESTDIR_TARGET)

+ 33
- 0
patches/PyQt5_gpl/win32/02_qmake-xspec.patch View File

@@ -11,6 +11,15 @@ index 7d13747..a1cd0e9 100644
# On Windows for Qt versions prior to v5.9.0 we need to be explicit
# about the qmake spec.
@@ -1558,7 +1558,7 @@ def generate_makefiles(target_config, verbose, parts, tracing, fatal_warnings, d
inf = open_for_writing('__init__.py')
inf.write(contents)
- if target_config.py_platform == 'win32':
+ if target_config.py_platform == 'win32' or target_config.qmake_spec == 'win32-g++':
# On Windows we try and make sure the Qt DLLs can be found, either any
# bundled copies or an existing installation (using the traditional
# Windows DLL search). We don't raise an exception in case the
@@ -1908,7 +1908,7 @@ def pro_sources(src_dir, other_headers=None, other_sources=None):
def module_file_name(target_config, name):
""" Return the name of a file implementing a module. """
@@ -20,6 +29,30 @@ index 7d13747..a1cd0e9 100644
fs = '{}.lib' if target_config.static else '{}.pyd'
else:
fs = 'lib{}.a' if target_config.static else '{}.so'
@@ -1930,6 +1930,9 @@ def generate_tool_wrapper(target_config, wrapper, module):
exe = quote(target_config.pyuic_interpreter)
+ if target_config.qmake_spec == 'win32-g++':
+ exe += ".exe"
+
wf = open_for_writing(wrapper)
if target_config.py_platform == 'win32':
@@ -2124,11 +2124,8 @@ def run_make(target_config, verbose, exe, makefile_name):
# Guess the name of make and set the default target and platform specific
# name of the executable.
- if target_config.py_platform == 'win32':
- if target_config.qmake_spec == 'win32-g++':
- make = 'mingw32-make'
- else:
- make = 'nmake'
+ if True: # there should be a better way to do this..
+ make = 'make'
if target_config.debug:
makefile_target = 'debug'
@@ -2514,7 +2514,7 @@ def get_sip_flags(target_config):
sip_flags.append('-D')


+ 36
- 0
patches/sip/001-use-env-vars.patch View File

@@ -0,0 +1,36 @@
diff --git a/siputils.py b/siputils.py
index e0efcf5..5da51f8 100644
--- a/siputils.py
+++ b/siputils.py
@@ -1162,9 +1162,9 @@ class Makefile:
if self._deployment_target:
mfile.write("export MACOSX_DEPLOYMENT_TARGET = %s\n" % self._deployment_target)
- mfile.write("CC = %s\n" % self.required_string("CC"))
- mfile.write("CXX = %s\n" % self.required_string("CXX"))
- mfile.write("LINK = %s\n" % self.required_string("LINK"))
+ mfile.write("CC ?= %s\n" % self.required_string("CC"))
+ mfile.write("CXX ?= %s\n" % self.required_string("CXX"))
+ mfile.write("LINK ?= %s\n" % self.required_string("LINK"))
cppflags = []
@@ -1194,13 +1194,13 @@ class Makefile:
libs.extend(self.optional_list("LIBS"))
- mfile.write("CPPFLAGS = %s\n" % ' '.join(cppflags))
+ mfile.write("CPPFLAGS += %s\n" % ' '.join(cppflags))
- mfile.write("CFLAGS = %s\n" % self.optional_string("CFLAGS"))
- mfile.write("CXXFLAGS = %s\n" % self.optional_string("CXXFLAGS"))
- mfile.write("LFLAGS = %s\n" % self.optional_string("LFLAGS"))
+ mfile.write("CFLAGS += %s\n" % self.optional_string("CFLAGS"))
+ mfile.write("CXXFLAGS += %s\n" % self.optional_string("CXXFLAGS"))
+ mfile.write("LFLAGS += %s\n" % self.optional_string("LFLAGS"))
- mfile.write("LIBS = %s\n" % ' '.join(libs))
+ mfile.write("LIBS += %s\n" % ' '.join(libs))
if self._qt:
mfile.write("MOC = %s\n" % _quote(self.required_string("MOC")))

+ 13
- 0
patches/sip/002-module-extension.patch View File

@@ -0,0 +1,13 @@
diff --git a/configure.py b/configure.py
index 6cea574..b7e4ba3 100644
--- a/configure.py
+++ b/configure.py
@@ -464,7 +464,7 @@ def create_makefiles(macros):
all_installs.extend(module_installs)
if not opts.no_module:
- if sys.platform == 'win32':
+ if sys.platform == 'win32' or opts.platform == 'win32-g++':
mod = 'sip.lib' if opts.static else 'sip.pyd'
else:
mod = 'libsip.a' if opts.static else 'sip.so'

+ 1
- 1
patches/sip/win32/0001-mingw-python.patch View File

@@ -85,7 +85,7 @@ diff -uNr sip-4.16.2/siputils.py sip-4.16.2-mingw/siputils.py
# Get these once and make them available to sub-classes.
- if sys.platform == "win32":
+ if False:
+ if sys.platform == "win32" and not "MSYSTEM" in os.environ:
def_copy = "copy"
def_rm = "del"
def_mkdir = "mkdir"


+ 13
- 0
patches/sip/win32/9001-pawpaw-needed-changes.patch View File

@@ -0,0 +1,13 @@
diff --git a/siputils.py b/siputils.py
index 457e417..050b130 100644
--- a/siputils.py
+++ b/siputils.py
@@ -951,7 +951,7 @@ class Makefile:
elif sys.platform == "darwin" and framework:
plib = "-framework " + clib
else:
- plib = "-l" + clib
+ plib = "-Wl,-Bdynamic -l" + clib + " -Wl,-Bstatic"
return plib

Loading…
Cancel
Save