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

Diff of /eclass/python.eclass

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

Revision 1.151 Revision 1.156
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 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.151 2012/02/27 03:57:35 floppym Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.156 2012/08/16 07:46:15 patrick 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
28fi 28fi
29 29
30_CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7) 30_CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
31_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2) 31_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2)
32_JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython) 32_JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython)
33_PYPY_GLOBALLY_SUPPORTED_ABIS=(2.7-pypy-1.7 2.7-pypy-1.8) 33_PYPY_GLOBALLY_SUPPORTED_ABIS=(2.7-pypy-1.7 2.7-pypy-1.8 2.7-pypy-1.9)
34_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]} ${_PYPY_GLOBALLY_SUPPORTED_ABIS[@]}) 34_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]} ${_PYPY_GLOBALLY_SUPPORTED_ABIS[@]})
35 35
36# ================================================================================================ 36# ================================================================================================
37# ===================================== HANDLING OF METADATA ===================================== 37# ===================================== HANDLING OF METADATA =====================================
38# ================================================================================================ 38# ================================================================================================
98 98
99 return 1 99 return 1
100 fi 100 fi
101} 101}
102 102
103_python_implementation() {
104 if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then
105 return 0
106 elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then
107 return 0
108 elif [[ "${CATEGORY}/${PN}" == "dev-python/pypy" ]]; then
109 return 0
110 else
111 return 1
112 fi
113}
114
103_python_package_supporting_installation_for_multiple_python_abis() { 115_python_package_supporting_installation_for_multiple_python_abis() {
104 if has "${EAPI:-0}" 0 1 2 3 4; then 116 if has "${EAPI:-0}" 0 1 2 3 4; then
105 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 117 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
106 return 0 118 return 0
107 else 119 else
243 else 255 else
244 die "Invalid syntax of PYTHON_DEPEND" 256 die "Invalid syntax of PYTHON_DEPEND"
245 fi 257 fi
246} 258}
247 259
260if _python_implementation; then
248DEPEND=">=app-admin/eselect-python-20091230" 261 DEPEND=">=app-admin/eselect-python-20091230"
249RDEPEND="${DEPEND}" 262 RDEPEND="${DEPEND}"
263 PDEPEND="app-admin/python-updater"
264fi
250 265
251if [[ -n "${PYTHON_DEPEND}" ]]; then 266if [[ -n "${PYTHON_DEPEND}" ]]; then
252 _python_parse_PYTHON_DEPEND 267 _python_parse_PYTHON_DEPEND
253else 268else
254 _PYTHON_ATOMS=("dev-lang/python") 269 _PYTHON_ATOMS=("dev-lang/python")
293 _PYTHON_USE_WITH_ATOMS="${_PYTHON_USE_WITH_ATOMS_ARRAY[@]}" 308 _PYTHON_USE_WITH_ATOMS="${_PYTHON_USE_WITH_ATOMS_ARRAY[@]}"
294 fi 309 fi
295 if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then 310 if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
296 _PYTHON_USE_WITH_ATOMS="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOMS} )" 311 _PYTHON_USE_WITH_ATOMS="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOMS} )"
297 fi 312 fi
298 DEPEND+=" ${_PYTHON_USE_WITH_ATOMS}" 313 DEPEND+="${DEPEND:+ }${_PYTHON_USE_WITH_ATOMS}"
299 RDEPEND+=" ${_PYTHON_USE_WITH_ATOMS}" 314 RDEPEND+="${RDEPEND:+ }${_PYTHON_USE_WITH_ATOMS}"
300 unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOMS _PYTHON_USE_WITH_ATOMS_ARRAY 315 unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOMS _PYTHON_USE_WITH_ATOMS_ARRAY
301fi 316fi
302 317
303unset _PYTHON_ATOMS 318unset _PYTHON_ATOMS
304 319
305# ================================================================================================ 320# ================================================================================================
306# =================================== MISCELLANEOUS FUNCTIONS ==================================== 321# =================================== MISCELLANEOUS FUNCTIONS ====================================
307# ================================================================================================ 322# ================================================================================================
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 323
321_python_abi-specific_local_scope() { 324_python_abi-specific_local_scope() {
322 [[ " ${FUNCNAME[@]:2} " =~ " "(_python_final_sanity_checks|python_execute_function|python_mod_optimize|python_mod_cleanup)" " ]] 325 [[ " ${FUNCNAME[@]:2} " =~ " "(_python_final_sanity_checks|python_execute_function|python_mod_optimize|python_mod_cleanup)" " ]]
323} 326}
324 327
1019 python_default_function() { 1022 python_default_function() {
1020 emake "$@" 1023 emake "$@"
1021 } 1024 }
1022 elif [[ "${EBUILD_PHASE}" == "test" ]]; then 1025 elif [[ "${EBUILD_PHASE}" == "test" ]]; then
1023 python_default_function() { 1026 python_default_function() {
1027 # Stolen from portage's _eapi0_src_test()
1028 local emake_cmd="${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE}"
1024 if emake -j1 -n check &> /dev/null; then 1029 if ${emake_cmd} -j1 -n check &> /dev/null; then
1025 emake -j1 check "$@" 1030 ${emake_cmd} -j1 check "$@"
1026 elif emake -j1 -n test &> /dev/null; then 1031 elif ${emake_cmd} -j1 -n test &> /dev/null; then
1027 emake -j1 test "$@" 1032 ${emake_cmd} -j1 test "$@"
1028 fi 1033 fi
1029 } 1034 }
1030 elif [[ "${EBUILD_PHASE}" == "install" ]]; then 1035 elif [[ "${EBUILD_PHASE}" == "install" ]]; then
1031 python_default_function() { 1036 python_default_function() {
1032 emake DESTDIR="${D}" install "$@" 1037 emake DESTDIR="${D}" install "$@"
1300cpython_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)")
1301python_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)")
1302python_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$")
1303 1308
1304pypy_versions_mapping = { 1309pypy_versions_mapping = {
1305 "1.5": "2.7" 1310 "1.5": "2.7",
1311 "1.6": "2.7",
1312 "1.7": "2.7",
1313 "1.8": "2.7",
1314 "1.9": "2.7",
1306} 1315}
1307 1316
1308def get_PYTHON_ABI(python_interpreter): 1317def get_PYTHON_ABI(python_interpreter):
1309 cpython_matched = cpython_interpreter_re.match(python_interpreter) 1318 cpython_matched = cpython_interpreter_re.match(python_interpreter)
1310 jython_matched = jython_interpreter_re.match(python_interpreter) 1319 jython_matched = jython_interpreter_re.match(python_interpreter)
2757 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then 2766 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
2758 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue 2767 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue
2759 else 2768 else
2760 [[ -f "${py_file}" ]] && continue 2769 [[ -f "${py_file}" ]] && continue
2761 fi 2770 fi
2762 echo "${_BLUE}<<< ${compiled_file%[co]}[co]${_NORMAL}"
2763 rm -f "${compiled_file%[co]}"[co] 2771 rm -f "${compiled_file%[co]}"[co]
2764 elif [[ "${compiled_file}" == *\$py.class ]]; then 2772 elif [[ "${compiled_file}" == *\$py.class ]]; then
2765 if [[ "${dir}" == "__pycache__" ]]; then 2773 if [[ "${dir}" == "__pycache__" ]]; then
2766 base_module_name="${compiled_file##*/}" 2774 base_module_name="${compiled_file##*/}"
2767 base_module_name="${base_module_name%\$py.class}" 2775 base_module_name="${base_module_name%\$py.class}"
2772 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then 2780 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
2773 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue 2781 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue
2774 else 2782 else
2775 [[ -f "${py_file}" ]] && continue 2783 [[ -f "${py_file}" ]] && continue
2776 fi 2784 fi
2777 echo "${_BLUE}<<< ${compiled_file}${_NORMAL}"
2778 rm -f "${compiled_file}" 2785 rm -f "${compiled_file}"
2779 else 2786 else
2780 die "${FUNCNAME}(): Unrecognized file type: '${compiled_file}'" 2787 die "${FUNCNAME}(): Unrecognized file type: '${compiled_file}'"
2781 fi 2788 fi
2782 2789
2783 # Delete empty parent directories. 2790 # Delete empty parent directories.
2784 dir="${compiled_file%/*}" 2791 dir="${compiled_file%/*}"
2785 while [[ "${dir}" != "${root}" ]]; do 2792 while [[ "${dir}" != "${root}" ]]; do
2786 if rmdir "${dir}" 2> /dev/null; then 2793 if ! rmdir "${dir}" 2> /dev/null; then
2787 echo "${_CYAN}<<< ${dir}${_NORMAL}"
2788 else
2789 break 2794 break
2790 fi 2795 fi
2791 dir="${dir%/*}" 2796 dir="${dir%/*}"
2792 done 2797 done
2793 done 2798 done

Legend:
Removed from v.1.151  
changed lines
  Added in v.1.156

  ViewVC Help
Powered by ViewVC 1.1.20