* [gentoo-dev] [PATCH 1/3] Introduce esetuppy setup.py wrapper.
[not found] <20121028165518.5f1afe4a@pomiocik.lan>
@ 2012-10-28 15:57 ` Michał Górny
2012-10-28 15:57 ` [gentoo-dev] [PATCH 2/3] Remove redundant 'cd ${BUILD_DIR}' Michał Górny
2012-10-28 15:57 ` [gentoo-dev] [PATCH 3/3] Support out-of-source builds Michał Górny
2 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2012-10-28 15:57 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
---
gx86/eclass/distutils-r1.eclass | 52 ++++++++++++++++++++++++++++++-----------
1 file changed, 39 insertions(+), 13 deletions(-)
diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 8dfe6bb..b991ab4 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -105,6 +105,38 @@ DEPEND=${PYTHON_DEPS}
# HTML_DOCS=( doc/html/ )
# @CODE
+# @ECLASS-VARIABLE: myesetuppyargs
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# An array containing options to be passed to setup.py.
+#
+# Example:
+# @CODE
+# python_configure_all() {
+# myesetuppyargs=( --enable-my-hidden-option )
+# }
+# @CODE
+
+# @FUNCTION: esetuppy
+# @USAGE: [<args>...]
+# @DESCRIPTION:
+# Run the setup.py using currently selected Python interpreter
+# (if ${PYTHON} is set; fallback 'python' otherwise). The setup.py will
+# be passed default command-line arguments, then ${myesetuppyargs[@]},
+# then any parameters passed to this command.
+#
+# This command will die on failure in EAPI 4 and newer, and just return
+# the exit code in earlier EAPIs.
+esetuppy() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ set -- "${PYTHON:-python}" setup.py \
+ "${myesetuppyargs[@]}" "${@}"
+
+ echo "${@}" >&2
+ "${@}" || die
+}
+
# @FUNCTION: distutils-r1_python_prepare_all
# @DESCRIPTION:
# The default python_prepare_all(). It applies the patches from PATCHES
@@ -147,16 +179,13 @@ distutils-r1_python_configure() {
# @FUNCTION: distutils-r1_python_compile
# @USAGE: [additional-args...]
# @DESCRIPTION:
-# The default python_compile(). Runs 'setup.py build' using the correct
-# Python implementation. Any parameters passed to this function will be
-# passed to setup.py.
+# The default python_compile(). Runs 'esetuppy build'. Any parameters
+# passed to this function will be passed to setup.py.
distutils-r1_python_compile() {
debug-print-function ${FUNCNAME} "${@}"
cd "${BUILD_DIR}" || die
- set -- "${PYTHON}" setup.py build "${@}"
- echo "${@}"
- "${@}" || die
+ esetuppy build "${@}"
}
# @FUNCTION: distutils-r1_python_test
@@ -198,10 +227,9 @@ distutils-r1_rename_scripts() {
# @FUNCTION: distutils-r1_python_install
# @USAGE: [additional-args...]
# @DESCRIPTION:
-# The default python_install(). Runs 'setup.py install' using
-# the correct Python implementation, and appending the optimization
-# flags. Then calls distutils-r1_rename_scripts. Any parameters passed
-# to this function will be passed to setup.py.
+# The default python_install(). Runs 'esetuppy install', appending
+# the optimization flags. Then calls distutils-r1_rename_scripts.
+# Any parameters passed to this function will be passed to setup.py.
distutils-r1_python_install() {
debug-print-function ${FUNCNAME} "${@}"
@@ -218,9 +246,7 @@ distutils-r1_python_install() {
unset PYTHONDONTWRITEBYTECODE
cd "${BUILD_DIR}" || die
- set -- "${PYTHON}" setup.py install "${flags[@]}" --root="${D}" "${@}"
- echo "${@}"
- "${@}" || die
+ esetuppy install "${flags[@]}" --root="${D}" "${@}"
distutils-r1_rename_scripts
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-dev] [PATCH 2/3] Remove redundant 'cd ${BUILD_DIR}'.
[not found] <20121028165518.5f1afe4a@pomiocik.lan>
2012-10-28 15:57 ` [gentoo-dev] [PATCH 1/3] Introduce esetuppy setup.py wrapper Michał Górny
@ 2012-10-28 15:57 ` Michał Górny
2012-10-28 15:57 ` [gentoo-dev] [PATCH 3/3] Support out-of-source builds Michał Górny
2 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2012-10-28 15:57 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
This is done in distutils-r1_run_phase anyway.
---
gx86/eclass/distutils-r1.eclass | 2 --
1 file changed, 2 deletions(-)
diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index b991ab4..6bec5bb 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -184,7 +184,6 @@ distutils-r1_python_configure() {
distutils-r1_python_compile() {
debug-print-function ${FUNCNAME} "${@}"
- cd "${BUILD_DIR}" || die
esetuppy build "${@}"
}
@@ -245,7 +244,6 @@ distutils-r1_python_install() {
unset PYTHONDONTWRITEBYTECODE
- cd "${BUILD_DIR}" || die
esetuppy install "${flags[@]}" --root="${D}" "${@}"
distutils-r1_rename_scripts
--
1.7.12.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-dev] [PATCH 3/3] Support out-of-source builds.
[not found] <20121028165518.5f1afe4a@pomiocik.lan>
2012-10-28 15:57 ` [gentoo-dev] [PATCH 1/3] Introduce esetuppy setup.py wrapper Michał Górny
2012-10-28 15:57 ` [gentoo-dev] [PATCH 2/3] Remove redundant 'cd ${BUILD_DIR}' Michał Górny
@ 2012-10-28 15:57 ` Michał Górny
2 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2012-10-28 15:57 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
---
gx86/eclass/distutils-r1.eclass | 50 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 6bec5bb..cce47a7 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -105,6 +105,22 @@ DEPEND=${PYTHON_DEPS}
# HTML_DOCS=( doc/html/ )
# @CODE
+# @ECLASS-VARIABLE: DISTUTILS_IN_SOURCE_BUILD
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-null value, in-source builds will be enabled.
+# If unset, the default is to use in-source builds when python_prepare()
+# is declared, and out-of-source builds otherwise.
+#
+# If in-source builds are used, the eclass will create a copy of package
+# sources for each Python implementation in python_prepare_all(),
+# and work on that copy afterwards.
+#
+# If out-of-source builds are used, the eclass will instead work
+# on the sources directly, prepending setup.py arguments with
+# 'build --build-base ${BUILD_DIR}' to enforce keeping & using built
+# files in the specific root.
+
# @ECLASS-VARIABLE: myesetuppyargs
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -130,7 +146,16 @@ DEPEND=${PYTHON_DEPS}
esetuppy() {
debug-print-function ${FUNCNAME} "${@}"
- set -- "${PYTHON:-python}" setup.py \
+ local args=()
+ if [[ ! ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
+ if [[ ! ${BUILD_DIR} ]]; then
+ die 'Out-of-source build requested, yet BUILD_DIR unset.'
+ fi
+
+ args+=( build --build-base "${BUILD_DIR}" )
+ fi
+
+ set -- "${PYTHON:-python}" setup.py "${args[@]}" \
"${myesetuppyargs[@]}" "${@}"
echo "${@}" >&2
@@ -152,8 +177,17 @@ distutils-r1_python_prepare_all() {
epatch_user
- # create source copies for each implementation
- python_copy_sources
+ # by default, use in-source build if python_prepare() is used
+ if [[ ! ${DISTUTILS_IN_SOURCE_BUILD+1} ]]; then
+ if declare -f python_prepare >/dev/null; then
+ DISTUTILS_IN_SOURCE_BUILD=1
+ fi
+ fi
+
+ if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
+ # create source copies for each implementation
+ python_copy_sources
+ fi
}
# @FUNCTION: distutils-r1_python_prepare
@@ -297,9 +331,15 @@ distutils-r1_python_install_all() {
distutils-r1_run_phase() {
debug-print-function ${FUNCNAME} "${@}"
- pushd "${BUILD_DIR}" &>/dev/null || die
+ if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
+ pushd "${BUILD_DIR}" &>/dev/null || die
+ fi
+
"${@}" || die "${1} failed."
- popd &>/dev/null || die
+
+ if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
+ popd &>/dev/null || die
+ fi
}
distutils-r1_src_prepare() {
--
1.7.12.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-28 15:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20121028165518.5f1afe4a@pomiocik.lan>
2012-10-28 15:57 ` [gentoo-dev] [PATCH 1/3] Introduce esetuppy setup.py wrapper Michał Górny
2012-10-28 15:57 ` [gentoo-dev] [PATCH 2/3] Remove redundant 'cd ${BUILD_DIR}' Michał Górny
2012-10-28 15:57 ` [gentoo-dev] [PATCH 3/3] Support out-of-source builds 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