commit:     7cbd714491bd8a138dad0cec791b8e8f104c29cc
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 27 10:09:49 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jan 28 23:01:23 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7cbd7144

distutils-r1.eclass: Support deprecated flit/poetry backends

Detect, report and fix the deprecated flit/poetry backends to use
flit_core and poetry_core respectively.  In both cases, the end result
is the same.  Using flit involves unnecessary dependencies, and poetry
is not even packaged right now (and has even worse dependency hell).

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/distutils-r1.eclass | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 7dfd92691b59..f7c6ea202ab0 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -862,13 +862,13 @@ _distutils-r1_backend_to_key() {
 
        local backend=${1}
        case ${backend} in
-               flit_core.buildapi)
+               flit_core.buildapi|flit.buildapi)
                        echo flit
                        ;;
                pdm.pep517.api)
                        echo pdm
                        ;;
-               poetry.core.masonry.api)
+               poetry.core.masonry.api|poetry.masonry.api)
                        echo poetry
                        ;;
                setuptools.build_meta|setuptools.build_meta:__legacy__)
@@ -950,6 +950,27 @@ distutils-r1_python_compile() {
                                eerror "(backend: ${build_backend})"
                                die "DISTUTILS_USE_PEP517 value incorrect"
                        fi
+
+                       # fix deprecated backends up
+                       local new_backend=
+                       case ${build_backend} in
+                               flit.buildapi)
+                                       new_backend=flit_core.buildapi
+                                       ;;
+                               poetry.masonry.api)
+                                       new_backend=poetry.core.masonry.api
+                                       ;;
+                       esac
+
+                       if [[ -n ${new_backend} ]]; then
+                               if [[ ! ${_DISTUTILS_DEPRECATED_BACKEND_WARNED} 
]]; then
+                                       eqawarn "${build_backend} backend is 
deprecated.  Please see:"
+                                       eqawarn 
"https://projects.gentoo.org/python/guide/distutils.html#deprecated-pep-517-backends";
+                                       eqawarn "The eclass will be using 
${new_backend} instead."
+                                       _DISTUTILS_DEPRECATED_BACKEND_WARNED=1
+                               fi
+                               build_backend=${new_backend}
+                       fi
                fi
 
                einfo "  Building the wheel via ${build_backend}"

Reply via email to