* [gentoo-dev] [PATCH 1/3] distutils-r1.eclass: Introduce dift --via-venv install mode
@ 2021-05-21 14:20 Michał Górny
2021-05-21 14:20 ` [gentoo-dev] [PATCH 2/3] dev-python/werkzeug: Reuse dift --via-venv Michał Górny
2021-05-21 14:20 ` [gentoo-dev] [PATCH 3/3] dev-python/tox: Use dift --via-venv to unbreak two tests Michał Górny
0 siblings, 2 replies; 3+ messages in thread
From: Michał Górny @ 2021-05-21 14:20 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/distutils-r1.eclass | 96 ++++++++++++++++++++++++--------------
1 file changed, 62 insertions(+), 34 deletions(-)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index a02b6d059bd1..5412de8aba29 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -481,7 +481,7 @@ esetup.py() {
}
# @FUNCTION: distutils_install_for_testing
-# @USAGE: [--via-root|--via-home] [<args>...]
+# @USAGE: [--via-root|--via-home|--via-venv] [<args>...]
# @DESCRIPTION:
# Install the package into a temporary location for running tests.
# Update PYTHONPATH appropriately and set TEST_DIR to the test
@@ -493,32 +493,36 @@ esetup.py() {
# PYTHONPATH) or tests rely on the results of install command.
# For most of the packages, tests built in BUILD_DIR are good enough.
#
-# The function supports two install modes. The current default is
-# --via-root mode. Previously, the function defaulted to --via-home
-# mode but it has been broken by new versions of setuptools (50.3.0+).
-# If you find that --via-root does not work but --via-home does, please
-# file a bug to let us know. Please note that proper testing sometimes
-# requires unmerging the package first.
+# The function supports three install modes. These are:
+#
+# --via-root (the default) that uses 'setup.py install --root=...'
+# combined with PYTHONPATH and is recommended for the majority
+# of packages.
+#
+# --via-venv that creates a (non-isolated) venv and installs the package
+# into it via 'setup.py install'. This mode does not use PYTHONPATH
+# but requires python to be called via PATH. It may solve a few corner
+# cases that --via-root does not support.
+#
+# --via-home that uses 'setup.py install --home=...'. This is
+# a historical mode that was mostly broken by setuptools 50.3.0+.
+# If your package does not work with the other two modes but works with
+# this one, please report a bug.
+#
+# Please note that in order to test the solution properly you need
+# to unmerge the package first.
distutils_install_for_testing() {
debug-print-function ${FUNCNAME} "${@}"
- # A few notes:
- # 1) because of namespaces, we can't use 'install --root'
- # (NB: this is probably no longer true with py3),
- # 2) 'install --home' is terribly broken on pypy, so we need
+ # A few notes about --via-home mode:
+ # 1) '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,
+ # 2) 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,
+ # 3) it runs a bunch of commands which write random files to cwd,
# in order to avoid that, we add the necessary path overrides
# in _distutils-r1_create_setup_cfg.
- TEST_DIR=${BUILD_DIR}/test
- local bindir=${TEST_DIR}/scripts
- local libdir=${TEST_DIR}/lib
- PATH=${bindir}:${PATH}
- PYTHONPATH=${libdir}:${PYTHONPATH}
-
local install_method=root
case ${1} in
--via-home)
@@ -529,30 +533,50 @@ distutils_install_for_testing() {
install_method=root
shift
;;
+ --via-venv)
+ install_method=venv
+ shift
+ ;;
esac
- local -a add_args
- case ${install_method} in
- home)
- add_args=(
- install
+ TEST_DIR=${BUILD_DIR}/test
+ local add_args=()
+
+ if [[ ${install_method} == venv ]]; then
+ "${EPYTHON}" -m venv --system-site-packages --without-pip \
+ "${TEST_DIR}" || die
+
+ # we only do the minimal necessary subset of activate script
+ PATH=${TEST_DIR}/bin:${PATH}
+ # unset PYTHONPATH in order to prevent BUILD_DIR from overriding
+ # venv packages
+ unset PYTHONPATH
+ else
+ local bindir=${TEST_DIR}/scripts
+ local libdir=${TEST_DIR}/lib
+ PATH=${bindir}:${PATH}
+ PYTHONPATH=${libdir}:${PYTHONPATH}
+
+ case ${install_method} in
+ home)
+ add_args=(
--home="${TEST_DIR}"
--install-lib="${libdir}"
--install-scripts="${bindir}"
- )
- mkdir -p "${libdir}" || die
- ;;
- root)
- add_args=(
- install
+ )
+ mkdir -p "${libdir}" || die
+ ;;
+ root)
+ add_args=(
--root="${TEST_DIR}"
--install-lib=lib
--install-scripts=scripts
- )
- ;;
- esac
+ )
+ ;;
+ esac
+ fi
- esetup.py "${add_args[@]}" "${@}"
+ esetup.py install "${add_args[@]}" "${@}"
}
# @FUNCTION: _distutils-r1_disable_ez_setup
@@ -646,6 +670,10 @@ _distutils-r1_create_setup_cfg() {
# setuptools like to create .egg files for install --home.
[bdist_egg]
dist_dir = ${BUILD_DIR}/dist
+
+ # avoid packing up eggs in a zip as it often breaks test suites
+ [options]
+ zip_safe = False
_EOF_
# we can't refer to ${D} before src_install()
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-dev] [PATCH 2/3] dev-python/werkzeug: Reuse dift --via-venv
2021-05-21 14:20 [gentoo-dev] [PATCH 1/3] distutils-r1.eclass: Introduce dift --via-venv install mode Michał Górny
@ 2021-05-21 14:20 ` Michał Górny
2021-05-21 14:20 ` [gentoo-dev] [PATCH 3/3] dev-python/tox: Use dift --via-venv to unbreak two tests Michał Górny
1 sibling, 0 replies; 3+ messages in thread
From: Michał Górny @ 2021-05-21 14:20 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
dev-python/werkzeug/werkzeug-2.0.1-r1.ebuild | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/dev-python/werkzeug/werkzeug-2.0.1-r1.ebuild b/dev-python/werkzeug/werkzeug-2.0.1-r1.ebuild
index 76e9a1859dab..0b427de76130 100644
--- a/dev-python/werkzeug/werkzeug-2.0.1-r1.ebuild
+++ b/dev-python/werkzeug/werkzeug-2.0.1-r1.ebuild
@@ -39,18 +39,8 @@ PATCHES=(
"${FILESDIR}"/${P}-py310.patch
)
-src_prepare() {
- distutils-r1_src_prepare
- # prevent esetup.py install from zipping the egg
- sed -i -e '/\[options\]/azip_safe = False' setup.cfg || die
-}
-
python_test() {
- "${EPYTHON}" -m venv --system-site-packages --without-pip \
- "${BUILD_DIR}"/venv || die
- local -x PATH=${BUILD_DIR}/venv/bin:${PATH}
- unset PYTHONPATH
- esetup.py install
+ distutils_install_for_testing --via-venv
# the default portage tempdir is too long for AF_UNIX sockets
local -x TMPDIR=/tmp
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-dev] [PATCH 3/3] dev-python/tox: Use dift --via-venv to unbreak two tests
2021-05-21 14:20 [gentoo-dev] [PATCH 1/3] distutils-r1.eclass: Introduce dift --via-venv install mode Michał Górny
2021-05-21 14:20 ` [gentoo-dev] [PATCH 2/3] dev-python/werkzeug: Reuse dift --via-venv Michał Górny
@ 2021-05-21 14:20 ` Michał Górny
1 sibling, 0 replies; 3+ messages in thread
From: Michał Górny @ 2021-05-21 14:20 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
dev-python/tox/tox-3.23.1.ebuild | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/dev-python/tox/tox-3.23.1.ebuild b/dev-python/tox/tox-3.23.1.ebuild
index 938612131f77..2d37d0a62479 100644
--- a/dev-python/tox/tox-3.23.1.ebuild
+++ b/dev-python/tox/tox-3.23.1.ebuild
@@ -53,11 +53,6 @@ python_test() {
# expects python2 to exist
tests/unit/interpreters/test_interpreters.py::test_tox_get_python_executable
-
- # broken without tox installed first
- # TODO: figure out how to make importlib_metadata work
- tests/unit/test_z_cmdline.py::test_tox_console_script
- tests/unit/test_z_cmdline.py::test_tox_quickstart_script
)
[[ ${EPYTHON} != pypy3 ]] && deselect+=(
@@ -69,6 +64,6 @@ python_test() {
tests/integration/test_parallel_interrupt.py::test_parallel_interrupt
)
- distutils_install_for_testing --via-root
+ distutils_install_for_testing --via-venv
epytest --no-network ${deselect[@]/#/--deselect }
}
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-21 14:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-21 14:20 [gentoo-dev] [PATCH 1/3] distutils-r1.eclass: Introduce dift --via-venv install mode Michał Górny
2021-05-21 14:20 ` [gentoo-dev] [PATCH 2/3] dev-python/werkzeug: Reuse dift --via-venv Michał Górny
2021-05-21 14:20 ` [gentoo-dev] [PATCH 3/3] dev-python/tox: Use dift --via-venv to unbreak two tests 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