diff options
Diffstat (limited to 'eclass/distutils-r1.eclass')
-rw-r--r-- | eclass/distutils-r1.eclass | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 61c0a80323ec..5a6ebdcede8a 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -195,7 +195,6 @@ esac # @CODE # @ECLASS_VARIABLE: DISTUTILS_ALLOW_WHEEL_REUSE -# @DEFAULT_UNSET # @USER_VARIABLE # @DESCRIPTION: # If set to a non-empty value, the eclass is allowed to reuse a wheel @@ -205,6 +204,7 @@ esac # This is an optimization that can avoid the overhead of calling into # the build system in pure Python packages and packages using the stable # Python ABI. +: ${DISTUTILS_ALLOW_WHEEL_REUSE=1} # @ECLASS_VARIABLE: BUILD_DIR # @OUTPUT_VARIABLE @@ -572,6 +572,9 @@ distutils_enable_sphinx() { # with the specified test runner. Also copies the current value # of RDEPEND to test?-BDEPEND. The test-runner argument must be one of: # +# - import-check: `pytest --import-check` fallback (for use when there are +# no tests to run) +# # - pytest: dev-python/pytest # # - setup.py: setup.py test (no deps included) @@ -597,9 +600,13 @@ distutils_enable_tests() { [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: test-runner" local test_deps=${RDEPEND} + local test_pkgs= case ${1} in + import-check) + test_pkgs+=' dev-python/pytest-import-check[${PYTHON_USEDEP}]' + ;& pytest) - local test_pkgs='>=dev-python/pytest-7.4.4[${PYTHON_USEDEP}]' + test_pkgs+=' >=dev-python/pytest-7.4.4[${PYTHON_USEDEP}]' if [[ -n ${EPYTEST_TIMEOUT} ]]; then test_pkgs+=' dev-python/pytest-timeout[${PYTHON_USEDEP}]' fi @@ -929,6 +936,7 @@ _distutils-r1_print_package_versions() { # distutils patches and/or quirks. distutils-r1_python_prepare_all() { debug-print-function ${FUNCNAME} "${@}" + _python_sanity_checks _distutils-r1_check_all_phase_mismatch if [[ ! ${DISTUTILS_OPTIONAL} ]]; then @@ -1244,7 +1252,11 @@ distutils_pep517_install() { die "mydistutilsargs are banned in PEP517 mode (use DISTUTILS_ARGS)" fi - local config_settings= + local cmd=() config_settings= + if has cargo ${INHERITED} && [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]]; then + cmd+=( cargo_env ) + fi + case ${DISTUTILS_USE_PEP517} in maturin) # `maturin pep517 build-wheel --help` for options @@ -1381,9 +1393,14 @@ distutils_pep517_install() { ;; esac + # https://pyo3.rs/latest/building-and-distribution.html#cross-compiling + if tc-is-cross-compiler; then + local -x PYO3_CROSS_LIB_DIR=${SYSROOT}/$(python_get_stdlib) + fi + local build_backend=$(_distutils-r1_get_backend) einfo " Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}" - local cmd=( + cmd+=( "${EPYTHON}" -m gpep517 build-wheel --prefix="${EPREFIX}/usr" --backend "${build_backend}" @@ -1560,6 +1577,9 @@ distutils-r1_python_test() { _python_check_EPYTHON case ${_DISTUTILS_TEST_RUNNER} in + import-check) + epytest --import-check "${BUILD_DIR}/install$(python_get_sitedir)" + ;; pytest) epytest ;; @@ -1782,16 +1802,6 @@ distutils-r1_run_phase() { # bug fixes from Cython (this works only when setup.py is using # cythonize() but it's better than nothing) local -x CYTHON_FORCE_REGEN=1 - - # Rust extensions are incompatible with C/C++ LTO compiler - # see e.g. https://bugs.gentoo.org/910220 - if has cargo ${INHERITED}; then - local x - for x in $(all-flag-vars); do - local -x "${x}=${!x}" - done - filter-lto - fi fi # silence warnings when pydevd is loaded on Python 3.11+ @@ -1933,7 +1943,7 @@ _distutils-r1_compare_installed_files() { # Perform the check only if at least one potentially reusable wheel # has been produced. Nonpure packages (e.g. NumPy) may install # interpreter configuration details into sitedir. - if [[ ${!DISTUTILS_WHEELS[*]} != *-none-any.whl* && + if [[ ${!DISTUTILS_WHEELS[*]} != *py3-none-any.whl* && ${!DISTUTILS_WHEELS[*]} != *-abi3-*.whl ]]; then return fi @@ -2101,8 +2111,10 @@ _distutils-r1_post_python_install() { local strays=() local p mapfile -d $'\0' -t strays < <( + # jar for jpype, https://bugs.gentoo.org/937642 find "${sitedir}" -maxdepth 1 -type f '!' '(' \ -name '*.egg-info' -o \ + -name '*.jar' -o \ -name '*.pth' -o \ -name '*.py' -o \ -name '*.pyi' -o \ |