* [gentoo-dev] [PATCH 1/2] distutils-r1.eclass: Fix disabling DISTUTILS_ALLOW_WHEEL_REUSE
@ 2024-08-02 19:31 Michał Górny
2024-08-02 19:31 ` [gentoo-dev] [PATCH 2/2] python-utils-r1.eclass: Add a sanity check for PYTHONPATH Michał Górny
0 siblings, 1 reply; 2+ messages in thread
From: Michał Górny @ 2024-08-02 19:31 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Fix the declaration of DISTUTILS_ALLOW_WHEEL_REUSE to allow disabling it
via setting the variable to an empty value in the environment.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/distutils-r1.eclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index fa8edb5cdfb7..4afee3d45b1c 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -204,7 +204,7 @@ esac
# This is an optimization that can avoid the overhead of calling into
# the build system in pure Python packages and packages using the stable
# Python ABI.
-DISTUTILS_ALLOW_WHEEL_REUSE=1
+: ${DISTUTILS_ALLOW_WHEEL_REUSE=1}
# @ECLASS_VARIABLE: BUILD_DIR
# @OUTPUT_VARIABLE
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-dev] [PATCH 2/2] python-utils-r1.eclass: Add a sanity check for PYTHONPATH
2024-08-02 19:31 [gentoo-dev] [PATCH 1/2] distutils-r1.eclass: Fix disabling DISTUTILS_ALLOW_WHEEL_REUSE Michał Górny
@ 2024-08-02 19:31 ` Michał Górny
0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2024-08-02 19:31 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Add a sanity check that ensures that PYTHONPATH does not contain any
relative paths. While at it, also explicitly warn about PYTHONPATH
being set, so we know about it in build logs.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/distutils-r1.eclass | 1 +
eclass/python-any-r1.eclass | 1 +
eclass/python-r1.eclass | 2 ++
eclass/python-single-r1.eclass | 1 +
eclass/python-utils-r1.eclass | 34 ++++++++++++++++++++++++++++++++++
5 files changed, 39 insertions(+)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 4afee3d45b1c..5d9f97474b29 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -936,6 +936,7 @@ _distutils-r1_print_package_versions() {
# distutils patches and/or quirks.
distutils-r1_python_prepare_all() {
debug-print-function ${FUNCNAME} "${@}"
+ _python_sanity_checks
_distutils-r1_check_all_phase_mismatch
if [[ ! ${DISTUTILS_OPTIONAL} ]]; then
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index a21df8e89498..65fffb798003 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -272,6 +272,7 @@ python_gen_any_dep() {
# This function will call python_check_deps() if defined.
python_setup() {
debug-print-function ${FUNCNAME} "${@}"
+ _python_sanity_checks
# support developer override
if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index c5fa6770558f..adf87c2c52f7 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -617,6 +617,7 @@ _python_multibuild_wrapper() {
# locally, and the former two are exported to the command environment.
python_foreach_impl() {
debug-print-function ${FUNCNAME} "${@}"
+ _python_sanity_checks
if [[ ${_DISTUTILS_R1_ECLASS} ]]; then
if has "${EBUILD_PHASE}" prepare configure compile test install &&
@@ -708,6 +709,7 @@ python_foreach_impl() {
# @CODE
python_setup() {
debug-print-function ${FUNCNAME} "${@}"
+ _python_sanity_checks
local has_check_deps
declare -f python_check_deps >/dev/null && has_check_deps=1
diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 4d61f08c06f0..337404df1681 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -393,6 +393,7 @@ python_gen_impl_dep() {
# the Python build environment up for it.
python_setup() {
debug-print-function ${FUNCNAME} "${@}"
+ _python_sanity_checks
unset EPYTHON
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index c47565fa1db2..cc33a1c1bffd 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1544,4 +1544,38 @@ python_has_version() {
return 0
}
+# @FUNCTION: _python_sanity_checks
+# @INTERNAL
+# @DESCRIPTION:
+# Perform additional environment sanity checks.
+_python_sanity_checks() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ [[ ${_PYTHON_SANITY_CHECKED} ]] && return
+
+ if [[ -v PYTHONPATH ]]; then
+ local x paths=()
+ mapfile -d ':' -t paths <<<${PYTHONPATH}
+
+ for x in "${paths[@]}"; do
+ if [[ ${x} != /* ]]; then
+ eerror "Relative path found in PYTHONPATH:"
+ eerror
+ eerror " PYTHONPATH=${PYTHONPATH@Q}"
+ eerror
+ eerror "This is guaranteed to cause random breakage. Please make sure that"
+ eerror "your PYTHONPATH contains absolute paths only (and only if necessary)."
+ eerror "Note that empty values (including ':' at either end and an empty"
+ eerror "PYTHONPATH) count as the current directory. If no PYTHONPATH"
+ eerror "is intended, it needs to be unset instead."
+ die "Relative paths in PYTHONPATH are forbidden: ${x@Q}"
+ fi
+ done
+
+ elog "PYTHONPATH=${PYTHONPATH@Q}"
+ fi
+
+ _PYTHON_SANITY_CHECKED=1
+}
+
fi
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-02 19:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-02 19:31 [gentoo-dev] [PATCH 1/2] distutils-r1.eclass: Fix disabling DISTUTILS_ALLOW_WHEEL_REUSE Michał Górny
2024-08-02 19:31 ` [gentoo-dev] [PATCH 2/2] python-utils-r1.eclass: Add a sanity check for PYTHONPATH Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox