[gtk-osx] Fix building libxml2
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-osx] Fix building libxml2
- Date: Mon, 8 Nov 2021 23:13:09 +0000 (UTC)
commit 99fec075c1417bca5e814e8bd0d19e873143f6b2
Author: John Ralls <jralls ceridwen us>
Date: Mon Nov 8 11:48:19 2021 -0800
Fix building libxml2
This is in two parts. The patch is for
https://gitlab.gnome.org/GNOME/libxml2/-/issues/317. The rest is
because while Apple provides python3 as part of Xcode 12 and 13 for
macOS 11 and 12 respectively it doesn't provide a linkable libpython3.dylib so
we can't build the python bindings for libxml2 or gobject-introspection
with it. To resolve that we force install a pyenv python3 and set up
jhbuild accordingly, and add an LDFLAGS entry to locate its library.
gtk-osx-setup.sh | 68 ++++++++---------------------
jhbuildrc-gtk-osx | 3 ++
modulesets-stable/gtk-osx-bootstrap.modules | 3 +-
modulesets/gtk-osx-bootstrap.modules | 3 +-
patches/libxml2-python-config.patch | 23 ++++++++++
5 files changed, 49 insertions(+), 51 deletions(-)
---
diff --git a/gtk-osx-setup.sh b/gtk-osx-setup.sh
index 1618972f..176c510b 100755
--- a/gtk-osx-setup.sh
+++ b/gtk-osx-setup.sh
@@ -85,55 +85,21 @@ else
popd
fi
-if test ! -x "$DEVPREFIX/bin/pyenv" ; then
+PYENV="$DEVPREFIX/bin/pyenv"
+
+if test ! -x "$PYENV" ; then
ln -s "$PYENV_INSTALL_ROOT/bin/pyenv" "$DEVPREFIX/bin"
fi
-# Setup PIP; note that we're assuming that python is the system python
-# at this point. Having set $PYTHONUSERBASE, pip will be installed in
-# $PYTHONUSERBASE/bin and the requisite modules will go in
-# $PYTHONUSERBASE/lib/python/site-packages.
-
-if test ! -f "`eval echo $PIP_CONFIG_FILE`" ; then
- export PIP_CONFIG_FILE="$PIP_CONFIG_DIR/pip.conf"
- mkdir -p "$PIP_CONFIG_DIR"
-fi
-# What flavor of python is available?
-
-if test "x$PYTHON" = "x"; then
- PYTHON3=`which python3`
- if test "x$PYTHON3" != "x"; then
- PYTHON=$PYTHON3
- PYVER=3
- else
- PYTHON=`which python`
- if test "x$PYTHON" != "x"; then
- PYVER=`python --version 2>&1 | cut -d ' ' -f 2 | cut -d . -f 1`
- else
- echo "No Python interpreter found, quitting."
- exit 1
- fi
- fi
-else
- PYVER=`$PYTHON --version 2>&1 | cut -d ' ' -f 2 | cut -d . -f 1`
-fi
+#Force installation and we hope use of Python with PyEnv. We must
+#avoid using the Apple-provided Python2 because jhbuild doesn't work
+#with python2 any more, and the Apple-provided python3 because it
+#doesn't include a usable libpython for libxml2 to link against.
-PIP="$PYTHON -m pip"
-pip_name=`$PIP --version | cut -d ' ' -f 1`
-if test "x$pip_name" != "xpip"; then
- if test a $PYVER -eq 2; then
- mv=`$PYTHON --version 2>&1 | cut -d ' ' -f 2 | cut -d . -f 3`
- if test $mv -lt 11 ; then
- curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o "$DEVPREFIX/get-pip.py"
- $PYTHON "$DEVPREFIX/get-pip.py" --user
- rm "$DEVPREFIX/get-pip.py"
- else
- $PYTHON -m ensurepip --user
- fi
- else
- $PYTHON -m ensurepip --user
- fi
-fi
+export PYTHON_CONFIGURE_OPTS="--enable-shared"
+export PYENV_VERSION=3.10.0
+$PYENV install $PYENV_VERSION
+PIP="$PYENV_ROOT/shims/pip"
$PIP install --upgrade --user pip
# Install pipenv
@@ -182,13 +148,14 @@ if test -x "$RUSTUP"; then
else
envvar CARGO_HOME "$DEVPREFIX"
envvar RUSTUP_HOME "$DEVPREFIX"
- curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal
+ curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --no-modify-path
fi
if test ! -d "$DEVPREFIX/etc" ; then
mkdir -p "$DEVPREFIX/etc"
fi
+PYENV_MINOR_VERSION=$(echo $PYENV_VERSION | cut -d . -f 1,2)
cat <<EOF > "$DEVPREFIX/etc/Pipfile"
[[source]]
url = "https://pypi.python.org/simple"
@@ -202,7 +169,7 @@ meson = {version=">=0.56.0"}
jhbuild = "$DEVPREFIX/libexec/run_jhbuild.py"
[requires]
-python_version = "3.8"
+python_version = "$PYENV_MINOR_VERSION"
EOF
cat <<EOF > "$DEVPREFIX/etc/pipenv-env"
export PYTHONUSERBASE="$PYTHONUSERBASE"
@@ -220,6 +187,8 @@ export PYTHONPATH="$PYTHONPATH"
export PIPENV_DOTENV_LOCATION="$DEVPREFIX/etc/pipenv-env"
export PIPENV_PIPFILE="$DEVPREFIX/etc/Pipfile"
export PYENV_ROOT="$PYENV_ROOT"
+export PYENV_VERSION="$PYENV_VERSION"
+export PATH="$PYENV_ROOT/shims:$PATH"
export CARGO_HOME="$CARGO_HOME"
export RUSTUP_HOME="$RUSTUP_HOME"
@@ -262,7 +231,9 @@ if test "x`echo $PATH | grep "$DEVPREFIX/bin"`" == x ; then
fi
# pipenv wants enum34 because it's installed with Py2 but that conflicts
# with Py3 so remove it.
-pip_remove enum34
+if test $PYVER -eq 3; then
+ pip_remove enum34
+fi
SDKROOT=`xcrun --show-sdk-path`
@@ -273,7 +244,6 @@ export PATH="$PYENV_ROOT/shims:$DEVPREFIX/bin:$PYENV_INSTALL_ROOT/plugins/python
if test -d "$SDKROOT"; then
export CFLAGS="-isysroot $SDKROOT -I$SDKROOT/usr/include"
fi
-export PYTHON_CONFIGURE_OPTS="--enable-shared"
$PIPENV install
diff --git a/jhbuildrc-gtk-osx b/jhbuildrc-gtk-osx
index d74725c5..aea4b156 100644
--- a/jhbuildrc-gtk-osx
+++ b/jhbuildrc-gtk-osx
@@ -626,6 +626,9 @@ else:
append_autogenargs('libxml2',
'--with-python-install-dir=' + _python_install_path)
environ_append('PYTHONPATH', _python_install_path, ':')
+ python_library_path = os.path.join(os.environ['PYENV_ROOT'], 'versions',
+ os.environ['PYENV_VERSION'], 'lib')
+ environ_append('LDFLAGS', '-L' + python_library_path)
os.environ['PYTHON'] = sys.executable
module_extra_env["pygtk"] = {'PYTHON':os.path.join(prefix, 'bin', 'python2')}
diff --git a/modulesets-stable/gtk-osx-bootstrap.modules b/modulesets-stable/gtk-osx-bootstrap.modules
index 142666a1..81b30eee 100644
--- a/modulesets-stable/gtk-osx-bootstrap.modules
+++ b/modulesets-stable/gtk-osx-bootstrap.modules
@@ -54,11 +54,12 @@
module won't link. In case you're wondering, itstool
needs libxml2's python module. -->
- <autotools id="libxml2" autogen-sh="configure"
+ <autotools id="libxml2" autogen-sh="autoreconf"
autogenargs='--libdir="$JHBUILD_LIBDIR" --with-python'>
<branch version="2.9.12" module="libxml2-2.9.12.tar.gz"
repo="xmlsoft.org"
hash="sha256:c8d6681e38c56f172892c85ddc0852e1fd4b53b4209e7f4ebf17f7e2eae71d92">
+ <patch file="libxml2-python-config.patch" strip="1"/>
</branch>
<after>
<dep package="python2"/>
diff --git a/modulesets/gtk-osx-bootstrap.modules b/modulesets/gtk-osx-bootstrap.modules
index 83ebea71..cdf56f29 100644
--- a/modulesets/gtk-osx-bootstrap.modules
+++ b/modulesets/gtk-osx-bootstrap.modules
@@ -52,11 +52,12 @@
module won't link. In case you're wondering, itstool
needs libxml2's python module. -->
- <autotools id="libxml2" autogen-sh="configure"
+ <autotools id="libxml2" autogen-sh="autoreconf"
autogenargs='--libdir="$JHBUILD_LIBDIR" --with-python'>
<branch version="2.9.12" module="libxml2-2.9.12.tar.gz"
repo="xmlsoft.org"
hash="sha256:c8d6681e38c56f172892c85ddc0852e1fd4b53b4209e7f4ebf17f7e2eae71d92">
+ <patch file="libxml2-python-config.patch" strip="1"/>
</branch>
<after>
<dep package="python2"/>
diff --git a/patches/libxml2-python-config.patch b/patches/libxml2-python-config.patch
new file mode 100644
index 00000000..6844fec0
--- /dev/null
+++ b/patches/libxml2-python-config.patch
@@ -0,0 +1,23 @@
+--- a/configure.ac 2021-05-13 11:44:23.000000000 -0700
++++ b/configure.ac 2021-11-08 11:13:54.000000000 -0800
+@@ -905,7 +905,17 @@
+ fi
+ fi
+ pythondir='$(PYTHON_SITE_PACKAGES)'
+- PYTHON_LIBS=`python$PYTHON_VERSION-config --ldflags`
++ py_ver_major=$(echo $PYTHON_VERSION | cut -d . -f 1)
++ py_ver_minor=$(echo $PYTHON_VERSION | cut -d . -f 2)
++ if test $py_ver_major -eq 3 -a $py_ver_minor -ge 8
++ then
++ PYTHON_LIBS=`python$PYTHON_VERSION-config --ldflags --embed`
++ elif test $py_ver_major -gt 3
++ then
++ PYTHON_LIBS=`python$PYTHON_VERSION-config --ldflags --embed`
++ else
++ PYTHON_LIBS=`python$PYTHON_VERSION-config --ldflags`
++ fi
+ else
+ PYTHON=
+ fi
+
+Diff finished. Mon Nov 8 11:28:35 2021
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]