public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] distutils-r1.eclass: Warn if *-nspkg.pth files are installed
@ 2017-05-05 21:14 Michał Górny
  2017-05-05 21:19 ` M. J. Everitt
  2017-05-16 17:19 ` Michał Górny
  0 siblings, 2 replies; 3+ messages in thread
From: Michał Górny @ 2017-05-05 21:14 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Add a check for *-nspkg.pth files indicating implicit setuptools
namespace hack. While they kept namespaces somewhat working without
requiring explicit support in ebuilds, they were unreliable. They
frequently required additional hacks (distutils_install_for_testing) to
get the tests working, and they have proven even more broken for Python
3.5+.

For this reason, those files were deprecated in favor of proper,
explicit namespace support. If they are found to exist, the developer
should ensure to remove them to avoid issues.
---
 eclass/distutils-r1.eclass | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

**REVIEW NOTE**

The wiki documentation update is not yet in place for the new policy
is not yet in place. In fact, it's not even guaranteed that the policy
will actually be approved. The discussion is taking place here:

https://archives.gentoo.org/gentoo-python/message/d74af64a795cb776ac7b4f285963072d

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 3be67bbf2a21..5df7234332d3 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -789,6 +789,33 @@ distutils-r1_src_test() {
 	fi
 }
 
+# @FUNCTION: _distutils-r1_check_namespace_pth
+# @INTERNAL
+# @DESCRIPTION:
+# Check if any *-nspkg.pth files were installed (by setuptools)
+# and warn about the policy non-conformance if they were.
+_distutils-r1_check_namespace_pth() {
+	local f pth=()
+
+	while IFS= read -r -d '' f; do
+		pth+=( "${f}" )
+	done < <(find "${ED}" -name '*-nspkg.pth' -print0)
+
+	if [[ ${pth[@]} ]]; then
+		ewarn "The following *-nspkg.pth files were found installed:"
+		ewarn
+		for f in "${pth[@]}"; do
+			ewarn "  ${f#${ED%/}}"
+		done
+		ewarn
+		ewarn "The presence of those files may break namespaces in Python 3.5+. Please"
+		ewarn "read our documentation on reliable handling of namespaces and update"
+		ewarn "the ebuild accordingly:"
+		ewarn
+		ewarn "  https://wiki.gentoo.org/wiki/Project:Python/Namespace_packages"
+	fi
+}
+
 distutils-r1_src_install() {
 	debug-print-function ${FUNCNAME} "${@}"
 
@@ -812,6 +839,8 @@ distutils-r1_src_install() {
 
 		"${cmd}" "QA: python_install_all() didn't call distutils-r1_python_install_all"
 	fi
+
+	_distutils-r1_check_namespace_pth
 }
 
 # -- distutils.eclass functions --
-- 
2.13.0.rc1



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

* Re: [gentoo-dev] [PATCH] distutils-r1.eclass: Warn if *-nspkg.pth files are installed
  2017-05-05 21:14 [gentoo-dev] [PATCH] distutils-r1.eclass: Warn if *-nspkg.pth files are installed Michał Górny
@ 2017-05-05 21:19 ` M. J. Everitt
  2017-05-16 17:19 ` Michał Górny
  1 sibling, 0 replies; 3+ messages in thread
From: M. J. Everitt @ 2017-05-05 21:19 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny


[-- Attachment #1.1: Type: text/plain, Size: 2666 bytes --]

On 05/05/17 22:14, Michał Górny wrote:
> Add a check for *-nspkg.pth files indicating implicit setuptools
> namespace hack. While they kept namespaces somewhat working without
> requiring explicit support in ebuilds, they were unreliable. They
> frequently required additional hacks (distutils_install_for_testing) to
> get the tests working, and they have proven even more broken for Python
> 3.5+.
>
> For this reason, those files were deprecated in favor of proper,
> explicit namespace support. If they are found to exist, the developer
> should ensure to remove them to avoid issues.
> ---
>  eclass/distutils-r1.eclass | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>
> **REVIEW NOTE**
>
> The wiki documentation update is not yet in place for the new policy
> is not yet in place. In fact, it's not even guaranteed that the policy
> will actually be approved. The discussion is taking place here:

The wiki documentation update is not yet in place for the new policy
is not yet in place. ???

Copy-pasta, sir .. :]

> https://archives.gentoo.org/gentoo-python/message/d74af64a795cb776ac7b4f285963072d
>
> diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
> index 3be67bbf2a21..5df7234332d3 100644
> --- a/eclass/distutils-r1.eclass
> +++ b/eclass/distutils-r1.eclass
> @@ -789,6 +789,33 @@ distutils-r1_src_test() {
>  	fi
>  }
>  
> +# @FUNCTION: _distutils-r1_check_namespace_pth
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Check if any *-nspkg.pth files were installed (by setuptools)
> +# and warn about the policy non-conformance if they were.
> +_distutils-r1_check_namespace_pth() {
> +	local f pth=()
> +
> +	while IFS= read -r -d '' f; do
> +		pth+=( "${f}" )
> +	done < <(find "${ED}" -name '*-nspkg.pth' -print0)
> +
> +	if [[ ${pth[@]} ]]; then
> +		ewarn "The following *-nspkg.pth files were found installed:"
> +		ewarn
> +		for f in "${pth[@]}"; do
> +			ewarn "  ${f#${ED%/}}"
> +		done
> +		ewarn
> +		ewarn "The presence of those files may break namespaces in Python 3.5+. Please"
> +		ewarn "read our documentation on reliable handling of namespaces and update"
> +		ewarn "the ebuild accordingly:"
> +		ewarn
> +		ewarn "  https://wiki.gentoo.org/wiki/Project:Python/Namespace_packages"
> +	fi
> +}
> +
>  distutils-r1_src_install() {
>  	debug-print-function ${FUNCNAME} "${@}"
>  
> @@ -812,6 +839,8 @@ distutils-r1_src_install() {
>  
>  		"${cmd}" "QA: python_install_all() didn't call distutils-r1_python_install_all"
>  	fi
> +
> +	_distutils-r1_check_namespace_pth
>  }
>  
>  # -- distutils.eclass functions --



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [gentoo-dev] [PATCH] distutils-r1.eclass: Warn if *-nspkg.pth files are installed
  2017-05-05 21:14 [gentoo-dev] [PATCH] distutils-r1.eclass: Warn if *-nspkg.pth files are installed Michał Górny
  2017-05-05 21:19 ` M. J. Everitt
@ 2017-05-16 17:19 ` Michał Górny
  1 sibling, 0 replies; 3+ messages in thread
From: Michał Górny @ 2017-05-16 17:19 UTC (permalink / raw
  To: gentoo-dev

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

On pią, 2017-05-05 at 23:14 +0200, Michał Górny wrote:
> Add a check for *-nspkg.pth files indicating implicit setuptools
> namespace hack. While they kept namespaces somewhat working without
> requiring explicit support in ebuilds, they were unreliable. They
> frequently required additional hacks (distutils_install_for_testing) to
> get the tests working, and they have proven even more broken for Python
> 3.5+.
> 
> For this reason, those files were deprecated in favor of proper,
> explicit namespace support. If they are found to exist, the developer
> should ensure to remove them to avoid issues.
> ---
>  eclass/distutils-r1.eclass | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> **REVIEW NOTE**
> 
> The wiki documentation update is not yet in place for the new policy
> is not yet in place. In fact, it's not even guaranteed that the policy
> will actually be approved. The discussion is taking place here:
> 
> https://archives.gentoo.org/gentoo-python/message/d74af64a795cb776ac7b4f285963072d
> 
> diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
> index 3be67bbf2a21..5df7234332d3 100644
> --- a/eclass/distutils-r1.eclass
> +++ b/eclass/distutils-r1.eclass
> @@ -789,6 +789,33 @@ distutils-r1_src_test() {
>  	fi
>  }
>  
> +# @FUNCTION: _distutils-r1_check_namespace_pth
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Check if any *-nspkg.pth files were installed (by setuptools)
> +# and warn about the policy non-conformance if they were.
> +_distutils-r1_check_namespace_pth() {
> +	local f pth=()
> +
> +	while IFS= read -r -d '' f; do
> +		pth+=( "${f}" )
> +	done < <(find "${ED}" -name '*-nspkg.pth' -print0)
> +
> +	if [[ ${pth[@]} ]]; then
> +		ewarn "The following *-nspkg.pth files were found installed:"
> +		ewarn
> +		for f in "${pth[@]}"; do
> +			ewarn "  ${f#${ED%/}}"
> +		done
> +		ewarn
> +		ewarn "The presence of those files may break namespaces in Python 3.5+. Please"
> +		ewarn "read our documentation on reliable handling of namespaces and update"
> +		ewarn "the ebuild accordingly:"
> +		ewarn
> +		ewarn "  https://wiki.gentoo.org/wiki/Project:Python/Namespace_packages"
> +	fi
> +}
> +
>  distutils-r1_src_install() {
>  	debug-print-function ${FUNCNAME} "${@}"
>  
> @@ -812,6 +839,8 @@ distutils-r1_src_install() {
>  
>  		"${cmd}" "QA: python_install_all() didn't call distutils-r1_python_install_all"
>  	fi
> +
> +	_distutils-r1_check_namespace_pth
>  }
>  
>  # -- distutils.eclass functions --

Committed.

-- 
Best regards,
Michał Górny

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 963 bytes --]

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

end of thread, other threads:[~2017-05-16 17:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-05 21:14 [gentoo-dev] [PATCH] distutils-r1.eclass: Warn if *-nspkg.pth files are installed Michał Górny
2017-05-05 21:19 ` M. J. Everitt
2017-05-16 17:19 ` 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