Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 907309 - Porting dev-python/numpy from distutils to meson
Summary: Porting dev-python/numpy from distutils to meson
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Science Related Packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-28 18:49 UTC by cyrillic
Modified: 2023-06-26 13:14 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,778.88 KB, text/plain)
2023-05-28 18:50 UTC, cyrillic
Details
build.log (build.log,499.66 KB, text/plain)
2023-06-13 00:36 UTC, cyrillic
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cyrillic 2023-05-28 18:49:01 UTC
Porting dev-python/numpy from distutils to meson : proof of concept

Reproducible: Always




Upstream has already done the hard part for life after distutils ...


# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8
EGIT_REPO_URI="https://github.com/${PN}/${PN}.git"
PYTHON_COMPAT=( python3_{9..12} pypy3 )
PYTHON_REQ_USE="threads(+)"

FORTRAN_NEEDED=lapack

inherit flag-o-matic fortran-2 git-r3 meson multiprocessing pypi python-r1 toolchain-funcs

DOC_PV=${PV}
DESCRIPTION="Fast array and numerical python library"
HOMEPAGE="
	https://numpy.org/
	https://github.com/numpy/numpy/
	https://pypi.org/project/numpy/
"
SRC_URI=""

LICENSE="BSD"
SLOT="0"
KEYWORDS=""
IUSE="lapack test"

RDEPEND="
	lapack? (
		>=virtual/cblas-3.8
		>=virtual/lapack-3.8
	)
"
BDEPEND="
	${RDEPEND}
	<dev-python/cython-3[${PYTHON_USEDEP}]
	>=dev-python/cython-0.29.30[${PYTHON_USEDEP}]
	lapack? (
		virtual/pkgconfig
	)
	test? (
		$(python_gen_cond_dep '
			>=dev-python/cffi-1.14.0[${PYTHON_USEDEP}]
		' 'python*')
		dev-python/charset_normalizer[${PYTHON_USEDEP}]
		>=dev-python/hypothesis-5.8.0[${PYTHON_USEDEP}]
		dev-python/pytest-xdist[${PYTHON_USEDEP}]
		>=dev-python/pytz-2019.3[${PYTHON_USEDEP}]
	)
"

PATCHES=()

src_configure() {
	configuring() {
		meson_src_configure \
			-Dblas="cblas,blas" \
			-Dlapack="lapack" \
			-Ddisable-svml=false \
			-Ddisable-threading=false \
			-Ddisable-simd-optimizations=true \
			-Drelaxed-strides-debug=false
	}
	python_foreach_impl configuring
}

src_compile() {
	python_foreach_impl meson_src_compile
}

src_test() {
	python_foreach_impl meson_src_test
}

src_install() {
	installing() {
		meson_src_install
	}
	python_foreach_impl installing
}
Comment 1 cyrillic 2023-05-28 18:50:57 UTC
Created attachment 862762 [details]
build.log
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-05-28 18:51:21 UTC
You'll need to use DISTUTILS_USE_PEP517=meson-python, ideally.

But yeah, I did take a look at this before, and gave up as it wasn't ready: https://github.com/gentoo/gentoo/pull/28725.
Comment 3 cyrillic 2023-05-29 06:24:37 UTC
(In reply to Sam James from comment #2)
> You'll need to use DISTUTILS_USE_PEP517=meson-python, ideally.

I tried that and things failed miserably. I also noticed in the logs that fortran was not getting used at all, so I cleaned that out.

# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8
EGIT_REPO_URI="https://github.com/${PN}/${PN}.git"
PYTHON_COMPAT=( python3_{9..12} pypy3 )
PYTHON_REQ_USE="threads(+)"

inherit flag-o-matic git-r3 meson multiprocessing pypi python-r1 toolchain-funcs

DESCRIPTION="Fast array and numerical python library"
HOMEPAGE="
	https://numpy.org/
	https://github.com/numpy/numpy/
	https://pypi.org/project/numpy/
"
SRC_URI=""

LICENSE="BSD"
SLOT="0"
KEYWORDS=""
IUSE="test"

RDEPEND="
	>=virtual/cblas-3.8
	>=virtual/lapack-3.8
"
BDEPEND="
	${RDEPEND}
	<dev-python/cython-3[${PYTHON_USEDEP}]
	>=dev-python/cython-0.29.30[${PYTHON_USEDEP}]
	virtual/pkgconfig
	test? (
		$(python_gen_cond_dep '
			>=dev-python/cffi-1.14.0[${PYTHON_USEDEP}]
		' 'python*')
		dev-python/charset_normalizer[${PYTHON_USEDEP}]
		>=dev-python/hypothesis-5.8.0[${PYTHON_USEDEP}]
		dev-python/pytest-xdist[${PYTHON_USEDEP}]
		>=dev-python/pytz-2019.3[${PYTHON_USEDEP}]
	)
"

src_configure() {
	local emesonargs=(
			-Dblas="cblas"
			-Dlapack="lapack"
			-Ddisable-svml=false
			-Ddisable-threading=false
			-Ddisable-simd-optimizations=true
			-Drelaxed-strides-debug=false
	)
	python_foreach_impl meson_src_configure
}

src_compile() {
	python_foreach_impl meson_src_compile
}

src_test() {
	python_foreach_impl meson_src_test
}

src_install() {
	python_foreach_impl meson_src_install
}
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-02 06:16:39 UTC
(In reply to cyrillic from comment #3)
> (In reply to Sam James from comment #2)
> > You'll need to use DISTUTILS_USE_PEP517=meson-python, ideally.
> 
> I tried that and things failed miserably. I also noticed in the logs that
> fortran was not getting used at all, so I cleaned that out.
> 

Fortran not being used sounds pretty suspicious.
Comment 5 cyrillic 2023-06-02 22:36:13 UTC
(In reply to Sam James from comment #4)
> Fortran not being used sounds pretty suspicious.

I agree. Even though things will compile and install without errors, it looks like the meson port is a bit half-baked at the moment.
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-02 22:52:03 UTC
(In reply to cyrillic from comment #5)
> (In reply to Sam James from comment #4)
> > Fortran not being used sounds pretty suspicious.
> 
> I agree. Even though things will compile and install without errors, it
> looks like the meson port is a bit half-baked at the moment.

Yeah :(

Unfortunately, I tried last night to get tests running and that didn't go great either.
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-12 10:47:11 UTC
mgorny and I have got a bit further, but blocked on https://github.com/numpy/numpy/issues/23909 right now..
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-12 12:18:58 UTC
Made some progress, more later.
Comment 9 Larry the Git Cow gentoo-dev 2023-06-12 15:22:05 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=358874f189c9f8d2e1532ba9933ee57ac8942a95

commit 358874f189c9f8d2e1532ba9933ee57ac8942a95
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-06-12 15:20:37 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-06-12 15:21:15 +0000

    dev-python/numpy: add 1.25.0_rc1
    
    Closes: https://bugs.gentoo.org/907309
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-python/numpy/Manifest                          |   1 +
 .../numpy-1.25.0_rc1-meson-pyproject.toml.patch    | 392 +++++++++++++++++++++
 dev-python/numpy/numpy-1.25.0_rc1.ebuild           | 127 +++++++
 3 files changed, 520 insertions(+)
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-12 15:23:29 UTC
The Fortran thing ended up being a red herring - see https://github.com/numpy/numpy/blob/4af0babbd67edc5db0fc54e2f905ceb64eba925e/INSTALL.rst#L72 (scipy needs it directly, but not numpy).
Comment 11 cyrillic 2023-06-12 23:36:41 UTC
Very nice ... I will be trying it out shortly.
Comment 12 cyrillic 2023-06-13 00:36:43 UTC
Created attachment 863753 [details]
build.log

Compile and install works fine with python3.11

If I bump dev-python/meson-python to allow python3.12 , then dev-python/numpy seems to be working with python3.12 as well.
Comment 13 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-13 17:19:10 UTC
Thanks!

I can add 3.12 to all of its deps (doing it now) but numpy itself fails tests w/ 3.12:

```
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_create_delete[ones-1-<subarray>] - assert (4294967295 - 4294967295) == (6 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_create_delete[ones-1-<subarray in field>] - assert (4294967295 - 4294967295) == (6 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_create_delete[ones-1-<structured subarray 1>] - assert (4294967295 - 4294967295) == (6 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_create_delete[ones-1-<structured subarray 2>] - assert (4294967295 - 4294967295) == (12 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_create_delete[zeros-0-<subarray>] - assert (4294967295 - 4294967295) == (6 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_create_delete[zeros-0-<subarray in field>] - assert (4294967295 - 4294967295) == (6 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_create_delete[zeros-0-<structured subarray 1>] - assert (4294967295 - 4294967295) == (6 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_create_delete[zeros-0-<structured subarray 2>] - assert (4294967295 - 4294967295) == (12 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_item_setting[<subarray>] - assert (4294967295 - 4294967295) == (6 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_item_setting[<subarray in field>] - assert (4294967295 - 4294967295) == (6 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_item_setting[<structured subarray 1>] - assert (4294967295 - 4294967295) == (6 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_item_setting[<structured subarray 2>] - assert (4294967295 - 4294967295) == (12 * 3)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape0-index0-2-<subarray>] - assert (4294967295 - 4294967295) == (6 * 2)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape0-index0-2-<subarray in field>] - assert (4294967295 - 4294967295) == (6 * 2)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape0-index0-2-<structured subarray 1>] - assert (4294967295 - 4294967295) == (6 * 2)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape0-index0-2-<structured subarray 2>] - assert (4294967295 - 4294967295) == (12 * 2)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape1-index1-4-<subarray>] - assert (4294967295 - 4294967295) == (6 * 4)
FAILED core/tests/test_regression.py::TestRegression::test_structured_arrays_with_objects2 - AssertionError
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape1-index1-4-<subarray in field>] - assert (4294967295 - 4294967295) == (6 * 4)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape1-index1-4-<structured subarray 1>] - assert (4294967295 - 4294967295) == (6 * 4)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape1-index1-4-<structured subarray 2>] - assert (4294967295 - 4294967295) == (12 * 4)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape2-index2-2-<subarray>] - assert (4294967295 - 4294967295) == (6 * 2)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape2-index2-2-<subarray in field>] - assert (4294967295 - 4294967295) == (6 * 2)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape2-index2-2-<structured subarray 1>] - assert (4294967295 - 4294967295) == (6 * 2)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape2-index2-2-<structured subarray 2>] - assert (4294967295 - 4294967295) == (12 * 2)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape3-index3-2-<subarray>] - assert (4294967295 - 4294967295) == (6 * 2)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape3-index3-2-<subarray in field>] - assert (4294967295 - 4294967295) == (6 * 2)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape3-index3-2-<structured subarray 1>] - assert (4294967295 - 4294967295) == (6 * 2)
FAILED core/tests/test_dtype.py::TestStructuredObjectRefcounting::test_structured_object_indexing[shape3-index3-2-<structured subarray 2>] - assert (4294967295 - 4294967295) == (12 * 2)
FAILED lib/tests/test_format.py::test_python2_python3_interoperability -   File "<string>", line 1
======================================================== 30 failed, 31179 passed, 941 skipped, 29 xfailed, 6 xpassed, 979 warnings in 81.67s (0:01:21) =========================================================
 * ERROR: dev-python/numpy-1.25.0_rc1::gentoo failed (test phase):
```
Comment 14 cyrillic 2023-06-13 22:44:59 UTC
Maybe the testsuite depends on distutils even though building numpy no longer does.
Comment 15 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-13 22:45:32 UTC
(In reply to cyrillic from comment #14)
> Maybe the testsuite depends on distutils even though building numpy no
> longer does.

Nah, these failures are *only* with 3.12. 3.10+3.11 are fine.
Comment 16 Larry the Git Cow gentoo-dev 2023-06-26 13:14:46 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=598a530efd89c78a4a079895e362b1db6a4cf54d

commit 598a530efd89c78a4a079895e362b1db6a4cf54d
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-06-26 12:48:09 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-06-26 13:14:16 +0000

    dev-python/numpy: enable py3.12
    
    It turns out the test failures were non-issues and are now fixed upstream.
    
    Closes: https://bugs.gentoo.org/907309
    Signed-off-by: Sam James <sam@gentoo.org>

 ...y-1.25.0-skip-python3.12-irrelevant-tests.patch | 187 +++++++++++++++++++++
 dev-python/numpy/numpy-1.25.0.ebuild               |   3 +-
 2 files changed, 189 insertions(+), 1 deletion(-)