Commit Graph
148 Commits
Author SHA1 Message Date
Ulrich Müller d7317785d0 *.eclass: @ECLASS-VARIABLE renamed to @ECLASS_VARIABLE
Bug: https://bugs.gentoo.org/835396
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
2022-03-24 04:58:34 +01:00
Michał Górny 9e323d64b3 python-utils-r1.eclass: Add a verbose python_has_version() wrapper
Add a python_has_version() wrapper for convenient use
in python_check_deps().  It includes:

- verbose output
- default "-b" root that's more suitable for build-time checks
- forward compatibility for -b/-d/-r arguments in EAPI 6

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-15 20:12:31 +01:00
Michał Górny cf8296ef1b python-utils-r1.eclass: Silence missing locale(1) error
The python_export_utf8_locale() function checks for missing locale(1)
and handles it gracefully.  However, it does not redirect stderr
probably, so systems without the executable (e.g. musl) get unintended
console output.  Redirect it to /dev/null.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:44:47 +01:00
Michał Górny ddd9cd63e8 python-utils-r1.eclass: Add QA check for obsolete PYTHON_COMPAT
Add a QA check that reports obsolete implementation in PYTHON_COMPAT
if ebuild has been modified in 2022 (based on copyright year).
Requested by sam.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:57 +01:00
Michał Górny ae26acc232 python-utils-r1.eclass: Support matching impls by stdlib version
Update _python_impl_matches() (used to implement python_gen*,
python_setup) to support specifying stdlib versions ("3.8", "3.9")
in addition to exact implementation names.  This makes handling PyPy3
version changes much easier when dealing with backports.

For example, if you specify "3.8", then the spec will match python3_8
and pypy3, for as long as we supply PyPy3.8.  Once we upgrade to PyPy3.9
completely, it will stop matching pypy3 and we won't have to manually
keep updating these deps.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:55 +01:00
Michał Górny 0cc9d3cc4f python-utils-r1.eclass: Add status messages to python_optimize
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:55 +01:00
Michał Górny 7dfd276145 python-utils-r1.eclass: Remove old phase check from python_optimize
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:54 +01:00
Michał Górny 3445afea17 python-utils-r1.eclass: Use heredoc instead of "python -c"
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:53 +01:00
Michał Górny beda1fe93a python-utils-r1.eclass: Remove python_is_python3
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:51 +01:00
Michał Górny ae1762f85b python-utils-r1.eclass: Remove python_wrapper_setup
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:49 +01:00
Michał Górny 2e00253a6a python-utils-r1.eclass: Remove deprecated python_export
Remove python_export, as it is no longer used by any ebuilds
in ::gentoo.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:48 +01:00
Michał Górny c14accfbbd python-utils-r1.eclass: Fix sphinx_build for non-autodoc case
Fix the regression in calling sphinx-build for the non-autodoc case
that causes the build to fail if dev-python/sphinx isn't built
for the newest Python interpreter available.  To account for this,
we need to call sphinx-build as an executable (i.e. via python-exec).

Ideally, build_sphinx would be aware of which case it is used for,
and use appropriate invocation.  Unfortunately, we cannot do that
without breaking backwards compatibility.  However, we can simply check
if Sphinx is available via ${EPYTHON}, and fall back to calling
python-exec directly.  This is effectively equivalent to choosing
the specific invocation directly, as python-exec would have respected
the implementation specified by EPYTHON anyway if sphinx-build
executable was available for it.

Fixes: f6a17acb8b (...: Run sphinx-build via EPYTHON)
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:47 +01:00
Michał Górny bcf57dbbf5 python-utils-r1.eclass: Inline python_is_installed
Inline the python_is_installed function that is used exactly once
(in _python_run_check_deps).  This helps us avoid having to grab
PYTHON_PKG_DEP twice.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:46 +01:00
Michał Górny 950d2685fb python-utils-r1.eclass: Report _python_run_check_deps verbosely
Report dep checking progress verbosely, to help users understand why
a particular implementations was rejected or selected.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:45 +01:00
Michał Górny d918d2e7cb python-utils-r1.eclass: Add function to run python_check_deps()
Add a function encompassing the common logic to run python_check_deps()
from python-any-r1 and python-r1.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-02-09 09:43:43 +01:00
Michał Górny 812520903e eclass: Update links to Gentoo Python Guide
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-01-29 00:01:23 +01:00
Michał Górny f10588909c python-utils-r1.eclass: Make epytest disable plugins we don't want
Make epytest explicitly disable unwanted plugins such as pytest-cov
or pytest-flakes.  We want the relevant options to be stripped out
of pytest config files.  However, when these packages are installed
on the system, it's easy to miss them and then users (or tinderboxes)
hit the failures first.  Disabling the plugins explicitly forces
them to fail immediately while testing.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-01-24 23:09:43 +01:00
Michał Górny f6a17acb8b python-utils-r1.eclass: Run sphinx-build via EPYTHON
Run sphinx-build via EPYTHON to ensure that the correct Python
executable is being used.  Otherwise, sphinx-build runs via
/usr/bin/python* and does not respect the virtualenv boundaries.

Closes: https://bugs.gentoo.org/831565
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-01-20 15:38:17 +01:00
Michał Górny 654fe46bff python-utils-r1.eclass: epytest, force color output to match NOCOLOR
Force pytest color output on or off based on the presence and value
of NOCOLOR envvar.  This fixes inconsistent use of colors that largely
depended on upstream pytest settings.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-01-13 13:08:12 +01:00
Michał Górny 61d3e4f587 python-utils-r1.eclass: Bump minimal Python versions
Bump minimal Python package versions to ensure that the python-exec deps
are inside.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2022-01-09 09:09:06 +01:00
Michał Górny d1888cdc8c python-utils-r1.eclass: Bump min pypy3 dep to force pypy3.8
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-11-09 11:28:24 +01:00
Florian Schmaus be22deb1b7 python-utils-r1.eclass: add and use _python_check_EPYTHON
Signed-off-by: Florian Schmaus <flow@gentoo.org>
2021-09-14 19:55:45 +02:00
Michał Górny a66615fe89 python-utils-r1.eclass: Handle deselect/ignore in epytest
Support (potentially global-scope) EPYTEST_DESELECT and EPYTEST_IGNORE
arrays to conveniently deselect/skip tests.  This effectively replaces
local hacks such as:

    epytest ${deselect[@]/#/--deselect }

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-08-15 08:54:36 +02:00
Mart Raudsepp c412d29682 python-utils-r1.eclass: Enable parallel bytecompile compilation
Python 3.5 added support for compileall to run parallel workers for
performing bytecode compilation. Make use of it to the extent
possible without refactoring the code too much to get different
paths into the same call for best possible parallelization.

Signed-off-by: Mart Raudsepp <leio@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-08-12 19:04:20 +02:00
Mart Raudsepp 7a9b4f552e python-utils-r1.eclass: Enable hardlinking of identical pyc files for py3.9+
Python 3.9 includes a new feature for compileall to automatically hardlink
different optimization level cache files if they are identical. Make use of it
for python_optimize for some space savings.
This however does not cover distutils use cases and python itself.

Signed-off-by: Mart Raudsepp <leio@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-08-12 19:04:19 +02:00
Michał Górny 71374edfc1 python-utils-r1.eclass: Cleanup cache dirs after epytest
Make epytest clean up common cache directories .hypothesis
and .pytest_cache after the execution.  If pytest is executed
in ${BUILD_DIR}/lib, these directories end up being wrongly installed,
and so far ebuilds had to handle cleaning them up.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-08-07 15:52:49 +02:00
Michał Górny 7ae1b4b192 python-utils-r1.eclass: Pass -Wdefault to epytest to avoid -Werror
Make pytest pass -Wdefault in order to override upstream default warning
options that commonly include -Werror.  This has often caused tests to
start failing due to new deprecation warnings introduced
in dependencies, or block new implementations due to harmless
deprecation warnings.

A side effect of this is that we are overriding all warning options used
by upstream.  This could e.g. cause more warnings to be reported (when
upstream ignores some of them).  This might also break badly written
tests (e.g. when they rely on exceptions to catch warnings).

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-07-02 10:25:40 +02:00
Michał Górny 74e79e846a python-utils-r1.eclass: Remove _python_ln_rel
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-29 08:04:58 +02:00
Mike Gilbert 65808f2334 Revert "python-utils-r1.eclass: Remove _python_ln_rel"
Reverts: 1f678a8cae
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
2021-06-24 17:05:03 -04:00
Michał Górny 7fb83c87d0 python-utils-r1.eclass: Revert "Remove python_optimize support..."
python_optimize is still used in dev-python/pypy.

Reverts: 964f5c6181
Closes: https://bugs.gentoo.org/798330
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-24 13:41:59 +02:00
Michał Górny 1f678a8cae python-utils-r1.eclass: Remove _python_ln_rel
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-23 23:44:28 +02:00
Michał Górny 22a9a4d043 python-utils-r1.eclass: Enable EAPI 8
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-23 23:44:10 +02:00
Michał Górny 3a980b89c1 python-utils-r1.eclass: Fix python_fix_shebang for py3.10+
We should be safe until Python 3.99 now ;-).

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-23 23:44:09 +02:00
Michał Górny a0eb584767 python-utils-r1.eclass: Deprecated and EAPI8-ban python_is_python3
There is no use for python_is_python3 anymore, as Python 2 is no longer
supported at runtime and the remaining any-r1 uses are pure-2.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-23 23:44:08 +02:00
Michał Górny 98a94936c2 python-utils-r1.eclass: Ban py2 deps in python_gen* in EAPI 8
Ban using -2 or python2* as an argument to python_gen_cond_dep and other
functions using _python_impl_matches, in order to force cleaning up old
entries, in EAPI 8.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-23 23:44:07 +02:00
Michał Górny b3071fedb9 python-utils-r1.eclass: Eliminate local python_is_python3 uses
Do not use python_is_python3 in eclass functions to ease banning it.
Except for wrapper setup that is still used in py2 any-r1 context,
we can unconditionally assume Python 3 everywhere.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-23 23:44:06 +02:00
Michał Górny addf1c5993 python-utils-r1.eclass: Rename *into vars to use underscores
Rename helper variables used by *into to mark them private with
underscores.  The old names are leftovers from deprecated API that
permitted setting them directly.  It was last used in ::gentoo in 2016.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-23 23:44:05 +02:00
Michał Górny 964f5c6181 python-utils-r1.eclass: Remove python_optimize support for py<3.5
Remove the support code for Python 2.7, <3.5, as well as PyPy2.7.  These
are no longer supported at runtime, so byte-compiling should not be used
for these impls.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-23 23:44:04 +02:00
Michał Górny 1c2d52b662 python-utils-r1.eclass: Use 'dosym -r' in EAPI 8
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-23 23:44:03 +02:00
Michał Górny bee922d3c8 python-utils-r1.eclass: Ban private API in EAPI 8
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-23 23:44:02 +02:00
Michał Górny c014e66fdd python-utils-r1.eclass: Disable python3_7
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-06-01 09:48:04 +02:00
Michał Górny 7c5a4f2407 python-utils-r1.eclass: Grab paths from sysconfig module
Grab site-packages and includedir paths from sysconfig rather than
distutils.sysconfig, as the latter module is deprecated.  The new method
results in the same paths for all supported implementations,
as confirmed by the tests.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-05-12 11:54:44 +02:00
Michał Górny 4ad70961aa python-utils-r1.eclass: Add py3.10 to patterns
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-05-04 17:39:51 +02:00
Michał Górny 12a4380694 python-utils-r1.eclass: Enable python3_10
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-05-04 15:58:52 +02:00
Sam James 9ffe4afadb python-utils-r1.eclass: add note when dropping EAPI support
We need to remember to update metadata/install-qa-check.d/60python-pyc
in future to disable now non-applicable QA checks.

If we don't, we end up breaking older EAPI installs in general.

See: 1137a7ecce
See: bdcfb21ca5
Bug: https://bugs.gentoo.org/704286
Bug: https://bugs.gentoo.org/781878
Signed-off-by: Sam James <sam@gentoo.org>
2021-04-10 00:19:59 +01:00
Michał Górny bdcfb21ca5 python-utils-r1.eclass: Remove support for EAPIs prior to 6
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-04-09 23:56:37 +02:00
Michał Górny df8f9663ac python-utils-r1.eclass: Include -l in epytest
Add '-l' to epytest, in order to improve tracebacks by including
the values of local variables.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-04-09 23:55:35 +02:00
Michał Górny 87c16896ff python-utils-r1.eclass: Add eunittest helper
Add an eunittest helper to wrap up the common 'python -m unittest
discover' calls, except that they are run via
dev-python/unittest-or-fail now.  This guarantees that if no tests are
discovered the test phase fails rather than silently ignoring
the problem.  This is especially helpful since it saves the developer
from having to inspect test phase logs.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-03-28 12:22:34 +02:00
Michał Górny 999d57f8d6 python-utils-r1.eclass: Remove python.eclass guards
python.eclass is gone for a long time, ::progress is discontinued,
it should be safe to assume people will no longer be copying old stuff.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-03-11 09:48:01 +01:00
Michał Górny b9829ab04f python-utils-r1.eclass: Always force test summary in epytest
Explicitly request pytest to display the summary of all test results
except for passing tests.  This overrides the upstream defaults to
improve the quality of build logs.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-03-08 08:52:32 +01:00