From: ahesford <ahesford@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] [RFC, WIP] common/build-helper/meson.sh: new build helper, used by meson build style
Date: Wed, 20 Sep 2023 17:16:21 +0200 [thread overview]
Message-ID: <20230920151621.T2_8a-lV2-lnmmPDmjwCyRLaKzNE8lSHP-_o487hxGs@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46117@inbox.vuxu.org>
[-- Attachment #1: Type: text/plain, Size: 2478 bytes --]
There is an updated pull request by ahesford against master on the void-packages repository
https://github.com/ahesford/void-packages meson
https://github.com/void-linux/void-packages/pull/46117
[RFC, WIP] common/build-helper/meson.sh: new build helper, used by meson build style
The `python3-scipy` package now builds with `python3-meson-python`, with some more coming down the pike. The Python build process is necessary to include Python package metadata. For SciPy, this is accomplished by using the `meson` build style to configure a build directory, then overriding `do_build` and `do_install` to build things the PEP517 way (using the pre-configured build directory).
It might be helpful to define a `meson` build helper that can write out the standard cross file for builds, allowing packages like SciPy to use the `python3-pep517` build style with the `meson` helper. There are some issues to be worked out:
1. It seems like the `xbps_meson.cross` is written before `CFLAGS`, *et al.* are properly defined, so this cross file is actually broken. (This is the process by which the `qmake` helper writes its configurations, and they reference `CFLAGS` and others; is the `qmake` helper writing broken configs?)
2. The meson configuration (which would need to happen even with `python3-pep517` plus a `meson` helper) still includes a lot of magic that would have to be brought over to templates. This isn't really easier than the current practice of overriding the one-line `do_build` and `do_install`.
A possible solution would be to define a special-purpose function in the helper, called `vmesoncross` or somesuch, that will only write the configured when called---from a build function where these are properly defined (*e.g.*, `pre_configure`, `do_configure`). We could also define a special `do_configure`-like function in the helper that can be used by the `meson` style to actually do the configuration. This might be a bit ugly, but avoids repetition or violating the typical practice that the actual build functions are only defined in templates or build styles.
A third option is just defining a new `python3-meson` build style that mashes the meson `do_configure` bits from the `meson` style with the `do_build` and `do_install` bits from the `python3-pep517` style.
All of these options are sub-optimal, but I'm not sure which one is least offsensive.
A patch file from https://github.com/void-linux/void-packages/pull/46117.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-meson-46117.patch --]
[-- Type: text/x-diff, Size: 11777 bytes --]
From 5dbb797c644dac784e31d29aa1590d2d9a5b20d8 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 18 Sep 2023 15:40:49 -0400
Subject: [PATCH 1/3] common/build-helper/meson.sh: new build helper, used by
meson build style
---
common/build-helper/meson.sh | 82 ++++++++++++++++++++++++
common/build-style/meson.sh | 85 +------------------------
common/environment/build-style/meson.sh | 1 +
3 files changed, 84 insertions(+), 84 deletions(-)
create mode 100644 common/build-helper/meson.sh
diff --git a/common/build-helper/meson.sh b/common/build-helper/meson.sh
new file mode 100644
index 0000000000000..1933306c18a4b
--- /dev/null
+++ b/common/build-helper/meson.sh
@@ -0,0 +1,82 @@
+# This bulid-helper writes a Meson cross-file, allowing other build styles
+# to properly drive cross-builds in Meson when appropriate
+
+if [ "$CROSS_BUILD" ]; then
+ mkdir -p "${XBPS_WRAPPERDIR}/meson"
+
+ _MESON_TARGET_ENDIAN=little
+ # drop the -musl suffix to the target cpu, meson doesn't recognize it
+ _MESON_TARGET_CPU=${XBPS_TARGET_MACHINE/-musl/}
+ case "$XBPS_TARGET_MACHINE" in
+ mips|mips-musl|mipshf-musl)
+ _MESON_TARGET_ENDIAN=big
+ _MESON_CPU_FAMILY=mips
+ ;;
+ armv*)
+ _MESON_CPU_FAMILY=arm
+ ;;
+ i686*)
+ _MESON_CPU_FAMILY=x86
+ ;;
+ ppc64le*)
+ _MESON_CPU_FAMILY=ppc64
+ ;;
+ ppc64*)
+ _MESON_TARGET_ENDIAN=big
+ _MESON_CPU_FAMILY=ppc64
+ ;;
+ ppcle*)
+ _MESON_CPU_FAMILY=ppc
+ ;;
+ ppc*)
+ _MESON_TARGET_ENDIAN=big
+ _MESON_CPU_FAMILY=ppc
+ ;;
+ *)
+ # if we reached here that means that the cpu and cpu_family
+ # are the same like 'x86_64' and 'aarch64'
+ _MESON_CPU_FAMILY=${_MESON_TARGET_CPU}
+ ;;
+ esac
+
+ # Tell meson to run binaries with qemu if desired
+ _MESON_EXE_WRAPPER=""
+ if [[ "${build_helper}" = *qemu* ]]; then
+ _MESON_EXE_WRAPPER="exe_wrapper = '/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static'"
+ fi
+
+ # Record cross-compiling information in cross file.
+ #
+ # CFLAGS, CXXFLAGS and LDFLAGS are not yet available and
+ # will be taken from the environment at configure time.
+ cat > "${XBPS_WRAPPERDIR}/meson/xbps_meson.cross" <<-EOF
+ [binaries]
+ ${_MESON_EXE_WRAPPER:-# exe_wrapper is not set}
+ c = '${CC}'
+ cpp = '${CXX}'
+ ar = '${XBPS_CROSS_TRIPLET}-gcc-ar'
+ nm = '${NM}'
+ ld = '${LD}'
+ strip = '${STRIP}'
+ readelf = '${READELF}'
+ objcopy = '${OBJCOPY}'
+ pkgconfig = '${PKG_CONFIG}'
+ rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
+ g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
+ g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
+ g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'
+ llvm-config = '/usr/bin/llvm-config'
+ cups-config = '${XBPS_CROSS_BASE}/usr/bin/cups-config'
+
+ [properties]
+ needs_exe_wrapper = true
+
+ [host_machine]
+ system = 'linux'
+ cpu_family = '${_MESON_CPU_FAMILY}'
+ cpu = '${_MESON_TARGET_CPU}'
+ endian = '${_MESON_TARGET_ENDIAN}'
+ EOF
+
+ unset _MESON_CPU_FAMILY _MESON_TARGET_CPU _MESON_TARGET_ENDIAN _MESON_EXE_WRAPPER
+fi
diff --git a/common/build-style/meson.sh b/common/build-style/meson.sh
index e983c5f42c2f7..5ea2eeda40097 100644
--- a/common/build-style/meson.sh
+++ b/common/build-style/meson.sh
@@ -1,94 +1,11 @@
#
# This helper is for templates using meson.
#
-do_patch() {
- : ${meson_crossfile:=xbps_meson.cross}
-
- if [ "$CROSS_BUILD" ]; then
- _MESON_TARGET_ENDIAN=little
- # drop the -musl suffix to the target cpu, meson doesn't recognize it
- _MESON_TARGET_CPU=${XBPS_TARGET_MACHINE/-musl/}
- case "$XBPS_TARGET_MACHINE" in
- mips|mips-musl|mipshf-musl)
- _MESON_TARGET_ENDIAN=big
- _MESON_CPU_FAMILY=mips
- ;;
- armv*)
- _MESON_CPU_FAMILY=arm
- ;;
- i686*)
- _MESON_CPU_FAMILY=x86
- ;;
- ppc64le*)
- _MESON_CPU_FAMILY=ppc64
- ;;
- ppc64*)
- _MESON_TARGET_ENDIAN=big
- _MESON_CPU_FAMILY=ppc64
- ;;
- ppcle*)
- _MESON_CPU_FAMILY=ppc
- ;;
- ppc*)
- _MESON_TARGET_ENDIAN=big
- _MESON_CPU_FAMILY=ppc
- ;;
- *)
- # if we reached here that means that the cpu and cpu_family
- # are the same like 'x86_64' and 'aarch64'
- _MESON_CPU_FAMILY=${_MESON_TARGET_CPU}
- ;;
- esac
-
- # Record cross-compiling information in cross file.
- # CFLAGS and LDFLAGS must be set as c_args and c_link_args.
- cat > ${meson_crossfile} <<EOF
-[binaries]
-c = '${CC}'
-cpp = '${CXX}'
-ar = '${XBPS_CROSS_TRIPLET}-gcc-ar'
-nm = '${NM}'
-ld = '${LD}'
-strip = '${STRIP}'
-readelf = '${READELF}'
-objcopy = '${OBJCOPY}'
-pkgconfig = '${PKG_CONFIG}'
-rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
-g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
-g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
-g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'
-llvm-config = '/usr/bin/llvm-config'
-cups-config = '${XBPS_CROSS_BASE}/usr/bin/cups-config'
-
-[properties]
-needs_exe_wrapper = true
-
-[built-in options]
-c_args = ['$(echo ${CFLAGS} | sed -r "s/\s+/','/g")']
-c_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
-
-cpp_args = ['$(echo ${CXXFLAGS} | sed -r "s/\s+/','/g")']
-cpp_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
-
-[host_machine]
-system = 'linux'
-cpu_family = '${_MESON_CPU_FAMILY}'
-cpu = '${_MESON_TARGET_CPU}'
-endian = '${_MESON_TARGET_ENDIAN}'
-EOF
- if [[ $build_helper = *"qemu"* ]]; then
- sed -e "/\[binaries\]/ a exe_wrapper = '/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static'" \
- -i ${meson_crossfile}
- fi
-
- unset _MESON_CPU_FAMILY _MESON_TARGET_CPU _MESON_TARGET_ENDIAN
- fi
-}
do_configure() {
: ${meson_cmd:=meson}
: ${meson_builddir:=build}
- : ${meson_crossfile:=xbps_meson.cross}
+ : ${meson_crossfile:="${XBPS_WRAPPERDIR}/meson/xbps_meson.cross"}
if [ "$CROSS_BUILD" ]; then
configure_args+=" --cross-file=${meson_crossfile}"
diff --git a/common/environment/build-style/meson.sh b/common/environment/build-style/meson.sh
index d5a3c4141f7d9..dbfe93700f691 100644
--- a/common/environment/build-style/meson.sh
+++ b/common/environment/build-style/meson.sh
@@ -1 +1,2 @@
hostmakedepends+=" meson"
+build_helper+=" meson"
From a640b681dd99188880ee6704c35f9fa9b851f6a3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 20 Sep 2023 10:45:43 -0400
Subject: [PATCH 2/3] python3-scipy: use new meson helper
---
srcpkgs/python3-scipy/template | 47 ++++++++++++++++------------------
1 file changed, 22 insertions(+), 25 deletions(-)
diff --git a/srcpkgs/python3-scipy/template b/srcpkgs/python3-scipy/template
index ba0dd761cdcf5..e99919babf3bf 100644
--- a/srcpkgs/python3-scipy/template
+++ b/srcpkgs/python3-scipy/template
@@ -2,9 +2,10 @@
pkgname=python3-scipy
version=1.11.2
revision=1
-build_style=meson
-build_helper="python3"
-configure_args="$(vopt_if openblas "" "-Dblas=blas -Dlapack=lapack")"
+build_style=python3-pep517
+build_helper="meson"
+make_build_args="--no-isolation --wheel
+ $(vopt_if openblas "" "-Csetup-args=-Dblas=blas -Csetup-args=-Dlapack=lapack")"
hostmakedepends="python3-build python3-installer python3-meson-python
python3-wheel python3-Cython python3-pybind11 pythran python3-numpy
gcc-fortran pkg-config"
@@ -22,8 +23,12 @@ make_check="no" # Tests need an installed copy to run and meson makes this tough
build_options="openblas"
if [ "$CROSS_BUILD" ]; then
+ make_build_args+="
+ -Csetup-args=--cross-file=${XBPS_WRAPPERDIR}/meson/xbps_meson.cross
+ -Csetup-args=--cross-file=${XBPS_WRAPPERDIR}/meson/python.cross
+ "
+
_pybind11_dir="${py3_sitelib}/pybind11"
- configure_args+=" --cross-file=python.cross"
export PKG_CONFIG_PATH="${XBPS_CROSS_BASE}/${_pybind11_dir}/share/pkgconfig"
# pybind11 uses a path relative to the pkgconfig file to set $prefix,
# which causes the wrapper to double-include $XBPS_CROSS_BASE; override
@@ -46,34 +51,26 @@ if [ "$build_option_openblas" ]; then
esac
fi
-pre_patch() {
- if [ "${CROSS_BUILD}" ]; then
- # Meson can't tolerate $CC with arguments as set by the build helper
- CC="${XBPS_CROSS_TRIPLET}-gcc"
- # CXX needs to know where to find Python headers
- CXXFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc}"
- fi
-}
-
post_patch() {
if [ "$CROSS_BUILD" ]; then
local _xpy="${XBPS_CROSS_BASE}/${py3_sitelib}"
- cat > python.cross <<-EOF
- [properties]
- numpy-include-dir = '${_xpy}/numpy/core/include'
- pythran-include-dir = '${_xpy}/pythran'
- EOF
+ cat > "${XBPS_WRAPPERDIR}/meson/python.cross" <<-EOF
+ [properties]
+ numpy-include-dir = '${_xpy}/numpy/core/include'
+ pythran-include-dir = '${_xpy}/pythran'
+ EOF
fi
}
-do_build() {
- # Use the build directory already configured by xbps-src for meson
- python3 -m build --no-isolation --wheel \
- -Cbuilddir="./build" -Ccompile-args="${makejobs}" .
+pre_build() {
+ if [ "$CROSS_BUILD" ]; then
+ # Meson can't tolerate $CC with arguments as set by the build helper
+ CC="${XBPS_CROSS_TRIPLET}-gcc"
+ # CXX needs to know where to find Python headers
+ CXXFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc}"
+ fi
}
-do_install() {
- python3 -m installer --destdir "${DESTDIR}" \
- --no-compile-bytecode dist/*.whl
+post_install() {
vlicense LICENSE.txt
}
From bedace4ff187239e850e30fbb8169a8c13655033 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 20 Sep 2023 11:13:02 -0400
Subject: [PATCH 3/3] python3-scikit-image: use new meson helper
---
srcpkgs/python3-scikit-image/template | 34 +++++++++++----------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/srcpkgs/python3-scikit-image/template b/srcpkgs/python3-scikit-image/template
index e800ed4f00f6c..b19743e50f37d 100644
--- a/srcpkgs/python3-scikit-image/template
+++ b/srcpkgs/python3-scikit-image/template
@@ -2,8 +2,8 @@
pkgname=python3-scikit-image
version=0.21.0
revision=1
-build_style=meson
-build_helper="python3"
+build_style=python3-pep517
+build_helper="meson"
hostmakedepends="python3-build python3-installer python3-meson-python
python3-wheel python3-setuptools python3-packaging python3-Cython pythran
python3-lazy_loader python3-numpy pkg-config"
@@ -21,22 +21,15 @@ checksum=53a82a9dbd3ed608d2ad3876269a271a7e922b12e228388eac996b508aadd652
make_check=no
if [ "${CROSS_BUILD}" ]; then
- configure_args="--cross-file=python.cross"
+ make_build_args+=" --no-isolation --wheel
+ -Csetup-args=--cross-file=${XBPS_WRAPPERDIR}/meson/xbps_meson.cross
+ -Csetup-args=--cross-file=${XBPS_WRAPPERDIR}/meson/python.cross"
fi
-pre_patch() {
- if [ "${CROSS_BUILD}" ]; then
- # Meson can't tolerate $CC with arguments as set by build helper
- CC="${XBPS_CROSS_TRIPLET}-gcc"
- # CXX needs to know where to find Python headers
- CXXFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc}"
- fi
-}
-
post_patch() {
if [ "${CROSS_BUILD}" ]; then
local _xpy="${XBPS_CROSS_BASE}/${py3_sitelib}"
- cat > python.cross <<-EOF
+ cat > "${XBPS_WRAPPERDIR}/meson/python.cross" <<-EOF
[properties]
numpy-include-dir = '${_xpy}/numpy/core/include'
pythran-include-dir = '${_xpy}/pythran'
@@ -44,14 +37,15 @@ post_patch() {
fi
}
-do_build() {
- # Use the build directory already configured by xbps-src for meson
- python3 -m build --no-isolation --wheel \
- -Cbuilddir="./build" -Ccompile-args="${makejobs}" .
+pre_build() {
+ if [ "${CROSS_BUILD}" ]; then
+ # Meson can't tolerate $CC with arguments as set by build helper
+ CC="${XBPS_CROSS_TRIPLET}-gcc"
+ # CXX needs to know where to find Python headers
+ CXXFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc}"
+ fi
}
-do_install() {
- python3 -m installer --destdir "${DESTDIR}" \
- --no-compile-bytecode dist/*.whl
+post_install() {
vlicense LICENSE.txt
}
next prev parent reply other threads:[~2023-09-20 15:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 19:53 [PR PATCH] " ahesford
2023-09-18 20:02 ` tornaria
2023-09-20 3:25 ` tornaria
2023-09-20 14:46 ` [PR PATCH] [Updated] " ahesford
2023-09-20 14:48 ` ahesford
2023-09-20 14:50 ` ahesford
2023-09-20 14:54 ` ahesford
2023-09-20 15:13 ` [PR PATCH] [Updated] " ahesford
2023-09-20 15:16 ` ahesford [this message]
2023-09-20 22:16 ` tornaria
2023-09-21 0:36 ` [RFC] " ahesford
2023-09-21 0:50 ` ahesford
2023-09-21 0:51 ` ahesford
2023-09-21 19:28 ` [PR PATCH] [Updated] " ahesford
2023-09-22 14:17 ` [PR PATCH] [Merged]: " ahesford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230920151621.T2_8a-lV2-lnmmPDmjwCyRLaKzNE8lSHP-_o487hxGs@z \
--to=ahesford@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).