mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-30 10:01:32 +02:00
eclass/python-r1: Sync with Gentoo
It's from Gentoo commit d7317785d04e7de172de3bff05852fca3cd15af2.
This commit is contained in:
parent
c564d3748f
commit
1962a0411b
@ -1,4 +1,4 @@
|
|||||||
# Copyright 1999-2021 Gentoo Authors
|
# Copyright 1999-2022 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: python-r1.eclass
|
# @ECLASS: python-r1.eclass
|
||||||
@ -28,7 +28,7 @@
|
|||||||
# both.
|
# both.
|
||||||
#
|
#
|
||||||
# For more information, please see the Python Guide:
|
# For more information, please see the Python Guide:
|
||||||
# https://dev.gentoo.org/~mgorny/python-guide/
|
# https://projects.gentoo.org/python/guide/
|
||||||
|
|
||||||
case "${EAPI:-0}" in
|
case "${EAPI:-0}" in
|
||||||
[0-5])
|
[0-5])
|
||||||
@ -53,7 +53,7 @@ inherit multibuild python-utils-r1
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: PYTHON_COMPAT
|
# @ECLASS_VARIABLE: PYTHON_COMPAT
|
||||||
# @REQUIRED
|
# @REQUIRED
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This variable contains a list of Python implementations the package
|
# This variable contains a list of Python implementations the package
|
||||||
@ -70,7 +70,7 @@ fi
|
|||||||
# PYTHON_COMPAT=( python2_7 python3_{3,4} )
|
# PYTHON_COMPAT=( python2_7 python3_{3,4} )
|
||||||
# @CODE
|
# @CODE
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: PYTHON_COMPAT_OVERRIDE
|
# @ECLASS_VARIABLE: PYTHON_COMPAT_OVERRIDE
|
||||||
# @USER_VARIABLE
|
# @USER_VARIABLE
|
||||||
# @DEFAULT_UNSET
|
# @DEFAULT_UNSET
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
@ -90,7 +90,7 @@ fi
|
|||||||
# PYTHON_COMPAT_OVERRIDE='pypy python3_3' emerge -1v dev-python/foo
|
# PYTHON_COMPAT_OVERRIDE='pypy python3_3' emerge -1v dev-python/foo
|
||||||
# @CODE
|
# @CODE
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: PYTHON_REQ_USE
|
# @ECLASS_VARIABLE: PYTHON_REQ_USE
|
||||||
# @DEFAULT_UNSET
|
# @DEFAULT_UNSET
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# The list of USEflags required to be enabled on the chosen Python
|
# The list of USEflags required to be enabled on the chosen Python
|
||||||
@ -110,7 +110,7 @@ fi
|
|||||||
# python_targets_pythonX_Y? ( dev-lang/python:X.Y[gdbm,ncurses(-)?] )
|
# python_targets_pythonX_Y? ( dev-lang/python:X.Y[gdbm,ncurses(-)?] )
|
||||||
# @CODE
|
# @CODE
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: PYTHON_DEPS
|
# @ECLASS_VARIABLE: PYTHON_DEPS
|
||||||
# @OUTPUT_VARIABLE
|
# @OUTPUT_VARIABLE
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This is an eclass-generated Python dependency string for all
|
# This is an eclass-generated Python dependency string for all
|
||||||
@ -125,12 +125,11 @@ fi
|
|||||||
#
|
#
|
||||||
# Example value:
|
# Example value:
|
||||||
# @CODE
|
# @CODE
|
||||||
# dev-lang/python-exec:=
|
|
||||||
# python_targets_python2_7? ( dev-lang/python:2.7[gdbm] )
|
# python_targets_python2_7? ( dev-lang/python:2.7[gdbm] )
|
||||||
# python_targets_pypy? ( dev-python/pypy[gdbm] )
|
# python_targets_pypy? ( dev-python/pypy[gdbm] )
|
||||||
# @CODE
|
# @CODE
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: PYTHON_USEDEP
|
# @ECLASS_VARIABLE: PYTHON_USEDEP
|
||||||
# @OUTPUT_VARIABLE
|
# @OUTPUT_VARIABLE
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This is an eclass-generated USE-dependency string which can be used to
|
# This is an eclass-generated USE-dependency string which can be used to
|
||||||
@ -151,7 +150,7 @@ fi
|
|||||||
# python_targets_python2_7(-)?,python_targets_python3_4(-)?
|
# python_targets_python2_7(-)?,python_targets_python3_4(-)?
|
||||||
# @CODE
|
# @CODE
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: PYTHON_SINGLE_USEDEP
|
# @ECLASS_VARIABLE: PYTHON_SINGLE_USEDEP
|
||||||
# @OUTPUT_VARIABLE
|
# @OUTPUT_VARIABLE
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# An eclass-generated USE-dependency string for the currently tested
|
# An eclass-generated USE-dependency string for the currently tested
|
||||||
@ -173,7 +172,7 @@ fi
|
|||||||
# python_single_target_python3_7(-)
|
# python_single_target_python3_7(-)
|
||||||
# @CODE
|
# @CODE
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: PYTHON_REQUIRED_USE
|
# @ECLASS_VARIABLE: PYTHON_REQUIRED_USE
|
||||||
# @OUTPUT_VARIABLE
|
# @OUTPUT_VARIABLE
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This is an eclass-generated required-use expression which ensures at
|
# This is an eclass-generated required-use expression which ensures at
|
||||||
@ -207,12 +206,6 @@ _python_set_globals() {
|
|||||||
local requse="|| ( ${flags[*]} )"
|
local requse="|| ( ${flags[*]} )"
|
||||||
local usedep=${optflags// /,}
|
local usedep=${optflags// /,}
|
||||||
|
|
||||||
# 1) well, python-exec would suffice as an RDEP
|
|
||||||
# but no point in making this overcomplex, BDEP doesn't hurt anyone
|
|
||||||
# 2) python-exec should be built with all targets forced anyway
|
|
||||||
# but if new targets were added, we may need to force a rebuild
|
|
||||||
deps+=">=dev-lang/python-exec-2:=[${usedep}]"
|
|
||||||
|
|
||||||
if [[ ${PYTHON_DEPS+1} ]]; then
|
if [[ ${PYTHON_DEPS+1} ]]; then
|
||||||
# IUSE is magical, so we can't really check it
|
# IUSE is magical, so we can't really check it
|
||||||
# (but we verify PYTHON_COMPAT already)
|
# (but we verify PYTHON_COMPAT already)
|
||||||
@ -296,13 +289,7 @@ _python_validate_useflags() {
|
|||||||
# are both in PYTHON_COMPAT and match any of the patterns passed
|
# are both in PYTHON_COMPAT and match any of the patterns passed
|
||||||
# as parameters to the function.
|
# as parameters to the function.
|
||||||
#
|
#
|
||||||
# The patterns are fnmatch-style patterns (matched via bash
|
# This is an internal function used to implement python_gen_cond_dep.
|
||||||
# == operator against PYTHON_COMPAT values). Remember to escape
|
|
||||||
# or quote the fnmatch patterns to prevent accidental shell filename
|
|
||||||
# expansion.
|
|
||||||
#
|
|
||||||
# This is an internal function used to implement python_gen_cond_dep
|
|
||||||
# and deprecated python_gen_usedep.
|
|
||||||
_python_gen_usedep() {
|
_python_gen_usedep() {
|
||||||
debug-print-function ${FUNCNAME} "${@}"
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
|
|
||||||
@ -323,46 +310,6 @@ _python_gen_usedep() {
|
|||||||
echo "${out// /,}"
|
echo "${out// /,}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: python_gen_usedep
|
|
||||||
# @USAGE: <pattern> [...]
|
|
||||||
# @DESCRIPTION:
|
|
||||||
# DEPRECATED. Please use python_gen_cond_dep instead.
|
|
||||||
#
|
|
||||||
# Output a USE dependency string for Python implementations which
|
|
||||||
# are both in PYTHON_COMPAT and match any of the patterns passed
|
|
||||||
# as parameters to the function.
|
|
||||||
#
|
|
||||||
# The patterns are fnmatch-style patterns (matched via bash
|
|
||||||
# == operator against PYTHON_COMPAT values). Remember to escape
|
|
||||||
# or quote the fnmatch patterns to prevent accidental shell filename
|
|
||||||
# expansion.
|
|
||||||
#
|
|
||||||
# When all implementations are requested, please use ${PYTHON_USEDEP}
|
|
||||||
# instead. Please also remember to set an appropriate REQUIRED_USE
|
|
||||||
# to avoid ineffective USE flags.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
# @CODE
|
|
||||||
# PYTHON_COMPAT=( python{2_7,3_4} )
|
|
||||||
# BDEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )"
|
|
||||||
# @CODE
|
|
||||||
#
|
|
||||||
# It will cause the dependency to look like:
|
|
||||||
# @CODE
|
|
||||||
# BDEPEND="doc? ( dev-python/epydoc[python_targets_python2_7?] )"
|
|
||||||
# @CODE
|
|
||||||
python_gen_usedep() {
|
|
||||||
debug-print-function ${FUNCNAME} "${@}"
|
|
||||||
|
|
||||||
# output only once, during some reasonable phase
|
|
||||||
# (avoid spamming cache regen runs)
|
|
||||||
if [[ ${EBUILD_PHASE} == setup ]]; then
|
|
||||||
eqawarn "python_gen_usedep() is deprecated. Please use python_gen_cond_dep instead."
|
|
||||||
fi
|
|
||||||
[[ ${EAPI} == [67] ]] || die "${FUNCNAME} banned in EAPI ${EAPI}"
|
|
||||||
_python_gen_usedep "${@}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# @FUNCTION: python_gen_useflags
|
# @FUNCTION: python_gen_useflags
|
||||||
# @USAGE: [<pattern>...]
|
# @USAGE: [<pattern>...]
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
@ -370,10 +317,8 @@ python_gen_usedep() {
|
|||||||
# are both in PYTHON_COMPAT and match any of the patterns passed
|
# are both in PYTHON_COMPAT and match any of the patterns passed
|
||||||
# as parameters to the function.
|
# as parameters to the function.
|
||||||
#
|
#
|
||||||
# The patterns are fnmatch-style patterns (matched via bash
|
# For the pattern syntax, please see _python_impl_matches
|
||||||
# == operator against PYTHON_COMPAT values). Remember to escape
|
# in python-utils-r1.eclass.
|
||||||
# or quote the fnmatch patterns to prevent accidental shell filename
|
|
||||||
# expansion.
|
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# @CODE
|
# @CODE
|
||||||
@ -407,10 +352,8 @@ python_gen_useflags() {
|
|||||||
# of Python implementations which are both in PYTHON_COMPAT and match
|
# of Python implementations which are both in PYTHON_COMPAT and match
|
||||||
# any of the patterns passed as the remaining parameters.
|
# any of the patterns passed as the remaining parameters.
|
||||||
#
|
#
|
||||||
# The patterns are fnmatch-style patterns (matched via bash
|
# For the pattern syntax, please see _python_impl_matches
|
||||||
# == operator against PYTHON_COMPAT values). Remember to escape
|
# in python-utils-r1.eclass.
|
||||||
# or quote the fnmatch patterns to prevent accidental shell filename
|
|
||||||
# expansion.
|
|
||||||
#
|
#
|
||||||
# In order to enforce USE constraints on the packages, verbatim
|
# In order to enforce USE constraints on the packages, verbatim
|
||||||
# '${PYTHON_USEDEP}' (quoted!) may be placed in the dependency
|
# '${PYTHON_USEDEP}' (quoted!) may be placed in the dependency
|
||||||
@ -441,9 +384,15 @@ python_gen_cond_dep() {
|
|||||||
_python_verify_patterns "${@}"
|
_python_verify_patterns "${@}"
|
||||||
for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
|
for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
|
||||||
if _python_impl_matches "${impl}" "${@}"; then
|
if _python_impl_matches "${impl}" "${@}"; then
|
||||||
# substitute ${PYTHON_USEDEP} if used
|
# substitute ${PYTHON_USEDEP} with USE-dep on *all* matching
|
||||||
# (since python_gen_usedep() will not return ${PYTHON_USEDEP}
|
# targets, if it is used. this ensures that Portage will
|
||||||
# the code is run at most once)
|
# report all missing USE flags simultaneously rather than
|
||||||
|
# requesting the user to enable them one by one.
|
||||||
|
#
|
||||||
|
# NB: the first call with replace all instances
|
||||||
|
# of ${PYTHON_USEDEP}, so the condition will be false
|
||||||
|
# on subsequent loop iterations and _python_gen_usedep()
|
||||||
|
# will run at most once.
|
||||||
if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
|
if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
|
||||||
local usedep=$(_python_gen_usedep "${@}")
|
local usedep=$(_python_gen_usedep "${@}")
|
||||||
dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}}
|
dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}}
|
||||||
@ -465,10 +414,8 @@ python_gen_cond_dep() {
|
|||||||
# patterns are passed, the output dependencies will be generated only
|
# patterns are passed, the output dependencies will be generated only
|
||||||
# for the implementations matching them.
|
# for the implementations matching them.
|
||||||
#
|
#
|
||||||
# The patterns are fnmatch-style patterns (matched via bash
|
# For the pattern syntax, please see _python_impl_matches
|
||||||
# == operator against PYTHON_COMPAT values). Remember to escape
|
# in python-utils-r1.eclass.
|
||||||
# or quote the fnmatch patterns to prevent accidental shell filename
|
|
||||||
# expansion.
|
|
||||||
#
|
#
|
||||||
# Use this function when you need to request different USE flags
|
# Use this function when you need to request different USE flags
|
||||||
# on the Python interpreter depending on package's USE flags. If you
|
# on the Python interpreter depending on package's USE flags. If you
|
||||||
@ -521,10 +468,8 @@ python_gen_impl_dep() {
|
|||||||
#
|
#
|
||||||
# Optionally, patterns may be specified to restrict the dependency to
|
# Optionally, patterns may be specified to restrict the dependency to
|
||||||
# a subset of Python implementations supported by the ebuild.
|
# a subset of Python implementations supported by the ebuild.
|
||||||
# The patterns are fnmatch-style patterns (matched via bash
|
# For the pattern syntax, please see _python_impl_matches
|
||||||
# == operator against PYTHON_COMPAT values). Remember to escape
|
# in python-utils-r1.eclass.
|
||||||
# or quote the fnmatch patterns to prevent accidental shell filename
|
|
||||||
# expansion.
|
|
||||||
#
|
#
|
||||||
# This should be used along with an appropriate python_check_deps()
|
# This should be used along with an appropriate python_check_deps()
|
||||||
# that checks which of the any-of blocks were matched, and python_setup
|
# that checks which of the any-of blocks were matched, and python_setup
|
||||||
@ -592,7 +537,7 @@ python_gen_any_dep() {
|
|||||||
echo "|| ( ${out})"
|
echo "|| ( ${out})"
|
||||||
}
|
}
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: BUILD_DIR
|
# @ECLASS_VARIABLE: BUILD_DIR
|
||||||
# @OUTPUT_VARIABLE
|
# @OUTPUT_VARIABLE
|
||||||
# @DEFAULT_UNSET
|
# @DEFAULT_UNSET
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
@ -711,10 +656,8 @@ python_foreach_impl() {
|
|||||||
# The python_check_deps() function in the any-of mode needs to be
|
# The python_check_deps() function in the any-of mode needs to be
|
||||||
# accompanied by appropriate any-of dependencies.
|
# accompanied by appropriate any-of dependencies.
|
||||||
#
|
#
|
||||||
# The patterns are fnmatch-style patterns (matched via bash
|
# For the pattern syntax, please see _python_impl_matches
|
||||||
# == operator against PYTHON_COMPAT values). Remember to escape
|
# in python-utils-r1.eclass.
|
||||||
# or quote the fnmatch patterns to prevent accidental shell filename
|
|
||||||
# expansion.
|
|
||||||
#
|
#
|
||||||
# This function needs to be used when Python is being called outside
|
# This function needs to be used when Python is being called outside
|
||||||
# of python_foreach_impl calls (e.g. for shared processes like doc
|
# of python_foreach_impl calls (e.g. for shared processes like doc
|
||||||
@ -788,12 +731,7 @@ python_setup() {
|
|||||||
|
|
||||||
# if python_check_deps() is declared, switch into any-of mode
|
# if python_check_deps() is declared, switch into any-of mode
|
||||||
if [[ ${has_check_deps} ]]; then
|
if [[ ${has_check_deps} ]]; then
|
||||||
# first check if the interpreter is installed
|
_python_run_check_deps "${impl}" || continue
|
||||||
python_is_installed "${impl}" || continue
|
|
||||||
# then run python_check_deps
|
|
||||||
local PYTHON_USEDEP="python_targets_${impl}(-)"
|
|
||||||
local PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)"
|
|
||||||
python_check_deps || continue
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
found=1
|
found=1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user