Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 1/7] distutils-r1.eclass: Move venv creation to post-compile
Date: Tue, 07 Jun 2022 20:09:19
Message-Id: 20220607200840.4112-2-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/7] distutils-r1.eclass: DISTUTILS_USE_PEP517=no, take two by "Michał Górny"
1 ---
2 eclass/distutils-r1.eclass | 65 ++++++++++++++++++++++----------------
3 1 file changed, 38 insertions(+), 27 deletions(-)
4
5 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
6 index 7829e521ca7b..e5e11c75e39f 100644
7 --- a/eclass/distutils-r1.eclass
8 +++ b/eclass/distutils-r1.eclass
9 @@ -1370,33 +1370,7 @@ distutils-r1_python_compile() {
10 addpredict /usr/lib/portage/pym
11 addpredict /usr/local # bug 498232
12
13 - local root=${BUILD_DIR}/install
14 - distutils_pep517_install "${root}"
15 -
16 - # copy executables to python-exec directory
17 - # we do it early so that we can alter bindir recklessly
18 - local bindir=${root}${EPREFIX}/usr/bin
19 - local rscriptdir=${root}$(python_get_scriptdir)
20 - [[ -d ${rscriptdir} ]] &&
21 - die "${rscriptdir} should not exist!"
22 - if [[ -d ${bindir} ]]; then
23 - mkdir -p "${rscriptdir}" || die
24 - cp -a --reflink=auto "${bindir}"/. "${rscriptdir}"/ || die
25 - fi
26 -
27 - # enable venv magic inside the install tree
28 - mkdir -p "${bindir}" || die
29 - ln -s "${PYTHON}" "${bindir}/${EPYTHON}" || die
30 - ln -s "${EPYTHON}" "${bindir}/python3" || die
31 - ln -s "${EPYTHON}" "${bindir}/python" || die
32 - cat > "${bindir}"/pyvenv.cfg <<-EOF || die
33 - include-system-site-packages = true
34 - EOF
35 -
36 - # we need to change shebangs to point to the venv-python
37 - find "${bindir}" -type f -exec sed -i \
38 - -e "1s@^#!\(${EPREFIX}/usr/bin/\(python\|pypy\)\)@#!${root}\1@" \
39 - {} + || die
40 + distutils_pep517_install "${BUILD_DIR}/install"
41 fi
42 }
43
44 @@ -1775,6 +1749,43 @@ distutils-r1_src_configure() {
45 return ${ret}
46 }
47
48 +# @FUNCTION: _distutils-r1_post_python_compile
49 +# @INTERNAL
50 +# @DESCRIPTION:
51 +# Post-phase function called after python_compile. In PEP517 mode,
52 +# it adjusts the install tree for venv-style usage.
53 +_distutils-r1_post_python_compile() {
54 + debug-print-function ${FUNCNAME} "${@}"
55 +
56 + local root=${BUILD_DIR}/install
57 + if [[ ${DISTUTILS_USE_PEP517} && -d ${root} ]]; then
58 + # copy executables to python-exec directory
59 + # we do it early so that we can alter bindir recklessly
60 + local bindir=${root}${EPREFIX}/usr/bin
61 + local rscriptdir=${root}$(python_get_scriptdir)
62 + [[ -d ${rscriptdir} ]] &&
63 + die "${rscriptdir} should not exist!"
64 + if [[ -d ${bindir} ]]; then
65 + mkdir -p "${rscriptdir}" || die
66 + cp -a --reflink=auto "${bindir}"/. "${rscriptdir}"/ || die
67 + fi
68 +
69 + # enable venv magic inside the install tree
70 + mkdir -p "${bindir}" || die
71 + ln -s "${PYTHON}" "${bindir}/${EPYTHON}" || die
72 + ln -s "${EPYTHON}" "${bindir}/python3" || die
73 + ln -s "${EPYTHON}" "${bindir}/python" || die
74 + cat > "${bindir}"/pyvenv.cfg <<-EOF || die
75 + include-system-site-packages = true
76 + EOF
77 +
78 + # we need to change shebangs to point to the venv-python
79 + find "${bindir}" -type f -exec sed -i \
80 + -e "1s@^#!\(${EPREFIX}/usr/bin/\(python\|pypy\)\)@#!${root}\1@" \
81 + {} + || die
82 + fi
83 +}
84 +
85 distutils-r1_src_compile() {
86 debug-print-function ${FUNCNAME} "${@}"
87 local ret=0
88 --
89 2.35.1