* [gentoo-python] [PATCH] Add distutils_install_for_testing().
@ 2013-02-09 15:35 Michał Górny
2013-02-09 15:54 ` [gentoo-python] " Mike Gilbert
0 siblings, 1 reply; 2+ messages in thread
From: Michał Górny @ 2013-02-09 15:35 UTC (permalink / raw
To: gentoo-python; +Cc: python, Michał Górny
This is a copy and rework of the crazy 'esetup.py install'
from logilab-common. A common function which can be used
in python_test() to obtain a working installation of almost
any distutils or setuptools package.
---
gx86/eclass/distutils-r1.eclass | 54 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 24589f0..963bdf9 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -239,6 +239,60 @@ esetup.py() {
"${@}" || die
}
+# @FUNCTION: distutils_install_for_testing
+# @USAGE: [<args>...]
+# @DESCRIPTION:
+# Install the package into a temporary location for running tests.
+# Update PYTHONPATH appropriately and set TEST_DIR to the test
+# installation root. The Python packages will be installed in 'lib'
+# subdir, and scripts in 'scripts' subdir (like in BUILD_DIR).
+#
+# Please note that this function should be only used if package uses
+# namespaces (and therefore proper install needs to be done to enforce
+# PYTHONPATH) or tests rely on the results of install command.
+# For most of the packages, tests built in BUILD_DIR are good enough.
+distutils_install_for_testing() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ # A few notes:
+ # 1) because of namespaces, we can't use 'install --root',
+ # 2) 'install --home' is terribly broken on pypy, so we need
+ # to override --install-lib and --install-scripts,
+ # 3) non-root 'install' complains about PYTHONPATH and missing dirs,
+ # so we need to set it properly and mkdir them,
+ # 4) it runs a bunch of commands which write random files to cwd,
+ # in order to avoid that, we need to run them ourselves to pass
+ # alternate build paths,
+ # 5) 'install' needs to go before 'bdist_egg' or the latter would
+ # re-set install paths.
+
+ if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
+ # use 'build' subdirectory to reduce the risk of collisions
+ local BUILD_DIR=${BUILD_DIR}/build
+ fi
+
+ TEST_DIR=${BUILD_DIR}/test
+ local bindir=${TEST_DIR}/scripts
+ local libdir=${TEST_DIR}/lib
+ PYTHONPATH=${libdir}:${PYTHONPATH}
+
+ local add_args=(
+ install
+ --home="${TEST_DIR}"
+ --install-lib="${libdir}"
+ --install-scripts="${bindir}"
+ )
+
+ if "${PYTHON:-python}" setup.py --help bdist_egg &>/dev/null; then
+ add_args+=(
+ bdist_egg --dist-dir="${TEST_DIR}"
+ )
+ fi
+
+ mkdir -p "${libdir}" || die
+ esetup.py "${add_args[@]}"
+}
+
# @FUNCTION: distutils-r1_python_prepare_all
# @DESCRIPTION:
# The default python_prepare_all(). It applies the patches from PATCHES
--
1.8.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-02-09 15:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-09 15:35 [gentoo-python] [PATCH] Add distutils_install_for_testing() Michał Górny
2013-02-09 15:54 ` [gentoo-python] " Mike Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox