Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0
@ 2023-06-02 22:42 ahesford
  2023-06-02 23:53 ` eli-schwartz
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ahesford @ 2023-06-02 22:42 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1214 bytes --]

There is a new pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages scikit-image
https://github.com/void-linux/void-packages/pull/44233

[WIP] python3-scikit-image: update to 0.21.0
@eli-schwartz I wonder if you can offer some insight. To get Meson building scikit-image, I patched the `meson.build` to allow manual specification of include directories for NumPy and Pythran rather than forcing the build system to execute the Python interpreter. This works OK and was stolen from SciPy. However:
- Cross-building on 32-bit hosts from 64-but builders fails because `LONG_BIT` is the wrong size in Python's `python3.11/pyport.h`. Clearly some headers are mixing. This gets pulled in by Pythran's generated outputs in a couple of places.
- I can't seem to get `-I/usr/include/python3.11` out of the compiler flags, when it should point to the cross-build tree.
- I don't know that fixing the include path is sufficient to resolve the first problem.

Although I'm prepared to leave 32-but ARM behind with this update, I'd prefer to get it working correctly. 

A patch file from https://github.com/void-linux/void-packages/pull/44233.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-scikit-image-44233.patch --]
[-- Type: text/x-diff, Size: 10311 bytes --]

From 45cb7fffc49471f16d110ad5a6d93b9642d479b3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 4 Apr 2023 10:06:35 -0400
Subject: [PATCH 1/4] New package: python3-lazy_loader-0.2

---
 srcpkgs/python3-lazy_loader/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/python3-lazy_loader/template

diff --git a/srcpkgs/python3-lazy_loader/template b/srcpkgs/python3-lazy_loader/template
new file mode 100644
index 000000000000..492c98124834
--- /dev/null
+++ b/srcpkgs/python3-lazy_loader/template
@@ -0,0 +1,19 @@
+# Template file for 'python3-lazy_loader'
+pkgname=python3-lazy_loader
+version=0.2
+revision=1
+build_style=python3-pep517
+hostmakedepends="python3-flit_core"
+depends="python3"
+checkdepends="python3-pytest-xdist"
+short_desc="Populate Python namespace without incurring immediate import costs"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/scientific-python/lazy_loader"
+changelog="https://raw.githubusercontent.com/scientific-python/lazy_loader/main/CHANGELOG.md"
+distfiles="${PYPI_SITE}/l/lazy_loader/lazy_loader-${version}.tar.gz"
+checksum=0edc7a5175c400acb108f283749951fefdadedeb00adcec6e88b974a9254f18a
+
+post_install() {
+	vlicense LICENSE.md
+}

From 9d0c13826a2bbed0aec434ed01d59fb5d66cec79 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 2 Jun 2023 12:06:36 -0400
Subject: [PATCH 2/4] New package: python3-pyproject-metadata-0.7.1

---
 srcpkgs/python3-pyproject-metadata/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/python3-pyproject-metadata/template

diff --git a/srcpkgs/python3-pyproject-metadata/template b/srcpkgs/python3-pyproject-metadata/template
new file mode 100644
index 000000000000..fcf5c5d22593
--- /dev/null
+++ b/srcpkgs/python3-pyproject-metadata/template
@@ -0,0 +1,19 @@
+# Template file for 'python3-pyproject-metadata'
+pkgname=python3-pyproject-metadata
+version=0.7.1
+revision=1
+build_style=python3-pep517
+hostmakedepends="python3-flit_core python3-wheel"
+depends="python3-packaging"
+short_desc="PEP 621 metadata parsing"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://pep621.readthedocs.io/"
+changelog="https://raw.githubusercontent.com/FFY00/python-pyproject-metadata/main/CHANGELOG.rst"
+distfiles="${PYPI_SITE}/p/pyproject-metadata/pyproject-metadata-${version}.tar.gz"
+checksum=0a94f18b108b9b21f3a26a3d541f056c34edcb17dc872a144a15618fed7aef67
+make_check=no # tarball includes no tests
+
+post_install() {
+	vlicense LICENSE
+}

From 3701519b2c5fb3cffbfbc50d9756cbaa7d3ebb34 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 2 Jun 2023 12:48:57 -0400
Subject: [PATCH 3/4] New package: python3-meson-python-0.13.1

---
 srcpkgs/python3-meson-python/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/python3-meson-python/template

diff --git a/srcpkgs/python3-meson-python/template b/srcpkgs/python3-meson-python/template
new file mode 100644
index 000000000000..50dc5be1c509
--- /dev/null
+++ b/srcpkgs/python3-meson-python/template
@@ -0,0 +1,20 @@
+# Template file for 'python3-meson-python'
+pkgname=python3-meson-python
+version=0.13.1
+revision=1
+build_style=python3-pep517
+hostmakedepends="meson python3-pyproject-metadata"
+depends="meson python3-pyproject-metadata patchelf"
+short_desc="Meson PEP 517 Python build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://meson-python.readthedocs.io/"
+changelog="https://raw.githubusercontent.com/mesonbuild/meson-python/main/CHANGELOG.rst"
+distfiles="${PYPI_SITE}/m/meson_python/meson_python-${version}.tar.gz"
+checksum=63b3170001425c42fa4cfedadb9051cbd28925ff8eed7c40d36ba0099e3c7618
+# tests require custom-built executables, need reconciliation with xbps-src env
+make_check=no 
+
+post_install() {
+	vlicense LICENSE
+}

From 5988ad795ca8fa557ec5ad7bf3d4eb20180707f5 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 4 Apr 2023 10:09:26 -0400
Subject: [PATCH 4/4] python3-scikit-image: update to 0.21.0.

---
 .../patches/numpy-version.patch               | 14 +++++
 .../patches/python-includes.patch             | 54 ++++++++++++++++
 srcpkgs/python3-scikit-image/template         | 63 ++++++++++++++-----
 3 files changed, 116 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/python3-scikit-image/patches/numpy-version.patch
 create mode 100644 srcpkgs/python3-scikit-image/patches/python-includes.patch

diff --git a/srcpkgs/python3-scikit-image/patches/numpy-version.patch b/srcpkgs/python3-scikit-image/patches/numpy-version.patch
new file mode 100644
index 000000000000..9d3a96588edd
--- /dev/null
+++ b/srcpkgs/python3-scikit-image/patches/numpy-version.patch
@@ -0,0 +1,14 @@
+There doesn't seem to be a valid reason for this restriction, and it doesn't
+impede building anyway.
+
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -145,7 +145,7 @@
+     "numpy==1.21.1; python_version=='3.8' and platform_python_implementation != 'PyPy'",
+     "numpy==1.21.1; python_version=='3.9' and platform_python_implementation != 'PyPy'",
+     "numpy==1.21.6; python_version=='3.10' and platform_system != 'Windows' and platform_python_implementation != 'PyPy'",
+-    "numpy==1.23.3; python_version=='3.11' and platform_python_implementation != 'PyPy'",
++    "numpy>=1.23.3; python_version=='3.11' and platform_python_implementation != 'PyPy'",
+     "numpy; python_version>='3.12'",
+     "numpy; python_version>='3.8' and platform_python_implementation=='PyPy'",
+ ]
diff --git a/srcpkgs/python3-scikit-image/patches/python-includes.patch b/srcpkgs/python3-scikit-image/patches/python-includes.patch
new file mode 100644
index 000000000000..a094c4e571cb
--- /dev/null
+++ b/srcpkgs/python3-scikit-image/patches/python-includes.patch
@@ -0,0 +1,54 @@
+Running build Python to determine include paths fails for cross-builds, so copy
+the SciPy approach and allow a cross file to define explicit paths.
+
+--- a/skimage/meson.build
++++ b/skimage/meson.build
+@@ -30,13 +30,16 @@
+ endif
+ 
+ # NumPy include directory - needed in all submodules
+-incdir_numpy = run_command(py3,
+-  [
+-    '-c',
+-    'import os; os.chdir(".."); import numpy; print(numpy.get_include())'
+-  ],
+-  check: true
+-).stdout().strip()
++incdir_numpy = meson.get_external_property('numpy_include_dir', 'not-given')
++if incdir_numpy == 'not-given'
++  incdir_numpy = run_command(py3,
++    [
++      '-c',
++      'import os; os.chdir(".."); import numpy; print(numpy.get_include())'
++    ],
++    check: true
++  ).stdout().strip()
++endif
+ 
+ inc_np = include_directories(incdir_numpy)
+ 
+@@ -51,13 +54,17 @@
+   check: true
+ ).stdout().strip() == '1'
+ 
+-incdir_pythran = run_command(py3,
+-  [
+-    '-c',
+-    'import os; os.chdir(".."); import pythran; print(os.path.dirname(pythran.__file__));'
+-  ],
+-  check: true
+-).stdout().strip()
++incdir_pythran = meson.get_external_property('pythran_include_dir', 'not-given')
++if incdir_pythran == 'not-given'
++  incdir_pythran = run_command(py3,
++    [
++      '-c',
++      'import os; os.chdir(".."); import pythran; print(os.path.dirname(pythran.__file__));'
++    ],
++    check: true
++  ).stdout().strip()
++endif
++
+ inc_pythran = include_directories(incdir_pythran)
+ 
+ cpp_args_pythran = [
diff --git a/srcpkgs/python3-scikit-image/template b/srcpkgs/python3-scikit-image/template
index c3b403fdef61..e7b7d35fbcf2 100644
--- a/srcpkgs/python3-scikit-image/template
+++ b/srcpkgs/python3-scikit-image/template
@@ -1,28 +1,61 @@
 # Template file for 'python3-scikit-image'
 pkgname=python3-scikit-image
-version=0.19.3
-revision=2
-_pkgname="${pkgname#python3-}"
-build_style=python3-module
-build_helper="numpy"
-hostmakedepends="python3-Cython python3-wheel python3-numpy
- python3-packaging python3-setuptools pythran"
-makedepends="python3-devel"
-depends="python3-scipy python3-numpy python3-imageio python3-matplotlib
- python3-networkx python3-tifffile python3-pywt python3-packaging"
+version=0.21.0
+revision=1
+build_style=meson
+build_helper="python3"
+hostmakedepends="python3-build python3-installer python3-meson-python
+ python3-wheel python3-setuptools python3-packaging python3-Cython pythran
+ python3-lazy_loader python3-numpy"
+makedepends="python3-devel python3-numpy pythran"
+depends="python3-numpy python3-scipy python3-networkx python3-Pillow
+ python3-imageio python3-tifffile python3-pywt python3-packaging
+ python3-lazy_loader"
 short_desc="Image processing in Python"
 maintainer="Andrew J. Hesford <ajh@sideband.org>"
 license="BSD-3-Clause, MIT"
 homepage="https://scikit-image.org/"
-distfiles="https://github.com/${_pkgname}/${_pkgname}/archive/v${version}.tar.gz"
-checksum=4eb877c98d1395769daef5bc2ba8a7efd3f736c87086aecb3775a9174593398b
+distfiles="https://github.com/scikit-image/scikit-image/archive/v${version}.tar.gz"
+checksum=53a82a9dbd3ed608d2ad3876269a271a7e922b12e228388eac996b508aadd652
 # Tests require data files and unpackaged dependencies
 make_check=no
 
-pre_build() {
-	make_build_args+=" ${makejobs}"
+if [ ! "$XBPS_WORDSIZE" = "$XBPS_TARGET_WORDSIZE" ]; then
+	broken="pythran components build only if word size matches"
+fi
+
+if [ "${CROSS_BUILD}" ]; then
+	configure_args="--cross-file=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
+		[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}" .
 }
 
-post_install() {
+do_install() {
+	python3 -m installer --destdir "${DESTDIR}" \
+		--no-compile-bytecode dist/*.whl
 	vlicense LICENSE.txt
 }

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [WIP] python3-scikit-image: update to 0.21.0
  2023-06-02 22:42 [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0 ahesford
@ 2023-06-02 23:53 ` eli-schwartz
  2023-06-03  2:58 ` ahesford
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: eli-schwartz @ 2023-06-02 23:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 321 bytes --]

New comment by eli-schwartz on void-packages repository

https://github.com/void-linux/void-packages/pull/44233#issuecomment-1574444688

Comment:
I don't have a lot of time today to look at this, but can you remind me if Void's setup is overriding the cross python with a python patched to do the sysconfigdata override?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [WIP] python3-scikit-image: update to 0.21.0
  2023-06-02 22:42 [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0 ahesford
  2023-06-02 23:53 ` eli-schwartz
@ 2023-06-03  2:58 ` ahesford
  2023-06-03  2:59 ` ahesford
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ahesford @ 2023-06-03  2:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 542 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/44233#issuecomment-1574591330

Comment:
Yes, although we don't specifically tell Meson anything about python. The build system sets, in the environment,

```sh
PYTHONPATH=${XBPS_CROSS_BASE}/${py3_lib}
PYTHON_CONFIG=${XBPS_CROSS_BASE}/usr/bin/python3-config
```

in the environment and `$_PYTHON_SYSCONFIGDATA_NAME` to the appropriate name for the cross host. Thus, running the build python *should* return parameters for the target.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [WIP] python3-scikit-image: update to 0.21.0
  2023-06-02 22:42 [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0 ahesford
  2023-06-02 23:53 ` eli-schwartz
  2023-06-03  2:58 ` ahesford
@ 2023-06-03  2:59 ` ahesford
  2023-06-06 14:06 ` [PR PATCH] [Updated] " ahesford
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ahesford @ 2023-06-03  2:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 523 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/44233#issuecomment-1574591330

Comment:
Yes, although we don't specifically tell Meson anything about python. The build system sets, in the environment,

```sh
PYTHONPATH=${XBPS_CROSS_BASE}/${py3_lib}
PYTHON_CONFIG=${XBPS_CROSS_BASE}/usr/bin/python3-config
```

and `$_PYTHON_SYSCONFIGDATA_NAME` to the appropriate name for the cross host. Thus, running the build python *should* return parameters for the target.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] python3-scikit-image: update to 0.21.0
  2023-06-02 22:42 [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0 ahesford
                   ` (2 preceding siblings ...)
  2023-06-03  2:59 ` ahesford
@ 2023-06-06 14:06 ` ahesford
  2023-06-06 14:23 ` ahesford
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ahesford @ 2023-06-06 14:06 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1219 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages scikit-image
https://github.com/void-linux/void-packages/pull/44233

[WIP] python3-scikit-image: update to 0.21.0
@eli-schwartz I wonder if you can offer some insight. To get Meson building scikit-image, I patched the `meson.build` to allow manual specification of include directories for NumPy and Pythran rather than forcing the build system to execute the Python interpreter. This works OK and was stolen from SciPy. However:
- Cross-building on 32-bit hosts from 64-but builders fails because `LONG_BIT` is the wrong size in Python's `python3.11/pyport.h`. Clearly some headers are mixing. This gets pulled in by Pythran's generated outputs in a couple of places.
- I can't seem to get `-I/usr/include/python3.11` out of the compiler flags, when it should point to the cross-build tree.
- I don't know that fixing the include path is sufficient to resolve the first problem.

Although I'm prepared to leave 32-but ARM behind with this update, I'd prefer to get it working correctly. 

A patch file from https://github.com/void-linux/void-packages/pull/44233.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-scikit-image-44233.patch --]
[-- Type: text/x-diff, Size: 10311 bytes --]

From e1d890804febe233e28ed0ac99a9d386afa33a05 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 4 Apr 2023 10:06:35 -0400
Subject: [PATCH 1/4] New package: python3-lazy_loader-0.2

---
 srcpkgs/python3-lazy_loader/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/python3-lazy_loader/template

diff --git a/srcpkgs/python3-lazy_loader/template b/srcpkgs/python3-lazy_loader/template
new file mode 100644
index 000000000000..492c98124834
--- /dev/null
+++ b/srcpkgs/python3-lazy_loader/template
@@ -0,0 +1,19 @@
+# Template file for 'python3-lazy_loader'
+pkgname=python3-lazy_loader
+version=0.2
+revision=1
+build_style=python3-pep517
+hostmakedepends="python3-flit_core"
+depends="python3"
+checkdepends="python3-pytest-xdist"
+short_desc="Populate Python namespace without incurring immediate import costs"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/scientific-python/lazy_loader"
+changelog="https://raw.githubusercontent.com/scientific-python/lazy_loader/main/CHANGELOG.md"
+distfiles="${PYPI_SITE}/l/lazy_loader/lazy_loader-${version}.tar.gz"
+checksum=0edc7a5175c400acb108f283749951fefdadedeb00adcec6e88b974a9254f18a
+
+post_install() {
+	vlicense LICENSE.md
+}

From 561cb895ead85274dce783b9ce2a1f680ba63e86 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 2 Jun 2023 12:06:36 -0400
Subject: [PATCH 2/4] New package: python3-pyproject-metadata-0.7.1

---
 srcpkgs/python3-pyproject-metadata/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/python3-pyproject-metadata/template

diff --git a/srcpkgs/python3-pyproject-metadata/template b/srcpkgs/python3-pyproject-metadata/template
new file mode 100644
index 000000000000..fcf5c5d22593
--- /dev/null
+++ b/srcpkgs/python3-pyproject-metadata/template
@@ -0,0 +1,19 @@
+# Template file for 'python3-pyproject-metadata'
+pkgname=python3-pyproject-metadata
+version=0.7.1
+revision=1
+build_style=python3-pep517
+hostmakedepends="python3-flit_core python3-wheel"
+depends="python3-packaging"
+short_desc="PEP 621 metadata parsing"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://pep621.readthedocs.io/"
+changelog="https://raw.githubusercontent.com/FFY00/python-pyproject-metadata/main/CHANGELOG.rst"
+distfiles="${PYPI_SITE}/p/pyproject-metadata/pyproject-metadata-${version}.tar.gz"
+checksum=0a94f18b108b9b21f3a26a3d541f056c34edcb17dc872a144a15618fed7aef67
+make_check=no # tarball includes no tests
+
+post_install() {
+	vlicense LICENSE
+}

From ecac9daf08c0eb9d77f285c9225081106c088754 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 2 Jun 2023 12:48:57 -0400
Subject: [PATCH 3/4] New package: python3-meson-python-0.13.1

---
 srcpkgs/python3-meson-python/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/python3-meson-python/template

diff --git a/srcpkgs/python3-meson-python/template b/srcpkgs/python3-meson-python/template
new file mode 100644
index 000000000000..50dc5be1c509
--- /dev/null
+++ b/srcpkgs/python3-meson-python/template
@@ -0,0 +1,20 @@
+# Template file for 'python3-meson-python'
+pkgname=python3-meson-python
+version=0.13.1
+revision=1
+build_style=python3-pep517
+hostmakedepends="meson python3-pyproject-metadata"
+depends="meson python3-pyproject-metadata patchelf"
+short_desc="Meson PEP 517 Python build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://meson-python.readthedocs.io/"
+changelog="https://raw.githubusercontent.com/mesonbuild/meson-python/main/CHANGELOG.rst"
+distfiles="${PYPI_SITE}/m/meson_python/meson_python-${version}.tar.gz"
+checksum=63b3170001425c42fa4cfedadb9051cbd28925ff8eed7c40d36ba0099e3c7618
+# tests require custom-built executables, need reconciliation with xbps-src env
+make_check=no 
+
+post_install() {
+	vlicense LICENSE
+}

From 8fda9c7770617c1c6342b1387689285e8121c02b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 4 Apr 2023 10:09:26 -0400
Subject: [PATCH 4/4] python3-scikit-image: update to 0.21.0.

---
 .../patches/numpy-version.patch               | 14 +++++
 .../patches/python-includes.patch             | 54 ++++++++++++++++
 srcpkgs/python3-scikit-image/template         | 63 ++++++++++++++-----
 3 files changed, 116 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/python3-scikit-image/patches/numpy-version.patch
 create mode 100644 srcpkgs/python3-scikit-image/patches/python-includes.patch

diff --git a/srcpkgs/python3-scikit-image/patches/numpy-version.patch b/srcpkgs/python3-scikit-image/patches/numpy-version.patch
new file mode 100644
index 000000000000..9d3a96588edd
--- /dev/null
+++ b/srcpkgs/python3-scikit-image/patches/numpy-version.patch
@@ -0,0 +1,14 @@
+There doesn't seem to be a valid reason for this restriction, and it doesn't
+impede building anyway.
+
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -145,7 +145,7 @@
+     "numpy==1.21.1; python_version=='3.8' and platform_python_implementation != 'PyPy'",
+     "numpy==1.21.1; python_version=='3.9' and platform_python_implementation != 'PyPy'",
+     "numpy==1.21.6; python_version=='3.10' and platform_system != 'Windows' and platform_python_implementation != 'PyPy'",
+-    "numpy==1.23.3; python_version=='3.11' and platform_python_implementation != 'PyPy'",
++    "numpy>=1.23.3; python_version=='3.11' and platform_python_implementation != 'PyPy'",
+     "numpy; python_version>='3.12'",
+     "numpy; python_version>='3.8' and platform_python_implementation=='PyPy'",
+ ]
diff --git a/srcpkgs/python3-scikit-image/patches/python-includes.patch b/srcpkgs/python3-scikit-image/patches/python-includes.patch
new file mode 100644
index 000000000000..a094c4e571cb
--- /dev/null
+++ b/srcpkgs/python3-scikit-image/patches/python-includes.patch
@@ -0,0 +1,54 @@
+Running build Python to determine include paths fails for cross-builds, so copy
+the SciPy approach and allow a cross file to define explicit paths.
+
+--- a/skimage/meson.build
++++ b/skimage/meson.build
+@@ -30,13 +30,16 @@
+ endif
+ 
+ # NumPy include directory - needed in all submodules
+-incdir_numpy = run_command(py3,
+-  [
+-    '-c',
+-    'import os; os.chdir(".."); import numpy; print(numpy.get_include())'
+-  ],
+-  check: true
+-).stdout().strip()
++incdir_numpy = meson.get_external_property('numpy_include_dir', 'not-given')
++if incdir_numpy == 'not-given'
++  incdir_numpy = run_command(py3,
++    [
++      '-c',
++      'import os; os.chdir(".."); import numpy; print(numpy.get_include())'
++    ],
++    check: true
++  ).stdout().strip()
++endif
+ 
+ inc_np = include_directories(incdir_numpy)
+ 
+@@ -51,13 +54,17 @@
+   check: true
+ ).stdout().strip() == '1'
+ 
+-incdir_pythran = run_command(py3,
+-  [
+-    '-c',
+-    'import os; os.chdir(".."); import pythran; print(os.path.dirname(pythran.__file__));'
+-  ],
+-  check: true
+-).stdout().strip()
++incdir_pythran = meson.get_external_property('pythran_include_dir', 'not-given')
++if incdir_pythran == 'not-given'
++  incdir_pythran = run_command(py3,
++    [
++      '-c',
++      'import os; os.chdir(".."); import pythran; print(os.path.dirname(pythran.__file__));'
++    ],
++    check: true
++  ).stdout().strip()
++endif
++
+ inc_pythran = include_directories(incdir_pythran)
+ 
+ cpp_args_pythran = [
diff --git a/srcpkgs/python3-scikit-image/template b/srcpkgs/python3-scikit-image/template
index c3b403fdef61..e7b7d35fbcf2 100644
--- a/srcpkgs/python3-scikit-image/template
+++ b/srcpkgs/python3-scikit-image/template
@@ -1,28 +1,61 @@
 # Template file for 'python3-scikit-image'
 pkgname=python3-scikit-image
-version=0.19.3
-revision=2
-_pkgname="${pkgname#python3-}"
-build_style=python3-module
-build_helper="numpy"
-hostmakedepends="python3-Cython python3-wheel python3-numpy
- python3-packaging python3-setuptools pythran"
-makedepends="python3-devel"
-depends="python3-scipy python3-numpy python3-imageio python3-matplotlib
- python3-networkx python3-tifffile python3-pywt python3-packaging"
+version=0.21.0
+revision=1
+build_style=meson
+build_helper="python3"
+hostmakedepends="python3-build python3-installer python3-meson-python
+ python3-wheel python3-setuptools python3-packaging python3-Cython pythran
+ python3-lazy_loader python3-numpy"
+makedepends="python3-devel python3-numpy pythran"
+depends="python3-numpy python3-scipy python3-networkx python3-Pillow
+ python3-imageio python3-tifffile python3-pywt python3-packaging
+ python3-lazy_loader"
 short_desc="Image processing in Python"
 maintainer="Andrew J. Hesford <ajh@sideband.org>"
 license="BSD-3-Clause, MIT"
 homepage="https://scikit-image.org/"
-distfiles="https://github.com/${_pkgname}/${_pkgname}/archive/v${version}.tar.gz"
-checksum=4eb877c98d1395769daef5bc2ba8a7efd3f736c87086aecb3775a9174593398b
+distfiles="https://github.com/scikit-image/scikit-image/archive/v${version}.tar.gz"
+checksum=53a82a9dbd3ed608d2ad3876269a271a7e922b12e228388eac996b508aadd652
 # Tests require data files and unpackaged dependencies
 make_check=no
 
-pre_build() {
-	make_build_args+=" ${makejobs}"
+if [ ! "$XBPS_WORDSIZE" = "$XBPS_TARGET_WORDSIZE" ]; then
+	broken="pythran components build only if word size matches"
+fi
+
+if [ "${CROSS_BUILD}" ]; then
+	configure_args="--cross-file=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
+		[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}" .
 }
 
-post_install() {
+do_install() {
+	python3 -m installer --destdir "${DESTDIR}" \
+		--no-compile-bytecode dist/*.whl
 	vlicense LICENSE.txt
 }

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] python3-scikit-image: update to 0.21.0
  2023-06-02 22:42 [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0 ahesford
                   ` (3 preceding siblings ...)
  2023-06-06 14:06 ` [PR PATCH] [Updated] " ahesford
@ 2023-06-06 14:23 ` ahesford
  2023-06-06 14:43 ` ahesford
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ahesford @ 2023-06-06 14:23 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1219 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages scikit-image
https://github.com/void-linux/void-packages/pull/44233

[WIP] python3-scikit-image: update to 0.21.0
@eli-schwartz I wonder if you can offer some insight. To get Meson building scikit-image, I patched the `meson.build` to allow manual specification of include directories for NumPy and Pythran rather than forcing the build system to execute the Python interpreter. This works OK and was stolen from SciPy. However:
- Cross-building on 32-bit hosts from 64-but builders fails because `LONG_BIT` is the wrong size in Python's `python3.11/pyport.h`. Clearly some headers are mixing. This gets pulled in by Pythran's generated outputs in a couple of places.
- I can't seem to get `-I/usr/include/python3.11` out of the compiler flags, when it should point to the cross-build tree.
- I don't know that fixing the include path is sufficient to resolve the first problem.

Although I'm prepared to leave 32-but ARM behind with this update, I'd prefer to get it working correctly. 

A patch file from https://github.com/void-linux/void-packages/pull/44233.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-scikit-image-44233.patch --]
[-- Type: text/x-diff, Size: 11668 bytes --]

From bf103a0ef465d31e4dc16a7093063331be7578d3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 4 Apr 2023 10:06:35 -0400
Subject: [PATCH 1/4] New package: python3-lazy_loader-0.2

---
 srcpkgs/python3-lazy_loader/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/python3-lazy_loader/template

diff --git a/srcpkgs/python3-lazy_loader/template b/srcpkgs/python3-lazy_loader/template
new file mode 100644
index 000000000000..492c98124834
--- /dev/null
+++ b/srcpkgs/python3-lazy_loader/template
@@ -0,0 +1,19 @@
+# Template file for 'python3-lazy_loader'
+pkgname=python3-lazy_loader
+version=0.2
+revision=1
+build_style=python3-pep517
+hostmakedepends="python3-flit_core"
+depends="python3"
+checkdepends="python3-pytest-xdist"
+short_desc="Populate Python namespace without incurring immediate import costs"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/scientific-python/lazy_loader"
+changelog="https://raw.githubusercontent.com/scientific-python/lazy_loader/main/CHANGELOG.md"
+distfiles="${PYPI_SITE}/l/lazy_loader/lazy_loader-${version}.tar.gz"
+checksum=0edc7a5175c400acb108f283749951fefdadedeb00adcec6e88b974a9254f18a
+
+post_install() {
+	vlicense LICENSE.md
+}

From b1387ce9d4df0d4fa4acdd484f28596a0d1f43b7 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 2 Jun 2023 12:06:36 -0400
Subject: [PATCH 2/4] New package: python3-pyproject-metadata-0.7.1

---
 srcpkgs/python3-pyproject-metadata/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/python3-pyproject-metadata/template

diff --git a/srcpkgs/python3-pyproject-metadata/template b/srcpkgs/python3-pyproject-metadata/template
new file mode 100644
index 000000000000..fcf5c5d22593
--- /dev/null
+++ b/srcpkgs/python3-pyproject-metadata/template
@@ -0,0 +1,19 @@
+# Template file for 'python3-pyproject-metadata'
+pkgname=python3-pyproject-metadata
+version=0.7.1
+revision=1
+build_style=python3-pep517
+hostmakedepends="python3-flit_core python3-wheel"
+depends="python3-packaging"
+short_desc="PEP 621 metadata parsing"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://pep621.readthedocs.io/"
+changelog="https://raw.githubusercontent.com/FFY00/python-pyproject-metadata/main/CHANGELOG.rst"
+distfiles="${PYPI_SITE}/p/pyproject-metadata/pyproject-metadata-${version}.tar.gz"
+checksum=0a94f18b108b9b21f3a26a3d541f056c34edcb17dc872a144a15618fed7aef67
+make_check=no # tarball includes no tests
+
+post_install() {
+	vlicense LICENSE
+}

From b7e81ddd31c6a38fa1ab7b06a4a712fab673e998 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 2 Jun 2023 12:48:57 -0400
Subject: [PATCH 3/4] New package: python3-meson-python-0.13.1

---
 srcpkgs/python3-meson-python/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/python3-meson-python/template

diff --git a/srcpkgs/python3-meson-python/template b/srcpkgs/python3-meson-python/template
new file mode 100644
index 000000000000..50dc5be1c509
--- /dev/null
+++ b/srcpkgs/python3-meson-python/template
@@ -0,0 +1,20 @@
+# Template file for 'python3-meson-python'
+pkgname=python3-meson-python
+version=0.13.1
+revision=1
+build_style=python3-pep517
+hostmakedepends="meson python3-pyproject-metadata"
+depends="meson python3-pyproject-metadata patchelf"
+short_desc="Meson PEP 517 Python build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://meson-python.readthedocs.io/"
+changelog="https://raw.githubusercontent.com/mesonbuild/meson-python/main/CHANGELOG.rst"
+distfiles="${PYPI_SITE}/m/meson_python/meson_python-${version}.tar.gz"
+checksum=63b3170001425c42fa4cfedadb9051cbd28925ff8eed7c40d36ba0099e3c7618
+# tests require custom-built executables, need reconciliation with xbps-src env
+make_check=no 
+
+post_install() {
+	vlicense LICENSE
+}

From 50389ad91e287c862114285a4bf836880deb84a9 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 4 Apr 2023 10:09:26 -0400
Subject: [PATCH 4/4] python3-scikit-image: update to 0.21.0.

---
 .../patches/meson-cross.patch                 | 93 +++++++++++++++++++
 .../patches/numpy-version.patch               | 14 +++
 srcpkgs/python3-scikit-image/template         | 63 ++++++++++---
 3 files changed, 155 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/python3-scikit-image/patches/meson-cross.patch
 create mode 100644 srcpkgs/python3-scikit-image/patches/numpy-version.patch

diff --git a/srcpkgs/python3-scikit-image/patches/meson-cross.patch b/srcpkgs/python3-scikit-image/patches/meson-cross.patch
new file mode 100644
index 000000000000..8807a612f665
--- /dev/null
+++ b/srcpkgs/python3-scikit-image/patches/meson-cross.patch
@@ -0,0 +1,93 @@
+From 8789a3365282a4f5604e090a10c960e710d240b9 Mon Sep 17 00:00:00 2001
+From: "Andrew J. Hesford" <ajh@sideband.org>
+Date: Tue, 6 Jun 2023 10:05:25 -0400
+Subject: [PATCH] meson: allow proper selection of NumPy, Pythran in cross
+ builds
+
+---
+ skimage/meson.build | 62 +++++++++++++++++++++++++++------------------
+ 1 file changed, 38 insertions(+), 24 deletions(-)
+
+diff --git a/skimage/meson.build b/skimage/meson.build
+index 28c831312..c168389d7 100644
+--- a/skimage/meson.build
++++ b/skimage/meson.build
+@@ -29,37 +29,51 @@ if is_windows
+   endif
+ endif
+ 
+-# NumPy include directory - needed in all submodules
+-incdir_numpy = run_command(py3,
+-  [
+-    '-c',
+-    'import os; os.chdir(".."); import numpy; print(numpy.get_include())'
+-  ],
+-  check: true
+-).stdout().strip()
++# Both NumPy and Pythran require header files that may differ between the build
++# system and the host system in a cross-compilation environment. To accommodate
++# these cases, we can query user-defined properties that can be specified in
++# the 'properties' section of a Meson cross file:
++#
++#   [properties]
++#   numpy-include-dir = '/path/to/numpy/includes'
++#   pythran-include-dir = '/path/to/pythran/includes'
++#
++# In the absence of explicitly configured paths, just run the build Python and
++# try to query the Python packages for their paths directly.
++
++# NumPy include directory
++incdir_numpy = meson.get_external_property('numpy-include-dir', 'not-given')
++if incdir_numpy == 'not-given'
++  # If not specified, try to query NumPy from the build python
++  incdir_numpy = run_command(py3,
++    [
++      '-c',
++      'import os; os.chdir(".."); import numpy; print(numpy.get_include())'
++    ],
++    check: true
++  ).stdout().strip()
++endif
+ 
+ inc_np = include_directories(incdir_numpy)
+ 
+ cc = meson.get_compiler('c')
+ 
+-# Pythran include directory and build flags
+-use_pythran = run_command(py3,
+-  [
+-    '-c',
+-    'import os; print(os.environ.get("SCIPY_USE_PYTHRAN", 1))'
+-  ],
+-  check: true
+-).stdout().strip() == '1'
+-
+-incdir_pythran = run_command(py3,
+-  [
+-    '-c',
+-    'import os; os.chdir(".."); import pythran; print(os.path.dirname(pythran.__file__));'
+-  ],
+-  check: true
+-).stdout().strip()
++# Pythran include directory
++incdir_pythran = meson.get_external_property('pythran-include-dir', 'not-given')
++if incdir_pythran == 'not-given'
++  # If not specified, try to query Pythran from the build python
++  incdir_pythran = run_command(py3,
++    [
++      '-c',
++      'import os; os.chdir(".."); import pythran; print(os.path.dirname(pythran.__file__));'
++    ],
++    check: true
++  ).stdout().strip()
++endif
++
+ inc_pythran = include_directories(incdir_pythran)
+ 
++# Pythran build flags
+ cpp_args_pythran = [
+   '-DENABLE_PYTHON_MODULE',
+   '-D__PYTHRAN__=3',
+-- 
+2.41.0
+
diff --git a/srcpkgs/python3-scikit-image/patches/numpy-version.patch b/srcpkgs/python3-scikit-image/patches/numpy-version.patch
new file mode 100644
index 000000000000..9d3a96588edd
--- /dev/null
+++ b/srcpkgs/python3-scikit-image/patches/numpy-version.patch
@@ -0,0 +1,14 @@
+There doesn't seem to be a valid reason for this restriction, and it doesn't
+impede building anyway.
+
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -145,7 +145,7 @@
+     "numpy==1.21.1; python_version=='3.8' and platform_python_implementation != 'PyPy'",
+     "numpy==1.21.1; python_version=='3.9' and platform_python_implementation != 'PyPy'",
+     "numpy==1.21.6; python_version=='3.10' and platform_system != 'Windows' and platform_python_implementation != 'PyPy'",
+-    "numpy==1.23.3; python_version=='3.11' and platform_python_implementation != 'PyPy'",
++    "numpy>=1.23.3; python_version=='3.11' and platform_python_implementation != 'PyPy'",
+     "numpy; python_version>='3.12'",
+     "numpy; python_version>='3.8' and platform_python_implementation=='PyPy'",
+ ]
diff --git a/srcpkgs/python3-scikit-image/template b/srcpkgs/python3-scikit-image/template
index c3b403fdef61..df69402a73dd 100644
--- a/srcpkgs/python3-scikit-image/template
+++ b/srcpkgs/python3-scikit-image/template
@@ -1,28 +1,61 @@
 # Template file for 'python3-scikit-image'
 pkgname=python3-scikit-image
-version=0.19.3
-revision=2
-_pkgname="${pkgname#python3-}"
-build_style=python3-module
-build_helper="numpy"
-hostmakedepends="python3-Cython python3-wheel python3-numpy
- python3-packaging python3-setuptools pythran"
-makedepends="python3-devel"
-depends="python3-scipy python3-numpy python3-imageio python3-matplotlib
- python3-networkx python3-tifffile python3-pywt python3-packaging"
+version=0.21.0
+revision=1
+build_style=meson
+build_helper="python3"
+hostmakedepends="python3-build python3-installer python3-meson-python
+ python3-wheel python3-setuptools python3-packaging python3-Cython pythran
+ python3-lazy_loader python3-numpy"
+makedepends="python3-devel python3-numpy pythran"
+depends="python3-numpy python3-scipy python3-networkx python3-Pillow
+ python3-imageio python3-tifffile python3-pywt python3-packaging
+ python3-lazy_loader"
 short_desc="Image processing in Python"
 maintainer="Andrew J. Hesford <ajh@sideband.org>"
 license="BSD-3-Clause, MIT"
 homepage="https://scikit-image.org/"
-distfiles="https://github.com/${_pkgname}/${_pkgname}/archive/v${version}.tar.gz"
-checksum=4eb877c98d1395769daef5bc2ba8a7efd3f736c87086aecb3775a9174593398b
+distfiles="https://github.com/scikit-image/scikit-image/archive/v${version}.tar.gz"
+checksum=53a82a9dbd3ed608d2ad3876269a271a7e922b12e228388eac996b508aadd652
 # Tests require data files and unpackaged dependencies
 make_check=no
 
-pre_build() {
-	make_build_args+=" ${makejobs}"
+if [ ! "$XBPS_WORDSIZE" = "$XBPS_TARGET_WORDSIZE" ]; then
+	broken="pythran components build only if word size matches"
+fi
+
+if [ "${CROSS_BUILD}" ]; then
+	configure_args="--cross-file=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
+		[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}" .
 }
 
-post_install() {
+do_install() {
+	python3 -m installer --destdir "${DESTDIR}" \
+		--no-compile-bytecode dist/*.whl
 	vlicense LICENSE.txt
 }

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [WIP] python3-scikit-image: update to 0.21.0
  2023-06-02 22:42 [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0 ahesford
                   ` (4 preceding siblings ...)
  2023-06-06 14:23 ` ahesford
@ 2023-06-06 14:43 ` ahesford
  2023-06-06 14:45 ` [PR PATCH] [Updated] " ahesford
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ahesford @ 2023-06-06 14:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 274 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/44233#issuecomment-1578901778

Comment:
Welp, this problem goes away if I actually install `pkg-config` so Meson can properly find include and link directories. Mea culpa!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PR PATCH] [Updated] [WIP] python3-scikit-image: update to 0.21.0
  2023-06-02 22:42 [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0 ahesford
                   ` (5 preceding siblings ...)
  2023-06-06 14:43 ` ahesford
@ 2023-06-06 14:45 ` ahesford
  2023-06-06 15:02 ` [PR PATCH] [Closed]: " ahesford
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ahesford @ 2023-06-06 14:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1219 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages scikit-image
https://github.com/void-linux/void-packages/pull/44233

[WIP] python3-scikit-image: update to 0.21.0
@eli-schwartz I wonder if you can offer some insight. To get Meson building scikit-image, I patched the `meson.build` to allow manual specification of include directories for NumPy and Pythran rather than forcing the build system to execute the Python interpreter. This works OK and was stolen from SciPy. However:
- Cross-building on 32-bit hosts from 64-but builders fails because `LONG_BIT` is the wrong size in Python's `python3.11/pyport.h`. Clearly some headers are mixing. This gets pulled in by Pythran's generated outputs in a couple of places.
- I can't seem to get `-I/usr/include/python3.11` out of the compiler flags, when it should point to the cross-build tree.
- I don't know that fixing the include path is sufficient to resolve the first problem.

Although I'm prepared to leave 32-but ARM behind with this update, I'd prefer to get it working correctly. 

A patch file from https://github.com/void-linux/void-packages/pull/44233.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-scikit-image-44233.patch --]
[-- Type: text/x-diff, Size: 11550 bytes --]

From bf103a0ef465d31e4dc16a7093063331be7578d3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 4 Apr 2023 10:06:35 -0400
Subject: [PATCH 1/4] New package: python3-lazy_loader-0.2

---
 srcpkgs/python3-lazy_loader/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/python3-lazy_loader/template

diff --git a/srcpkgs/python3-lazy_loader/template b/srcpkgs/python3-lazy_loader/template
new file mode 100644
index 000000000000..492c98124834
--- /dev/null
+++ b/srcpkgs/python3-lazy_loader/template
@@ -0,0 +1,19 @@
+# Template file for 'python3-lazy_loader'
+pkgname=python3-lazy_loader
+version=0.2
+revision=1
+build_style=python3-pep517
+hostmakedepends="python3-flit_core"
+depends="python3"
+checkdepends="python3-pytest-xdist"
+short_desc="Populate Python namespace without incurring immediate import costs"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/scientific-python/lazy_loader"
+changelog="https://raw.githubusercontent.com/scientific-python/lazy_loader/main/CHANGELOG.md"
+distfiles="${PYPI_SITE}/l/lazy_loader/lazy_loader-${version}.tar.gz"
+checksum=0edc7a5175c400acb108f283749951fefdadedeb00adcec6e88b974a9254f18a
+
+post_install() {
+	vlicense LICENSE.md
+}

From b1387ce9d4df0d4fa4acdd484f28596a0d1f43b7 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 2 Jun 2023 12:06:36 -0400
Subject: [PATCH 2/4] New package: python3-pyproject-metadata-0.7.1

---
 srcpkgs/python3-pyproject-metadata/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/python3-pyproject-metadata/template

diff --git a/srcpkgs/python3-pyproject-metadata/template b/srcpkgs/python3-pyproject-metadata/template
new file mode 100644
index 000000000000..fcf5c5d22593
--- /dev/null
+++ b/srcpkgs/python3-pyproject-metadata/template
@@ -0,0 +1,19 @@
+# Template file for 'python3-pyproject-metadata'
+pkgname=python3-pyproject-metadata
+version=0.7.1
+revision=1
+build_style=python3-pep517
+hostmakedepends="python3-flit_core python3-wheel"
+depends="python3-packaging"
+short_desc="PEP 621 metadata parsing"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://pep621.readthedocs.io/"
+changelog="https://raw.githubusercontent.com/FFY00/python-pyproject-metadata/main/CHANGELOG.rst"
+distfiles="${PYPI_SITE}/p/pyproject-metadata/pyproject-metadata-${version}.tar.gz"
+checksum=0a94f18b108b9b21f3a26a3d541f056c34edcb17dc872a144a15618fed7aef67
+make_check=no # tarball includes no tests
+
+post_install() {
+	vlicense LICENSE
+}

From fa21910cda40d82b101cf7a622f5741a4b131d15 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 2 Jun 2023 12:48:57 -0400
Subject: [PATCH 3/4] New package: python3-meson-python-0.13.1

---
 srcpkgs/python3-meson-python/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/python3-meson-python/template

diff --git a/srcpkgs/python3-meson-python/template b/srcpkgs/python3-meson-python/template
new file mode 100644
index 000000000000..57f3b808c83e
--- /dev/null
+++ b/srcpkgs/python3-meson-python/template
@@ -0,0 +1,20 @@
+# Template file for 'python3-meson-python'
+pkgname=python3-meson-python
+version=0.13.1
+revision=1
+build_style=python3-pep517
+hostmakedepends="meson python3-pyproject-metadata"
+depends="meson python3-pyproject-metadata patchelf"
+short_desc="Meson PEP 517 Python build backend"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://meson-python.readthedocs.io/"
+changelog="https://raw.githubusercontent.com/mesonbuild/meson-python/main/CHANGELOG.rst"
+distfiles="${PYPI_SITE}/m/meson_python/meson_python-${version}.tar.gz"
+checksum=63b3170001425c42fa4cfedadb9051cbd28925ff8eed7c40d36ba0099e3c7618
+# tests require custom-built executables, need reconciliation with xbps-src env
+make_check=no
+
+post_install() {
+	vlicense LICENSE
+}

From 1fd1ad0d8d0852e3f4bb4f6661db55f97300e3d3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 4 Apr 2023 10:09:26 -0400
Subject: [PATCH 4/4] python3-scikit-image: update to 0.21.0.

---
 .../patches/meson-cross.patch                 | 93 +++++++++++++++++++
 .../patches/numpy-version.patch               | 14 +++
 srcpkgs/python3-scikit-image/template         | 59 +++++++++---
 3 files changed, 151 insertions(+), 15 deletions(-)
 create mode 100644 srcpkgs/python3-scikit-image/patches/meson-cross.patch
 create mode 100644 srcpkgs/python3-scikit-image/patches/numpy-version.patch

diff --git a/srcpkgs/python3-scikit-image/patches/meson-cross.patch b/srcpkgs/python3-scikit-image/patches/meson-cross.patch
new file mode 100644
index 000000000000..8807a612f665
--- /dev/null
+++ b/srcpkgs/python3-scikit-image/patches/meson-cross.patch
@@ -0,0 +1,93 @@
+From 8789a3365282a4f5604e090a10c960e710d240b9 Mon Sep 17 00:00:00 2001
+From: "Andrew J. Hesford" <ajh@sideband.org>
+Date: Tue, 6 Jun 2023 10:05:25 -0400
+Subject: [PATCH] meson: allow proper selection of NumPy, Pythran in cross
+ builds
+
+---
+ skimage/meson.build | 62 +++++++++++++++++++++++++++------------------
+ 1 file changed, 38 insertions(+), 24 deletions(-)
+
+diff --git a/skimage/meson.build b/skimage/meson.build
+index 28c831312..c168389d7 100644
+--- a/skimage/meson.build
++++ b/skimage/meson.build
+@@ -29,37 +29,51 @@ if is_windows
+   endif
+ endif
+ 
+-# NumPy include directory - needed in all submodules
+-incdir_numpy = run_command(py3,
+-  [
+-    '-c',
+-    'import os; os.chdir(".."); import numpy; print(numpy.get_include())'
+-  ],
+-  check: true
+-).stdout().strip()
++# Both NumPy and Pythran require header files that may differ between the build
++# system and the host system in a cross-compilation environment. To accommodate
++# these cases, we can query user-defined properties that can be specified in
++# the 'properties' section of a Meson cross file:
++#
++#   [properties]
++#   numpy-include-dir = '/path/to/numpy/includes'
++#   pythran-include-dir = '/path/to/pythran/includes'
++#
++# In the absence of explicitly configured paths, just run the build Python and
++# try to query the Python packages for their paths directly.
++
++# NumPy include directory
++incdir_numpy = meson.get_external_property('numpy-include-dir', 'not-given')
++if incdir_numpy == 'not-given'
++  # If not specified, try to query NumPy from the build python
++  incdir_numpy = run_command(py3,
++    [
++      '-c',
++      'import os; os.chdir(".."); import numpy; print(numpy.get_include())'
++    ],
++    check: true
++  ).stdout().strip()
++endif
+ 
+ inc_np = include_directories(incdir_numpy)
+ 
+ cc = meson.get_compiler('c')
+ 
+-# Pythran include directory and build flags
+-use_pythran = run_command(py3,
+-  [
+-    '-c',
+-    'import os; print(os.environ.get("SCIPY_USE_PYTHRAN", 1))'
+-  ],
+-  check: true
+-).stdout().strip() == '1'
+-
+-incdir_pythran = run_command(py3,
+-  [
+-    '-c',
+-    'import os; os.chdir(".."); import pythran; print(os.path.dirname(pythran.__file__));'
+-  ],
+-  check: true
+-).stdout().strip()
++# Pythran include directory
++incdir_pythran = meson.get_external_property('pythran-include-dir', 'not-given')
++if incdir_pythran == 'not-given'
++  # If not specified, try to query Pythran from the build python
++  incdir_pythran = run_command(py3,
++    [
++      '-c',
++      'import os; os.chdir(".."); import pythran; print(os.path.dirname(pythran.__file__));'
++    ],
++    check: true
++  ).stdout().strip()
++endif
++
+ inc_pythran = include_directories(incdir_pythran)
+ 
++# Pythran build flags
+ cpp_args_pythran = [
+   '-DENABLE_PYTHON_MODULE',
+   '-D__PYTHRAN__=3',
+-- 
+2.41.0
+
diff --git a/srcpkgs/python3-scikit-image/patches/numpy-version.patch b/srcpkgs/python3-scikit-image/patches/numpy-version.patch
new file mode 100644
index 000000000000..9d3a96588edd
--- /dev/null
+++ b/srcpkgs/python3-scikit-image/patches/numpy-version.patch
@@ -0,0 +1,14 @@
+There doesn't seem to be a valid reason for this restriction, and it doesn't
+impede building anyway.
+
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -145,7 +145,7 @@
+     "numpy==1.21.1; python_version=='3.8' and platform_python_implementation != 'PyPy'",
+     "numpy==1.21.1; python_version=='3.9' and platform_python_implementation != 'PyPy'",
+     "numpy==1.21.6; python_version=='3.10' and platform_system != 'Windows' and platform_python_implementation != 'PyPy'",
+-    "numpy==1.23.3; python_version=='3.11' and platform_python_implementation != 'PyPy'",
++    "numpy>=1.23.3; python_version=='3.11' and platform_python_implementation != 'PyPy'",
+     "numpy; python_version>='3.12'",
+     "numpy; python_version>='3.8' and platform_python_implementation=='PyPy'",
+ ]
diff --git a/srcpkgs/python3-scikit-image/template b/srcpkgs/python3-scikit-image/template
index c3b403fdef61..e800ed4f00f6 100644
--- a/srcpkgs/python3-scikit-image/template
+++ b/srcpkgs/python3-scikit-image/template
@@ -1,28 +1,57 @@
 # Template file for 'python3-scikit-image'
 pkgname=python3-scikit-image
-version=0.19.3
-revision=2
-_pkgname="${pkgname#python3-}"
-build_style=python3-module
-build_helper="numpy"
-hostmakedepends="python3-Cython python3-wheel python3-numpy
- python3-packaging python3-setuptools pythran"
-makedepends="python3-devel"
-depends="python3-scipy python3-numpy python3-imageio python3-matplotlib
- python3-networkx python3-tifffile python3-pywt python3-packaging"
+version=0.21.0
+revision=1
+build_style=meson
+build_helper="python3"
+hostmakedepends="python3-build python3-installer python3-meson-python
+ python3-wheel python3-setuptools python3-packaging python3-Cython pythran
+ python3-lazy_loader python3-numpy pkg-config"
+makedepends="python3-devel python3-numpy pythran"
+depends="python3-numpy python3-scipy python3-networkx python3-Pillow
+ python3-imageio python3-tifffile python3-pywt python3-packaging
+ python3-lazy_loader"
 short_desc="Image processing in Python"
 maintainer="Andrew J. Hesford <ajh@sideband.org>"
 license="BSD-3-Clause, MIT"
 homepage="https://scikit-image.org/"
-distfiles="https://github.com/${_pkgname}/${_pkgname}/archive/v${version}.tar.gz"
-checksum=4eb877c98d1395769daef5bc2ba8a7efd3f736c87086aecb3775a9174593398b
+distfiles="https://github.com/scikit-image/scikit-image/archive/v${version}.tar.gz"
+checksum=53a82a9dbd3ed608d2ad3876269a271a7e922b12e228388eac996b508aadd652
 # Tests require data files and unpackaged dependencies
 make_check=no
 
-pre_build() {
-	make_build_args+=" ${makejobs}"
+if [ "${CROSS_BUILD}" ]; then
+	configure_args="--cross-file=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
+		[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}" .
 }
 
-post_install() {
+do_install() {
+	python3 -m installer --destdir "${DESTDIR}" \
+		--no-compile-bytecode dist/*.whl
 	vlicense LICENSE.txt
 }

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PR PATCH] [Closed]: [WIP] python3-scikit-image: update to 0.21.0
  2023-06-02 22:42 [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0 ahesford
                   ` (6 preceding siblings ...)
  2023-06-06 14:45 ` [PR PATCH] [Updated] " ahesford
@ 2023-06-06 15:02 ` ahesford
  2023-06-06 15:02 ` ahesford
  2023-06-06 15:05 ` eli-schwartz
  9 siblings, 0 replies; 11+ messages in thread
From: ahesford @ 2023-06-06 15:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1056 bytes --]

There's a closed pull request on the void-packages repository

[WIP] python3-scikit-image: update to 0.21.0
https://github.com/void-linux/void-packages/pull/44233

Description:
@eli-schwartz I wonder if you can offer some insight. To get Meson building scikit-image, I patched the `meson.build` to allow manual specification of include directories for NumPy and Pythran rather than forcing the build system to execute the Python interpreter. This works OK and was stolen from SciPy. However:
- Cross-building on 32-bit hosts from 64-but builders fails because `LONG_BIT` is the wrong size in Python's `python3.11/pyport.h`. Clearly some headers are mixing. This gets pulled in by Pythran's generated outputs in a couple of places.
- I can't seem to get `-I/usr/include/python3.11` out of the compiler flags, when it should point to the cross-build tree.
- I don't know that fixing the include path is sufficient to resolve the first problem.

Although I'm prepared to leave 32-but ARM behind with this update, I'd prefer to get it working correctly. 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [WIP] python3-scikit-image: update to 0.21.0
  2023-06-02 22:42 [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0 ahesford
                   ` (7 preceding siblings ...)
  2023-06-06 15:02 ` [PR PATCH] [Closed]: " ahesford
@ 2023-06-06 15:02 ` ahesford
  2023-06-06 15:05 ` eli-schwartz
  9 siblings, 0 replies; 11+ messages in thread
From: ahesford @ 2023-06-06 15:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 183 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/44233#issuecomment-1578935325

Comment:
8342faf5f853303045375e0139825690a2e20e7e

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [WIP] python3-scikit-image: update to 0.21.0
  2023-06-02 22:42 [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0 ahesford
                   ` (8 preceding siblings ...)
  2023-06-06 15:02 ` ahesford
@ 2023-06-06 15:05 ` eli-schwartz
  9 siblings, 0 replies; 11+ messages in thread
From: eli-schwartz @ 2023-06-06 15:05 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

New comment by eli-schwartz on void-packages repository

https://github.com/void-linux/void-packages/pull/44233#issuecomment-1578941202

Comment:
Ah okay. Good to hear the problem is solved. :)

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-06-06 15:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-02 22:42 [PR PATCH] [WIP] python3-scikit-image: update to 0.21.0 ahesford
2023-06-02 23:53 ` eli-schwartz
2023-06-03  2:58 ` ahesford
2023-06-03  2:59 ` ahesford
2023-06-06 14:06 ` [PR PATCH] [Updated] " ahesford
2023-06-06 14:23 ` ahesford
2023-06-06 14:43 ` ahesford
2023-06-06 14:45 ` [PR PATCH] [Updated] " ahesford
2023-06-06 15:02 ` [PR PATCH] [Closed]: " ahesford
2023-06-06 15:02 ` ahesford
2023-06-06 15:05 ` eli-schwartz

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).