/[gentoo-x86]/eclass/python.eclass
Gentoo

Diff of /eclass/python.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.150 Revision 1.170
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2014 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.150 2012/02/13 23:50:12 zmedico Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.170 2014/11/20 15:32:09 mgorny Exp $
4 4
5# @ECLASS: python.eclass 5# @ECLASS: python.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Gentoo Python Project <python@gentoo.org> 7# Gentoo Python Project <python@gentoo.org>
8# @BLURB: Eclass for Python packages 8# @BLURB: Eclass for Python packages
9# @DESCRIPTION: 9# @DESCRIPTION:
10# The python eclass contains miscellaneous, useful functions for Python packages. 10# The python eclass contains miscellaneous, useful functions for Python packages.
11#
12# This eclass is DEPRECATED. Please use python-r1, python-single-r1
13# or python-any-r1 instead.
14
15if [[ ${_PYTHON_UTILS_R1} ]]; then
16 die 'python.eclass can not be used with python-r1 suite eclasses.'
17fi
11 18
12# Must call inherit before EXPORT_FUNCTIONS to avoid QA warning. 19# Must call inherit before EXPORT_FUNCTIONS to avoid QA warning.
13if [[ -z "${_PYTHON_ECLASS_INHERITED}" ]]; then 20if [[ -z "${_PYTHON_ECLASS_INHERITED}" ]]; then
14 inherit multilib 21 inherit multilib
15fi 22fi
21 28
22# Avoid processing this eclass more than once. 29# Avoid processing this eclass more than once.
23if [[ -z "${_PYTHON_ECLASS_INHERITED}" ]]; then 30if [[ -z "${_PYTHON_ECLASS_INHERITED}" ]]; then
24_PYTHON_ECLASS_INHERITED="1" 31_PYTHON_ECLASS_INHERITED="1"
25 32
26if ! has "${EAPI:-0}" 0 1 2 3 4; then 33if ! has "${EAPI:-0}" 0 1 2 3 4 5; then
27 die "API of python.eclass in EAPI=\"${EAPI}\" not established" 34 die "API of python.eclass in EAPI=\"${EAPI}\" not established"
28fi 35fi
29 36
37# Please do not add any new versions of Python here! Instead, please
38# focus on converting packages to use the new eclasses.
39
30_CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7) 40_CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
31_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2) 41_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2 3.3)
32_JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython) 42_JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython 2.7-jython)
33_PYPY_GLOBALLY_SUPPORTED_ABIS=(2.7-pypy-1.7 2.7-pypy-1.8) 43_PYPY_GLOBALLY_SUPPORTED_ABIS=(2.7-pypy-1.7 2.7-pypy-1.8 2.7-pypy-1.9 2.7-pypy-2.0)
34_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]} ${_PYPY_GLOBALLY_SUPPORTED_ABIS[@]}) 44_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]} ${_PYPY_GLOBALLY_SUPPORTED_ABIS[@]})
35 45
36# ================================================================================================ 46# ================================================================================================
37# ===================================== HANDLING OF METADATA ===================================== 47# ===================================== HANDLING OF METADATA =====================================
38# ================================================================================================ 48# ================================================================================================
98 108
99 return 1 109 return 1
100 fi 110 fi
101} 111}
102 112
113_python_implementation() {
114 if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then
115 return 0
116 elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then
117 return 0
118 elif [[ "${CATEGORY}/${PN}" == "virtual/pypy" ]]; then
119 return 0
120 else
121 return 1
122 fi
123}
124
103_python_package_supporting_installation_for_multiple_python_abis() { 125_python_package_supporting_installation_for_multiple_python_abis() {
104 if has "${EAPI:-0}" 0 1 2 3 4; then
105 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 126 [[ -n "${SUPPORT_PYTHON_ABIS}" ]]
106 return 0
107 else
108 return 1
109 fi
110 else
111 die "${FUNCNAME}(): Support for EAPI=\"${EAPI}\" not implemented"
112 fi
113} 127}
114 128
115# @ECLASS-VARIABLE: PYTHON_DEPEND 129# @ECLASS-VARIABLE: PYTHON_DEPEND
116# @DESCRIPTION: 130# @DESCRIPTION:
117# Specification of dependency on dev-lang/python. 131# Specification of dependency on dev-lang/python.
243 else 257 else
244 die "Invalid syntax of PYTHON_DEPEND" 258 die "Invalid syntax of PYTHON_DEPEND"
245 fi 259 fi
246} 260}
247 261
262if _python_implementation; then
248DEPEND=">=app-admin/eselect-python-20091230" 263 DEPEND=">=app-admin/eselect-python-20091230"
249RDEPEND="${DEPEND}" 264 RDEPEND="${DEPEND}"
265 PDEPEND="app-admin/python-updater"
266fi
250 267
251if [[ -n "${PYTHON_DEPEND}" ]]; then 268if [[ -n "${PYTHON_DEPEND}" ]]; then
252 _python_parse_PYTHON_DEPEND 269 _python_parse_PYTHON_DEPEND
253else 270else
254 _PYTHON_ATOMS=("dev-lang/python") 271 _PYTHON_ATOMS=("dev-lang/python")
293 _PYTHON_USE_WITH_ATOMS="${_PYTHON_USE_WITH_ATOMS_ARRAY[@]}" 310 _PYTHON_USE_WITH_ATOMS="${_PYTHON_USE_WITH_ATOMS_ARRAY[@]}"
294 fi 311 fi
295 if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then 312 if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
296 _PYTHON_USE_WITH_ATOMS="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOMS} )" 313 _PYTHON_USE_WITH_ATOMS="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOMS} )"
297 fi 314 fi
298 DEPEND+=" ${_PYTHON_USE_WITH_ATOMS}" 315 DEPEND+="${DEPEND:+ }${_PYTHON_USE_WITH_ATOMS}"
299 RDEPEND+=" ${_PYTHON_USE_WITH_ATOMS}" 316 RDEPEND+="${RDEPEND:+ }${_PYTHON_USE_WITH_ATOMS}"
300 unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOMS _PYTHON_USE_WITH_ATOMS_ARRAY 317 unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOMS _PYTHON_USE_WITH_ATOMS_ARRAY
301fi 318fi
302 319
303unset _PYTHON_ATOMS 320unset _PYTHON_ATOMS
304 321
305# ================================================================================================ 322# ================================================================================================
306# =================================== MISCELLANEOUS FUNCTIONS ==================================== 323# =================================== MISCELLANEOUS FUNCTIONS ====================================
307# ================================================================================================ 324# ================================================================================================
308
309_python_implementation() {
310 if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then
311 return 0
312 elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then
313 return 0
314 elif [[ "${CATEGORY}/${PN}" == "dev-python/pypy" ]]; then
315 return 0
316 else
317 return 1
318 fi
319}
320 325
321_python_abi-specific_local_scope() { 326_python_abi-specific_local_scope() {
322 [[ " ${FUNCNAME[@]:2} " =~ " "(_python_final_sanity_checks|python_execute_function|python_mod_optimize|python_mod_cleanup)" " ]] 327 [[ " ${FUNCNAME[@]:2} " =~ " "(_python_final_sanity_checks|python_execute_function|python_mod_optimize|python_mod_cleanup)" " ]]
323} 328}
324 329
337 342
338_python_initial_sanity_checks() { 343_python_initial_sanity_checks() {
339 if [[ "$(declare -p PYTHON_SANITY_CHECKS_EXECUTED 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS_EXECUTED="* || " ${FUNCNAME[@]:1} " =~ " "(python_set_active_version|python_pkg_setup)" " && -z "${PYTHON_SKIP_SANITY_CHECKS}" ]]; then 344 if [[ "$(declare -p PYTHON_SANITY_CHECKS_EXECUTED 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS_EXECUTED="* || " ${FUNCNAME[@]:1} " =~ " "(python_set_active_version|python_pkg_setup)" " && -z "${PYTHON_SKIP_SANITY_CHECKS}" ]]; then
340 # Ensure that /usr/bin/python and /usr/bin/python-config are valid. 345 # Ensure that /usr/bin/python and /usr/bin/python-config are valid.
341 if [[ "$(readlink "${EPREFIX}/usr/bin/python")" != "python-wrapper" ]]; then 346 if [[ "$(readlink "${EPREFIX}/usr/bin/python")" != "python-wrapper" ]]; then
342 eerror "'${EPREFIX}/usr/bin/python' is not valid symlink." 347 eerror "'${EPREFIX}/usr/bin/python' is not a valid symlink."
343 eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem." 348 eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
344 die "'${EPREFIX}/usr/bin/python' is not valid symlink" 349 die "'${EPREFIX}/usr/bin/python' is not a valid symlink"
345 fi 350 fi
346 if [[ "$(<"${EPREFIX}/usr/bin/python-config")" != *"Gentoo python-config wrapper script"* ]]; then 351 if [[ "$(<"${EPREFIX}/usr/bin/python-config")" != *"Gentoo python-config wrapper script"* ]]; then
347 eerror "'${EPREFIX}/usr/bin/python-config' is not valid script" 352 eerror "'${EPREFIX}/usr/bin/python-config' is not a valid script"
348 eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem." 353 eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
349 die "'${EPREFIX}/usr/bin/python-config' is not valid script" 354 die "'${EPREFIX}/usr/bin/python-config' is not a valid script"
350 fi 355 fi
351 fi 356 fi
352} 357}
353 358
354_python_final_sanity_checks() { 359_python_final_sanity_checks() {
747 if [[ -n "${PYTHON_EXPORT_PHASE_FUNCTIONS}" ]]; then 752 if [[ -n "${PYTHON_EXPORT_PHASE_FUNCTIONS}" ]]; then
748 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install 753 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
749 fi 754 fi
750fi 755fi
751 756
752if has "${EAPI:-0}" 0 1 2 3 4; then
753 unset PYTHON_ABIS 757unset PYTHON_ABIS
754fi
755 758
756_python_calculate_PYTHON_ABIS() { 759_python_calculate_PYTHON_ABIS() {
757 if ! _python_package_supporting_installation_for_multiple_python_abis; then 760 if ! _python_package_supporting_installation_for_multiple_python_abis; then
758 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" 761 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
759 fi 762 fi
760 763
761 _python_initial_sanity_checks 764 _python_initial_sanity_checks
762 765
763 if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then 766 if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]]; then
764 local PYTHON_ABI 767 local PYTHON_ABI
765 768
766 if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then 769 if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
767 local cpython_enabled="0" 770 local cpython_enabled="0"
768 771
800 803
801 python_version="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')" 804 python_version="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
802 805
803 if has_version "=dev-lang/python-2*"; then 806 if has_version "=dev-lang/python-2*"; then
804 if [[ "$(readlink "${EPREFIX}/usr/bin/python2")" != "python2."* ]]; then 807 if [[ "$(readlink "${EPREFIX}/usr/bin/python2")" != "python2."* ]]; then
805 die "'${EPREFIX}/usr/bin/python2' is not valid symlink" 808 die "'${EPREFIX}/usr/bin/python2' is not a valid symlink"
806 fi 809 fi
807 810
808 python2_version="$("${EPREFIX}/usr/bin/python2" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')" 811 python2_version="$("${EPREFIX}/usr/bin/python2" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
809 812
810 support_python_major_version="0" 813 support_python_major_version="0"
823 fi 826 fi
824 fi 827 fi
825 828
826 if has_version "=dev-lang/python-3*"; then 829 if has_version "=dev-lang/python-3*"; then
827 if [[ "$(readlink "${EPREFIX}/usr/bin/python3")" != "python3."* ]]; then 830 if [[ "$(readlink "${EPREFIX}/usr/bin/python3")" != "python3."* ]]; then
828 die "'${EPREFIX}/usr/bin/python3' is not valid symlink" 831 die "'${EPREFIX}/usr/bin/python3' is not a valid symlink"
829 fi 832 fi
830 833
831 python3_version="$("${EPREFIX}/usr/bin/python3" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')" 834 python3_version="$("${EPREFIX}/usr/bin/python3" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
832 835
833 support_python_major_version="0" 836 support_python_major_version="0"
842 die "Active version of CPython 3 is not supported by ${CATEGORY}/${PF}" 845 die "Active version of CPython 3 is not supported by ${CATEGORY}/${PF}"
843 fi 846 fi
844 else 847 else
845 python3_version="" 848 python3_version=""
846 fi 849 fi
850 fi
851
852 if [[ -z "${python2_version}" && -z "${python3_version}" ]]; then
853 eerror "${CATEGORY}/${PF} requires at least one of the following packages:"
854 for PYTHON_ABI in "${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]}" "${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]}"; do
855 if ! _python_check_python_abi_matching --patterns-list "${PYTHON_ABI}" "${RESTRICT_PYTHON_ABIS}"; then
856 eerror " dev-lang/python:${PYTHON_ABI}"
857 fi
858 done
859 die "No supported version of CPython installed"
847 fi 860 fi
848 861
849 if [[ -n "${python2_version}" && "${python_version}" == "2."* && "${python_version}" != "${python2_version}" ]]; then 862 if [[ -n "${python2_version}" && "${python_version}" == "2."* && "${python_version}" != "${python2_version}" ]]; then
850 eerror "Python wrapper is configured incorrectly or '${EPREFIX}/usr/bin/python2' symlink" 863 eerror "Python wrapper is configured incorrectly or '${EPREFIX}/usr/bin/python2' symlink"
851 eerror "is set incorrectly. Use \`eselect python\` to fix configuration." 864 eerror "is set incorrectly. Use \`eselect python\` to fix configuration."
1009 python_default_function() { 1022 python_default_function() {
1010 emake "$@" 1023 emake "$@"
1011 } 1024 }
1012 elif [[ "${EBUILD_PHASE}" == "test" ]]; then 1025 elif [[ "${EBUILD_PHASE}" == "test" ]]; then
1013 python_default_function() { 1026 python_default_function() {
1027 # Stolen from portage's _eapi0_src_test()
1028 local emake_cmd="${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE}"
1014 if emake -j1 -n check &> /dev/null; then 1029 if ${emake_cmd} -j1 -n check &> /dev/null; then
1015 emake -j1 check "$@" 1030 ${emake_cmd} -j1 check "$@"
1016 elif emake -j1 -n test &> /dev/null; then 1031 elif ${emake_cmd} -j1 -n test &> /dev/null; then
1017 emake -j1 test "$@" 1032 ${emake_cmd} -j1 test "$@"
1018 fi 1033 fi
1019 } 1034 }
1020 elif [[ "${EBUILD_PHASE}" == "install" ]]; then 1035 elif [[ "${EBUILD_PHASE}" == "install" ]]; then
1021 python_default_function() { 1036 python_default_function() {
1022 emake DESTDIR="${D}" install "$@" 1037 emake DESTDIR="${D}" install "$@"
1289pypy_interpreter_re = re.compile(r"^pypy-c(\d+\.\d+)$") 1304pypy_interpreter_re = re.compile(r"^pypy-c(\d+\.\d+)$")
1290cpython_shebang_re = re.compile(r"^#![ \t]*(?:${EPREFIX}/usr/bin/python|(?:${EPREFIX})?/usr/bin/env[ \t]+(?:${EPREFIX}/usr/bin/)?python)") 1305cpython_shebang_re = re.compile(r"^#![ \t]*(?:${EPREFIX}/usr/bin/python|(?:${EPREFIX})?/usr/bin/env[ \t]+(?:${EPREFIX}/usr/bin/)?python)")
1291python_shebang_options_re = re.compile(r"^#![ \t]*${EPREFIX}/usr/bin/(?:jython|pypy-c|python)(?:\d+(?:\.\d+)?)?[ \t]+(-\S)") 1306python_shebang_options_re = re.compile(r"^#![ \t]*${EPREFIX}/usr/bin/(?:jython|pypy-c|python)(?:\d+(?:\.\d+)?)?[ \t]+(-\S)")
1292python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$") 1307python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$")
1293 1308
1294pypy_versions_mapping = { 1309#pypy_versions_mapping = {
1295 "1.5": "2.7" 1310# "1.5": "2.7",
1296} 1311# "1.6": "2.7",
1312# "1.7": "2.7",
1313# "1.8": "2.7",
1314# "1.9": "2.7",
1315# "2.0": "2.7",
1316#}
1297 1317
1298def get_PYTHON_ABI(python_interpreter): 1318def get_PYTHON_ABI(python_interpreter):
1299 cpython_matched = cpython_interpreter_re.match(python_interpreter) 1319 cpython_matched = cpython_interpreter_re.match(python_interpreter)
1300 jython_matched = jython_interpreter_re.match(python_interpreter) 1320 jython_matched = jython_interpreter_re.match(python_interpreter)
1301 pypy_matched = pypy_interpreter_re.match(python_interpreter) 1321 pypy_matched = pypy_interpreter_re.match(python_interpreter)
1302 if cpython_matched is not None: 1322 if cpython_matched is not None:
1303 PYTHON_ABI = cpython_matched.group(1) 1323 PYTHON_ABI = cpython_matched.group(1)
1304 elif jython_matched is not None: 1324 elif jython_matched is not None:
1305 PYTHON_ABI = jython_matched.group(1) + "-jython" 1325 PYTHON_ABI = jython_matched.group(1) + "-jython"
1306 elif pypy_matched is not None: 1326 elif pypy_matched is not None:
1307 PYTHON_ABI = pypy_versions_mapping[pypy_matched.group(1)] + "-pypy-" + pypy_matched.group(1) 1327 #PYTHON_ABI = pypy_versions_mapping[pypy_matched.group(1)] + "-pypy-" + pypy_matched.group(1)
1328 PYTHON_ABI = "2.7-pypy-" + pypy_matched.group(1)
1308 else: 1329 else:
1309 PYTHON_ABI = None 1330 PYTHON_ABI = None
1310 return PYTHON_ABI 1331 return PYTHON_ABI
1311 1332
1312def get_python_interpreter(PYTHON_ABI): 1333def get_python_interpreter(PYTHON_ABI):
2037 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then 2058 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
2038 echo "=dev-lang/python-${PYTHON_ABI}*" 2059 echo "=dev-lang/python-${PYTHON_ABI}*"
2039 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then 2060 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
2040 echo "=dev-java/jython-${PYTHON_ABI%-jython}*" 2061 echo "=dev-java/jython-${PYTHON_ABI%-jython}*"
2041 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then 2062 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
2042 echo "=dev-python/pypy-${PYTHON_ABI#*-pypy-}*" 2063 echo "=virtual/pypy-${PYTHON_ABI#*-pypy-}*"
2043 fi 2064 fi
2044 else 2065 else
2045 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then 2066 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
2046 echo "dev-lang/python:${PYTHON_ABI}" 2067 echo "dev-lang/python:${PYTHON_ABI}"
2047 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then 2068 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
2048 echo "dev-java/jython:${PYTHON_ABI%-jython}" 2069 echo "dev-java/jython:${PYTHON_ABI%-jython}"
2049 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then 2070 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
2050 echo "dev-python/pypy:${PYTHON_ABI#*-pypy-}" 2071 echo "virtual/pypy:${PYTHON_ABI#*-pypy-}"
2051 fi 2072 fi
2052 fi 2073 fi
2053} 2074}
2054 2075
2055# @FUNCTION: python_get_includedir 2076# @FUNCTION: python_get_includedir
2692 fi 2713 fi
2693 2714
2694 export PYTHONDONTWRITEBYTECODE="1" 2715 export PYTHONDONTWRITEBYTECODE="1"
2695} 2716}
2696 2717
2718_python_vecho() {
2719 [[ -z ${PORTAGE_VERBOSE} ]] || echo "$@"
2720}
2721
2697_python_clean_compiled_modules() { 2722_python_clean_compiled_modules() {
2698 _python_initialize_prefix_variables 2723 _python_initialize_prefix_variables
2699 _python_set_color_variables 2724 _python_set_color_variables
2700 2725
2701 [[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage" 2726 [[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage"
2714 2739
2715 if [[ "${EBUILD_PHASE}" == "postrm" ]]; then 2740 if [[ "${EBUILD_PHASE}" == "postrm" ]]; then
2716 # Delete empty child directories. 2741 # Delete empty child directories.
2717 find "${path}" -type d | sort -r | while read -r dir; do 2742 find "${path}" -type d | sort -r | while read -r dir; do
2718 if rmdir "${dir}" 2> /dev/null; then 2743 if rmdir "${dir}" 2> /dev/null; then
2719 echo "${_CYAN}<<< ${dir}${_NORMAL}" 2744 _python_vecho "<<< ${dir}"
2720 fi 2745 fi
2721 done 2746 done
2722 fi 2747 fi
2723 elif [[ "${path}" == *.py ]]; then 2748 elif [[ "${path}" == *.py ]]; then
2724 base_module_name="${path##*/}" 2749 base_module_name="${path##*/}"
2747 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then 2772 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
2748 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue 2773 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue
2749 else 2774 else
2750 [[ -f "${py_file}" ]] && continue 2775 [[ -f "${py_file}" ]] && continue
2751 fi 2776 fi
2752 echo "${_BLUE}<<< ${compiled_file%[co]}[co]${_NORMAL}" 2777 _python_vecho "<<< ${compiled_file%[co]}[co]"
2753 rm -f "${compiled_file%[co]}"[co] 2778 rm -f "${compiled_file%[co]}"[co]
2754 elif [[ "${compiled_file}" == *\$py.class ]]; then 2779 elif [[ "${compiled_file}" == *\$py.class ]]; then
2755 if [[ "${dir}" == "__pycache__" ]]; then 2780 if [[ "${dir}" == "__pycache__" ]]; then
2756 base_module_name="${compiled_file##*/}" 2781 base_module_name="${compiled_file##*/}"
2757 base_module_name="${base_module_name%\$py.class}" 2782 base_module_name="${base_module_name%\$py.class}"
2762 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then 2787 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
2763 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue 2788 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue
2764 else 2789 else
2765 [[ -f "${py_file}" ]] && continue 2790 [[ -f "${py_file}" ]] && continue
2766 fi 2791 fi
2767 echo "${_BLUE}<<< ${compiled_file}${_NORMAL}" 2792 _python_vecho "<<< ${compiled_file}"
2768 rm -f "${compiled_file}" 2793 rm -f "${compiled_file}"
2769 else 2794 else
2770 die "${FUNCNAME}(): Unrecognized file type: '${compiled_file}'" 2795 die "${FUNCNAME}(): Unrecognized file type: '${compiled_file}'"
2771 fi 2796 fi
2772 2797
2773 # Delete empty parent directories. 2798 # Delete empty parent directories.
2774 dir="${compiled_file%/*}" 2799 dir="${compiled_file%/*}"
2775 while [[ "${dir}" != "${root}" ]]; do 2800 while [[ "${dir}" != "${root}" ]]; do
2776 if rmdir "${dir}" 2> /dev/null; then 2801 if rmdir "${dir}" 2> /dev/null; then
2777 echo "${_CYAN}<<< ${dir}${_NORMAL}" 2802 _python_vecho "<<< ${dir}"
2778 else 2803 else
2779 break 2804 break
2780 fi 2805 fi
2781 dir="${dir%/*}" 2806 dir="${dir%/*}"
2782 done 2807 done
2980 done <<< "${stderr}" 3005 done <<< "${stderr}"
2981 fi 3006 fi
2982 fi 3007 fi
2983 else 3008 else
2984 # Deprecated part of python_mod_optimize() 3009 # Deprecated part of python_mod_optimize()
2985 ewarn
2986 ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
2987 ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-08-01."
2988 ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
2989 ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
2990 ewarn
2991 3010
2992 local myroot mydirs=() myfiles=() myopts=() return_code="0" 3011 local myroot mydirs=() myfiles=() myopts=() return_code="0"
2993 3012
2994 # strip trailing slash 3013 # strip trailing slash
2995 myroot="${EROOT%/}" 3014 myroot="${EROOT%/}"
3145 fi 3164 fi
3146 shift 3165 shift
3147 done 3166 done
3148 else 3167 else
3149 # Deprecated part of python_mod_cleanup() 3168 # Deprecated part of python_mod_cleanup()
3150 ewarn
3151 ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
3152 ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-08-01."
3153 ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
3154 ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
3155 ewarn
3156 3169
3157 search_paths=("${@#/}") 3170 search_paths=("${@#/}")
3158 search_paths=("${search_paths[@]/#/${root}/}") 3171 search_paths=("${search_paths[@]/#/${root}/}")
3159 fi 3172 fi
3160 3173

Legend:
Removed from v.1.150  
changed lines
  Added in v.1.170

  ViewVC Help
Powered by ViewVC 1.1.20