From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH 11/11] distutils-r1.eclass: Reflow distutils-r1_python_compile()
Date: Tue, 25 Mar 2025 21:16:16 +0100 [thread overview]
Message-ID: <20250325202258.261756-12-mgorny@gentoo.org> (raw)
In-Reply-To: <20250325202258.261756-1-mgorny@gentoo.org>
Reflow distutils-r1_python_compile() to remove duplicate conditions
and improve readability.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/distutils-r1.eclass | 117 ++++++++++++++++++-------------------
1 file changed, 56 insertions(+), 61 deletions(-)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index be61c49a8255..7a28644252ba 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1484,71 +1484,66 @@ distutils-r1_python_compile() {
_python_check_EPYTHON
- case ${DISTUTILS_USE_PEP517:-unset} in
- no)
- return
- ;;
- unset)
- # legacy mode
- _distutils-r1_copy_egg_info
- esetup.py build -j "$(makeopts_jobs "${MAKEOPTS} ${*}")" "${@}"
- ;;
- *)
- # we do this for all build systems, since other backends
- # and custom hooks may wrap setuptools
- #
- # we are appending a dynamic component so that
- # distutils-r1_python_compile can be called multiple
- # times and don't end up combining resulting packages
- mkdir -p "${BUILD_DIR}" || die
- local -x DIST_EXTRA_CONFIG="${BUILD_DIR}/extra-setup.cfg"
- cat > "${DIST_EXTRA_CONFIG}" <<-EOF || die
- [build]
- build_base = ${BUILD_DIR}/build${#DISTUTILS_WHEELS[@]}
-
- [build_ext]
- parallel = $(makeopts_jobs "${MAKEOPTS} ${*}")
- EOF
- ;;
- esac
+ [[ ${DISTUTILS_USE_PEP517} == no ]] && return
- if [[ ${DISTUTILS_USE_PEP517} ]]; then
- if [[ ${DISTUTILS_ALLOW_WHEEL_REUSE} ]]; then
- local whl
- for whl in "${!DISTUTILS_WHEELS[@]}"; do
- # use only wheels corresponding to the current directory
- if [[ ${PWD} != ${DISTUTILS_WHEELS["${whl}"]} ]]; then
- continue
- fi
+ if [[ ! ${DISTUTILS_USE_PEP517} ]]; then
+ # legacy mode
+ _distutils-r1_copy_egg_info
+ esetup.py build -j "$(makeopts_jobs "${MAKEOPTS} ${*}")" "${@}"
+ return
+ fi
- # 1. Use pure Python wheels only if we're not expected
- # to build extensions. Otherwise, we may end up
- # not building the extension at all when e.g. PyPy3
- # is built without one.
- #
- # 2. For CPython, we can reuse stable ABI wheels. Note
- # that this relies on the assumption that we're building
- # from the oldest to the newest implementation,
- # and the wheels are forward-compatible.
- if [[
- ( ! ${DISTUTILS_EXT} && ${whl} == *py3-none-any* ) ||
- (
- ${EPYTHON} == python* &&
- # freethreading does not support stable ABI
- # at the moment
- ${EPYTHON} != *t &&
- ${whl} == *-abi3-*
- )
- ]]; then
- distutils_wheel_install "${BUILD_DIR}/install" "${whl}"
- return
- fi
- done
- fi
+ # we do this for all build systems, since other backends
+ # and custom hooks may wrap setuptools
+ #
+ # we are appending a dynamic component so that
+ # distutils-r1_python_compile can be called multiple
+ # times and don't end up combining resulting packages
+ mkdir -p "${BUILD_DIR}" || die
+ local -x DIST_EXTRA_CONFIG="${BUILD_DIR}/extra-setup.cfg"
+ cat > "${DIST_EXTRA_CONFIG}" <<-EOF || die
+ [build]
+ build_base = ${BUILD_DIR}/build${#DISTUTILS_WHEELS[@]}
+
+ [build_ext]
+ parallel = $(makeopts_jobs "${MAKEOPTS} ${*}")
+ EOF
+
+ if [[ ${DISTUTILS_ALLOW_WHEEL_REUSE} ]]; then
+ local whl
+ for whl in "${!DISTUTILS_WHEELS[@]}"; do
+ # use only wheels corresponding to the current directory
+ if [[ ${PWD} != ${DISTUTILS_WHEELS["${whl}"]} ]]; then
+ continue
+ fi
- distutils_pep517_install "${BUILD_DIR}/install"
- DISTUTILS_WHEELS+=( "${DISTUTILS_WHEEL_PATH}" "${PWD}" )
+ # 1. Use pure Python wheels only if we're not expected
+ # to build extensions. Otherwise, we may end up
+ # not building the extension at all when e.g. PyPy3
+ # is built without one.
+ #
+ # 2. For CPython, we can reuse stable ABI wheels. Note
+ # that this relies on the assumption that we're building
+ # from the oldest to the newest implementation,
+ # and the wheels are forward-compatible.
+ if [[
+ ( ! ${DISTUTILS_EXT} && ${whl} == *py3-none-any* ) ||
+ (
+ ${EPYTHON} == python* &&
+ # freethreading does not support stable ABI
+ # at the moment
+ ${EPYTHON} != *t &&
+ ${whl} == *-abi3-*
+ )
+ ]]; then
+ distutils_wheel_install "${BUILD_DIR}/install" "${whl}"
+ return
+ fi
+ done
fi
+
+ distutils_pep517_install "${BUILD_DIR}/install"
+ DISTUTILS_WHEELS+=( "${DISTUTILS_WHEEL_PATH}" "${PWD}" )
}
# @FUNCTION: _distutils-r1_wrap_scripts
next prev parent reply other threads:[~2025-03-25 20:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-25 20:16 [gentoo-dev] [PATCH 00/11] distutils-r1.eclass: uv-build support, setuptools build dir fixes, PEP517 backend override support Michał Górny
2025-03-25 20:16 ` [gentoo-dev] [PATCH 01/11] distutils-r1.eclass: Bump build system lower bounds Michał Górny
2025-03-25 20:16 ` [gentoo-dev] [PATCH 02/11] distutils-r1.eclass: Set FLIT_ALLOW_INVALID Michał Górny
2025-03-25 20:16 ` [gentoo-dev] [PATCH 03/11] dev-python/uv-build: New package, v0.6.9 Michał Górny
2025-03-25 20:16 ` [gentoo-dev] [PATCH 04/11] distutils-r1.eclass: Support uv-build backend Michał Górny
2025-03-25 20:16 ` [gentoo-dev] [PATCH 05/11] distutils-r1.eclass: Support the legacy "uv" backend too Michał Górny
2025-03-25 20:16 ` [gentoo-dev] [PATCH 06/11] distutils-r1.eclass: Use unique setuptools build directories Michał Górny
2025-03-25 20:16 ` [gentoo-dev] [PATCH 07/11] distutils-r1.eclass: Reflow _distutils-r1_backend_to_key() Michał Górny
2025-03-25 20:16 ` [gentoo-dev] [PATCH 08/11] distutils-r1.eclass: Invert DISTUTILS_USE_PEP517 - backend mapping Michał Górny
2025-03-25 20:16 ` [gentoo-dev] [PATCH 09/11] distutils-r1.eclass: Support overriding PEP517 build backend Michał Górny
2025-03-25 20:16 ` [gentoo-dev] [PATCH 10/11] dev-python/uv-build: Use DISTUTILS_UPSTREAM_PEP517 Michał Górny
2025-03-25 20:16 ` Michał Górny [this message]
2025-03-26 8:27 ` [gentoo-dev] [PATCH 00/11] distutils-r1.eclass: uv-build support, setuptools build dir fixes, PEP517 backend override support Ulrich Müller
2025-03-26 8:30 ` Michał Górny
2025-03-26 8:37 ` Ulrich Müller
2025-03-26 8:41 ` Michał Górny
2025-03-26 11:34 ` [gentoo-dev] [PATCH 12/12] distutils-r1.eclass: Add a safety check for wheel install done Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250325202258.261756-12-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox