public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: net-wireless/soapysdr/files/, net-wireless/soapysdr/
@ 2024-06-02  1:44 Sam James
  0 siblings, 0 replies; only message in thread
From: Sam James @ 2024-06-02  1:44 UTC (permalink / raw
  To: gentoo-commits

commit:     b68f6dcca10b8439e9de2c2eea96853cee5f2577
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  2 01:23:09 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun  2 01:40:35 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b68f6dcc

net-wireless/soapysdr: fix broken Python handling

* Add patch for Python 3.12 distutils

* Switch to python-single-r1 as its only Python reverse dependency in
  ::gentoo is net-wireless/gnuradio.

  Before now, it was completely broken as it'd use whatever Python it
  felt like -- at no point was EPYTHON/PYTHON passed into the build system,
  and it accumulated args when re-running for each impl (just enabling Python,
  not for any specific impl) anyway.

  We also only installed once anyway.

Fixes: 915993925dd6ae9f4303278ab00e4feb49c5d12b
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../soapysdr-0.8.1-python3.12-distutils.patch      | 74 ++++++++++++++++++++++
 ...pysdr-0.8.1.ebuild => soapysdr-0.8.1-r1.ebuild} | 48 +++++++-------
 net-wireless/soapysdr/soapysdr-9999.ebuild         | 43 ++++++-------
 3 files changed, 116 insertions(+), 49 deletions(-)

diff --git a/net-wireless/soapysdr/files/soapysdr-0.8.1-python3.12-distutils.patch b/net-wireless/soapysdr/files/soapysdr-0.8.1-python3.12-distutils.patch
new file mode 100644
index 000000000000..877bc9c15ba7
--- /dev/null
+++ b/net-wireless/soapysdr/files/soapysdr-0.8.1-python3.12-distutils.patch
@@ -0,0 +1,74 @@
+https://github.com/pothosware/SoapySDR/commit/1ee5670803f89b21d84a6a84acbb578da051c119
+
+From 1ee5670803f89b21d84a6a84acbb578da051c119 Mon Sep 17 00:00:00 2001
+From: Ryan Volz <ryan.volz@gmail.com>
+Date: Tue, 26 Sep 2023 14:56:59 -0400
+Subject: [PATCH] Remove deprecated use of distutils, fix for Python 3.12+
+
+This switches to using sysconfig from distutils, which is necessary for
+Python 3.12+ since distutils is deprecated and has been removed.
+
+It is necessary to specify the install scheme when a prefix other than
+the Python default is used so that changes to the default scheme made by
+distributions (e.g. Debian, Fedora) do not produce an incorrect Python
+installation directory. For example, Debian patches the default scheme
+to prepend the path with '/local', but if a user specifies a prefix of
+'/usr/local', then the path using the default scheme would be
+'/usr/local/local/...' with a duplicated 'local' directory. Specifying
+an unmodified install scheme fixes that.
+
+Signed-off-by: Ryan Volz <ryan.volz@gmail.com>
+---
+ python/get_python_lib.py | 36 ++++++++++++++++++++++++-----------
+ 1 file changed, 25 insertions(+), 11 deletions(-)
+
+diff --git a/python/get_python_lib.py b/python/get_python_lib.py
+index 0c716529..574f0b60 100644
+--- a/python/get_python_lib.py
++++ b/python/get_python_lib.py
+@@ -1,19 +1,33 @@
+ import os
++import pathlib
+ import sys
+-import site
+-from distutils.sysconfig import get_python_lib
++import sysconfig
+ 
+ if __name__ == '__main__':
+-    prefix = sys.argv[1]
++    prefix = pathlib.Path(sys.argv[1]).resolve()
+ 
+-    #ask distutils where to install the python module
+-    install_dir = get_python_lib(plat_specific=True, prefix=prefix)
++    # default install dir for the running Python interpreter
++    default_install_dir = pathlib.Path(sysconfig.get_path('platlib')).resolve()
+ 
+-    #use sites when the prefix is already recognized
++    # if default falls under the desired prefix, we're done
+     try:
+-        paths = [p for p in site.getsitepackages() if p.startswith(prefix)]
+-        if len(paths) == 1: install_dir = paths[0]
+-    except AttributeError: pass
++        relative_install_dir = default_install_dir.relative_to(prefix)
++    except ValueError:
++        # get install dir for the specified prefix
++        # can't use the default scheme because distributions modify it
++        # newer Python versions have 'venv' scheme, use for all OSs.
++        if 'venv' in sysconfig.get_scheme_names():
++            scheme = 'venv'
++        elif os.name == 'nt':
++            scheme = 'nt'
++        else:
++            scheme = 'posix_prefix'
++        prefix_install_dir = pathlib.Path(sysconfig.get_path(
++            'platlib',
++            scheme=scheme,
++            vars={'base': prefix, 'platbase': prefix},
++        )).resolve()
++        relative_install_dir = prefix_install_dir.relative_to(prefix)
+ 
+-    #strip the prefix to return a relative path
+-    print(os.path.relpath(install_dir, prefix))
++    # want a relative path for use in the build system
++    print(relative_install_dir)
+

diff --git a/net-wireless/soapysdr/soapysdr-0.8.1.ebuild b/net-wireless/soapysdr/soapysdr-0.8.1-r1.ebuild
similarity index 58%
rename from net-wireless/soapysdr/soapysdr-0.8.1.ebuild
rename to net-wireless/soapysdr/soapysdr-0.8.1-r1.ebuild
index b82e2be6935d..f4f69287124e 100644
--- a/net-wireless/soapysdr/soapysdr-0.8.1.ebuild
+++ b/net-wireless/soapysdr/soapysdr-0.8.1-r1.ebuild
@@ -4,8 +4,7 @@
 EAPI=8
 
 PYTHON_COMPAT=( python3_{10..12} )
-
-inherit cmake python-r1
+inherit cmake python-single-r1
 
 DESCRIPTION="vendor and platform neutral SDR support library"
 HOMEPAGE="https://github.com/pothosware/SoapySDR"
@@ -22,39 +21,40 @@ fi
 
 LICENSE="Boost-1.0"
 SLOT="0/${PV}"
-
 IUSE="bladerf hackrf python rtlsdr plutosdr uhd"
 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
 
 RDEPEND="python? ( ${PYTHON_DEPS} )"
-DEPEND="${RDEPEND}
-	python? ( dev-lang/swig:0 )
+DEPEND="${RDEPEND}"
+BDEPEND="python? ( dev-lang/swig:0 )"
+PDEPEND="
+	bladerf? ( net-wireless/soapybladerf )
+	hackrf? ( net-wireless/soapyhackrf )
+	rtlsdr? ( net-wireless/soapyrtlsdr )
+	plutosdr? ( net-wireless/soapyplutosdr )
+	uhd? ( net-wireless/soapyuhd )
 "
-PDEPEND="bladerf? ( net-wireless/soapybladerf )
-		hackrf? ( net-wireless/soapyhackrf )
-		rtlsdr? ( net-wireless/soapyrtlsdr )
-		plutosdr? ( net-wireless/soapyplutosdr )
-		uhd? ( net-wireless/soapyuhd )"
 
-src_configure() {
-	configuration() {
-		mycmakeargs+=(
-			-DENABLE_PYTHON=ON
-			-DBUILD_PYTHON3=ON
-		)
-	}
+PATCHES=(
+	"${FILESDIR}"/soapysdr-0.8.1-python3.12-distutils.patch
+)
 
-	if use python; then
-		python_foreach_impl configuration
-	fi
+pkg_setup() {
+	use python && python-single-r1_pkg_setup
+}
+
+src_configure() {
+	local mycmakeargs=(
+		-DENABLE_PYTHON=$(usex python)
+		-DENABLE_PYTHON3=$(usex python)
+		-DBUILD_PYTHON3=$(usex python)
+		-DUSE_PYTHON_CONFIG=ON
+	)
 
 	cmake_src_configure
 }
 
 src_install() {
 	cmake_src_install
-
-	if use python; then
-		python_foreach_impl python_optimize
-	fi
+	use python && python_optimize
 }

diff --git a/net-wireless/soapysdr/soapysdr-9999.ebuild b/net-wireless/soapysdr/soapysdr-9999.ebuild
index 04bd0f2876cd..dbc5bebb6a98 100644
--- a/net-wireless/soapysdr/soapysdr-9999.ebuild
+++ b/net-wireless/soapysdr/soapysdr-9999.ebuild
@@ -4,8 +4,7 @@
 EAPI=8
 
 PYTHON_COMPAT=( python3_{10..12} )
-
-inherit cmake python-r1
+inherit cmake python-single-r1
 
 DESCRIPTION="vendor and platform neutral SDR support library"
 HOMEPAGE="https://github.com/pothosware/SoapySDR"
@@ -15,46 +14,40 @@ if [ "${PV}" = "9999" ]; then
 	EGIT_CLONE_TYPE="shallow"
 	inherit git-r3
 else
-	KEYWORDS="~amd64 ~arm ~riscv ~x86"
+	KEYWORDS="amd64 ~arm ~riscv ~x86"
 	SRC_URI="https://github.com/pothosware/SoapySDR/archive/soapy-sdr-${PV}.tar.gz -> ${P}.tar.gz"
 	S="${WORKDIR}"/SoapySDR-soapy-sdr-"${PV}"
 fi
 
 LICENSE="Boost-1.0"
 SLOT="0/${PV}"
-
 IUSE="bladerf hackrf python rtlsdr plutosdr uhd"
 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
 
 RDEPEND="python? ( ${PYTHON_DEPS} )"
-DEPEND="${RDEPEND}
-	python? ( dev-lang/swig:0 )
+DEPEND="${RDEPEND}"
+BDEPEND="python? ( dev-lang/swig:0 )"
+PDEPEND="
+	bladerf? ( net-wireless/soapybladerf )
+	hackrf? ( net-wireless/soapyhackrf )
+	rtlsdr? ( net-wireless/soapyrtlsdr )
+	plutosdr? ( net-wireless/soapyplutosdr )
+	uhd? ( net-wireless/soapyuhd )
 "
-PDEPEND="bladerf? ( net-wireless/soapybladerf )
-		hackrf? ( net-wireless/soapyhackrf )
-		rtlsdr? ( net-wireless/soapyrtlsdr )
-		plutosdr? ( net-wireless/soapyplutosdr )
-		uhd? ( net-wireless/soapyuhd )"
 
-src_configure() {
-	configuration() {
-		mycmakeargs+=(
-			-DENABLE_PYTHON=ON
-			-DBUILD_PYTHON3=ON
-		)
-	}
+pkg_setup() {
+	use python && python-single-r1_pkg_setup
+}
 
-	if use python; then
-		python_foreach_impl configuration
-	fi
+src_configure() {
+	local mycmakeargs=(
+		-DENABLE_PYTHON3=$(usex python)
+	)
 
 	cmake_src_configure
 }
 
 src_install() {
 	cmake_src_install
-
-	if use python; then
-		python_foreach_impl python_optimize
-	fi
+	use python && python_optimize
 }


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-06-02  1:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-02  1:44 [gentoo-commits] repo/gentoo:master commit in: net-wireless/soapysdr/files/, net-wireless/soapysdr/ Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox