diff options
author | Michał Górny <mgorny@gentoo.org> | 2022-02-04 22:30:56 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2022-02-09 09:43:52 +0100 |
commit | 5eed1a007f6274c7560d980c200469c5732b192b (patch) | |
tree | 73d9a3fd08e0a31a624cf2d775e19d89208d1faf /eclass/distutils-r1.eclass | |
parent | python-single-r1.eclass: Remove PYTHON_MULTI_USEDEP (diff) | |
download | gentoo-5eed1a007f6274c7560d980c200469c5732b192b.tar.gz gentoo-5eed1a007f6274c7560d980c200469c5732b192b.tar.bz2 gentoo-5eed1a007f6274c7560d980c200469c5732b192b.zip |
distutils-r1.eclass: Use heredoc instead of "python -c"
Use heredocs instead of inlining longish scripts in "python -c",
for greater readability. Thanks to arthurzam for the suggestion.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/distutils-r1.eclass')
-rw-r--r-- | eclass/distutils-r1.eclass | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index b4bbb7d67e04..a1b840d9cc68 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -936,9 +936,13 @@ _distutils-r1_get_backend() { if [[ -f pyproject.toml ]]; then # if pyproject.toml exists, try getting the backend from it # NB: this could fail if pyproject.toml doesn't list one - build_backend=$("${EPYTHON}" -c 'import tomli; \ - print(tomli.load(open("pyproject.toml", "rb")) \ - ["build-system"]["build-backend"])' 2>/dev/null) + build_backend=$( + "${EPYTHON}" - <<-EOF 2>/dev/null + import tomli + print(tomli.load(open("pyproject.toml", "rb")) + ["build-system"]["build-backend"]) + EOF + ) fi if [[ -z ${build_backend} && ${DISTUTILS_USE_PEP517} == setuptools && -f setup.py ]] @@ -1004,10 +1008,14 @@ distutils_pep517_install() { local build_backend=$(_distutils-r1_get_backend) einfo " Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}" - local wheel=$("${EPYTHON}" -c "import ${build_backend%:*}; \ - import os; \ - print(${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR']), - file=os.fdopen(3, 'w'))" 3>&1 >&2 || die "Wheel build failed") + local wheel=$( + "${EPYTHON}" - 3>&1 >&2 <<-EOF || die "Wheel build failed" + import ${build_backend%:*} + import os + print(${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR']), + file=os.fdopen(3, 'w')) + EOF + ) [[ -n ${wheel} ]] || die "No wheel name returned" einfo " Installing the wheel to ${root}" @@ -1017,9 +1025,13 @@ distutils_pep517_install() { # NB: we override sys.prefix & sys.exec_prefix because otherwise # installer would use virtualenv's prefix local -x PYTHON_PREFIX=${EPREFIX}/usr - "${EPYTHON}" -c 'import os, sys; sys.prefix = sys.exec_prefix = os.environ["PYTHON_PREFIX"]; from installer.__main__ import main; main(sys.argv[1:])' \ - -d "${root}" "${WHEEL_BUILD_DIR}/${wheel}" --no-compile-bytecode || - die "installer failed" + "${EPYTHON}" - -d "${root}" "${WHEEL_BUILD_DIR}/${wheel}" --no-compile-bytecode \ + <<-EOF || die "installer failed" + import os, sys + sys.prefix = sys.exec_prefix = os.environ["PYTHON_PREFIX"] + from installer.__main__ import main + main(sys.argv[1:]) + EOF # remove installed licenses find "${root}$(python_get_sitedir)" \ |