From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH 2/2] distutils-r1.eclass: Strip pkg_resources namespaces automatically
Date: Wed, 22 Feb 2023 19:20:40 +0100 [thread overview]
Message-ID: <20230222182040.1550296-2-mgorny@gentoo.org> (raw)
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/distutils-r1.eclass | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 426de7200957..9ef8342486b4 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1980,6 +1980,36 @@ distutils-r1_src_test() {
return ${ret}
}
+# @FUNCTION: _distutils-r1_strip_namespace_packages
+# @USAGE: <sitedir>
+# @INTERNAL
+# @DESCRIPTION:
+# Find and remove setuptools-style namespaces in the specified
+# directory.
+_distutils-r1_strip_namespace_packages() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local sitedir=${1}
+ local f ns had_any=
+ while IFS= read -r -d '' f; do
+ while read -r ns; do
+ einfo "Stripping pkg_resources-style namespace ${ns}"
+ had_any=1
+ done < "${f}"
+
+ rm "${f}" || die
+ done < <(
+ # NB: this deliberately does not include .egg-info, in order
+ # to limit this to PEP517 mode.
+ find "${sitedir}" -path '*.dist-info/namespace_packages.txt' -print0
+ )
+
+ # If we had any namespace packages, remove .pth files as well.
+ if [[ ${had_any} ]]; then
+ find "${sitedir}" -name '*-nspkg.pth' -delete || die
+ fi
+}
+
# @FUNCTION: _distutils-r1_post_python_install
# @INTERNAL
# @DESCRIPTION:
@@ -1990,6 +2020,8 @@ _distutils-r1_post_python_install() {
local sitedir=${D%/}$(python_get_sitedir)
if [[ -d ${sitedir} ]]; then
+ _distutils-r1_strip_namespace_packages "${sitedir}"
+
local forbidden_package_names=(
examples test tests
.pytest_cache .hypothesis _trial_temp
--
2.39.2
reply other threads:[~2023-02-22 18:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230222182040.1550296-2-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-dev@lists.gentoo.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