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

Diff of /eclass/python.eclass

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

Revision 1.94 Revision 1.95
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2010 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.94 2010/03/13 13:46:20 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.95 2010/03/20 17:59:40 arfrever 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
196 python_pkg_setup_fail() { 196 python_pkg_setup_fail() {
197 eerror "${1}" 197 eerror "${1}"
198 die "${1}" 198 die "${1}"
199 } 199 }
200 200
201 [[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return 201 if [[ "${PYTHON_USE_WITH_OPT}" ]]; then
202 if [[ "${PYTHON_USE_WITH_OPT}" == !* ]]; then
203 use ${PYTHON_USE_WITH_OPT#!} && return
204 else
205 use !${PYTHON_USE_WITH_OPT} && return
206 fi
207 fi
202 208
203 python_pkg_setup_check_USE_flags() { 209 python_pkg_setup_check_USE_flags() {
204 local pyatom use 210 local pyatom use
205 pyatom="$(python_get_implementational_package)" 211 pyatom="$(python_get_implementational_package)"
206 212
219 if [[ ${PYTHON_USE_WITH_OR} ]]; then 225 if [[ ${PYTHON_USE_WITH_OR} ]]; then
220 python_pkg_setup_fail "Please rebuild ${pyatom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}" 226 python_pkg_setup_fail "Please rebuild ${pyatom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
221 fi 227 fi
222 } 228 }
223 229
224 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 230 if _python_package_supporting_installation_for_multiple_python_abis; then
225 python_execute_function -q python_pkg_setup_check_USE_flags 231 python_execute_function -q python_pkg_setup_check_USE_flags
226 else 232 else
227 python_pkg_setup_check_USE_flags 233 python_pkg_setup_check_USE_flags
228 fi 234 fi
229 235
259fi 265fi
260 266
261unset _PYTHON_ATOMS 267unset _PYTHON_ATOMS
262 268
263# ================================================================================================ 269# ================================================================================================
264# ======== FUNCTIONS FOR PACKAGES SUPPORTING INSTALLATION FOR MULTIPLE VERSIONS OF PYTHON ======== 270# =========== FUNCTIONS FOR PACKAGES SUPPORTING INSTALLATION FOR MULTIPLE PYTHON ABIS ============
265# ================================================================================================ 271# ================================================================================================
266 272
267# @ECLASS-VARIABLE: SUPPORT_PYTHON_ABIS 273# @ECLASS-VARIABLE: SUPPORT_PYTHON_ABIS
268# @DESCRIPTION: 274# @DESCRIPTION:
269# Set this in EAPI <= 4 to indicate that current package supports installation for 275# Set this in EAPI <= 4 to indicate that current package supports installation for
270# multiple versions of Python. 276# multiple Python ABIs.
271 277
272# @ECLASS-VARIABLE: PYTHON_EXPORT_PHASE_FUNCTIONS 278# @ECLASS-VARIABLE: PYTHON_EXPORT_PHASE_FUNCTIONS
273# @DESCRIPTION: 279# @DESCRIPTION:
274# Set this to export phase functions for the following ebuild phases: 280# Set this to export phase functions for the following ebuild phases:
275# src_prepare, src_configure, src_compile, src_test, src_install. 281# src_prepare, src_configure, src_compile, src_test, src_install.
276if ! has "${EAPI:-0}" 0 1; then 282if ! has "${EAPI:-0}" 0 1; then
277 python_src_prepare() { 283 python_src_prepare() {
284 if ! _python_package_supporting_installation_for_multiple_python_abis; then
285 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
286 fi
287
278 python_copy_sources 288 python_copy_sources
279 } 289 }
280 290
281 for python_default_function in src_configure src_compile src_test src_install; do 291 for python_default_function in src_configure src_compile src_test src_install; do
282 eval "python_${python_default_function}() { 292 eval "python_${python_default_function}() {
293 if ! _python_package_supporting_installation_for_multiple_python_abis; then
294 die \"\${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs\"
295 fi
296
283 python_execute_function -d -s \"\$@\" 297 python_execute_function -d -s \"\$@\"
284 }" 298 }"
285 done 299 done
286 unset python_default_function 300 unset python_default_function
287 301
295# @FUNCTION: validate_PYTHON_ABIS 309# @FUNCTION: validate_PYTHON_ABIS
296# @DESCRIPTION: 310# @DESCRIPTION:
297# Ensure that PYTHON_ABIS variable has valid value. 311# Ensure that PYTHON_ABIS variable has valid value.
298# This function usually should not be directly called in ebuilds. 312# This function usually should not be directly called in ebuilds.
299validate_PYTHON_ABIS() { 313validate_PYTHON_ABIS() {
300 # Ensure that some functions cannot be accidentally successfully used in EAPI <= 4 without setting SUPPORT_PYTHON_ABIS variable. 314 if ! _python_package_supporting_installation_for_multiple_python_abis; then
301 if has "${EAPI:-0}" 0 1 2 3 4 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then 315 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
302 die "${FUNCNAME}() cannot be used in this EAPI without setting SUPPORT_PYTHON_ABIS variable"
303 fi 316 fi
304 317
305 _python_initial_sanity_checks 318 _python_initial_sanity_checks
306 319
307 # USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 5. 320 # USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 5.
334 done 347 done
335 [[ "${support_ABI}" == "1" ]] && export PYTHON_ABIS+="${PYTHON_ABIS:+ }${PYTHON_ABI}" 348 [[ "${support_ABI}" == "1" ]] && export PYTHON_ABIS+="${PYTHON_ABIS:+ }${PYTHON_ABI}"
336 done 349 done
337 350
338 if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then 351 if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
339 die "USE_PYTHON variable does not enable any version of Python supported by ${CATEGORY}/${PF}" 352 die "USE_PYTHON variable does not enable any Python ABI supported by ${CATEGORY}/${PF}"
340 fi 353 fi
341 354
342 if [[ "${cpython_enabled}" == "0" ]]; then 355 if [[ "${cpython_enabled}" == "0" ]]; then
343 die "USE_PYTHON variable does not enable any version of CPython" 356 die "USE_PYTHON variable does not enable any CPython ABI"
344 fi 357 fi
345 else 358 else
346 local python_version python2_version= python3_version= support_python_major_version 359 local python_version python2_version= python3_version= support_python_major_version
347 360
348 python_version="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')" 361 python_version="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
425# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [-f|--final-ABI] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--source-dir source_directory] [--] <function> [arguments] 438# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [-f|--final-ABI] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--source-dir source_directory] [--] <function> [arguments]
426# @DESCRIPTION: 439# @DESCRIPTION:
427# Execute specified function for each value of PYTHON_ABIS, optionally passing additional 440# Execute specified function for each value of PYTHON_ABIS, optionally passing additional
428# arguments. The specified function can use PYTHON_ABI and BUILDDIR variables. 441# arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
429python_execute_function() { 442python_execute_function() {
443 if ! _python_package_supporting_installation_for_multiple_python_abis; then
444 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
445 fi
446
430 _python_set_color_variables 447 _python_set_color_variables
431 448
432 local action action_message action_message_template= default_function="0" failure_message failure_message_template= final_ABI="0" function i iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0" source_dir= 449 local action action_message action_message_template= default_function="0" failure_message failure_message_template= final_ABI="0" function i iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0" source_dir=
433 450
434 while (($#)); do 451 while (($#)); do
523 die "${FUNCNAME}(): '--default-function' option cannot be used in this ebuild phase" 540 die "${FUNCNAME}(): '--default-function' option cannot be used in this ebuild phase"
524 fi 541 fi
525 function="python_default_function" 542 function="python_default_function"
526 fi 543 fi
527 544
545 # Ensure that python_execute_function() cannot be directly or indirectly called by python_execute_function().
528 for ((i = 1; i < "${#FUNCNAME[@]}"; i++)); do 546 for ((i = 1; i < "${#FUNCNAME[@]}"; i++)); do
529 if [[ "${FUNCNAME[${i}]}" == "${FUNCNAME}" ]]; then 547 if [[ "${FUNCNAME[${i}]}" == "${FUNCNAME}" ]]; then
530 die "${FUNCNAME}(): Invalid call stack" 548 die "${FUNCNAME}(): Invalid call stack"
531 fi 549 fi
532 done 550 done
603 fi 621 fi
604 if [[ "${quiet}" == "0" ]]; then 622 if [[ "${quiet}" == "0" ]]; then
605 ewarn "${_RED}${failure_message}${_NORMAL}" 623 ewarn "${_RED}${failure_message}${_NORMAL}"
606 fi 624 fi
607 if [[ -z "${PYTHON_ABIS}" ]]; then 625 if [[ -z "${PYTHON_ABIS}" ]]; then
608 die "${function}() function failed with all enabled versions of Python" 626 die "${function}() function failed with all enabled Python ABIs"
609 fi 627 fi
610 else 628 else
611 die "${failure_message}" 629 die "${failure_message}"
612 fi 630 fi
613 fi 631 fi
647# @FUNCTION: python_copy_sources 665# @FUNCTION: python_copy_sources
648# @USAGE: <directory="${S}"> [directory] 666# @USAGE: <directory="${S}"> [directory]
649# @DESCRIPTION: 667# @DESCRIPTION:
650# Copy unpacked sources of current package to separate build directory for each Python ABI. 668# Copy unpacked sources of current package to separate build directory for each Python ABI.
651python_copy_sources() { 669python_copy_sources() {
670 if ! _python_package_supporting_installation_for_multiple_python_abis; then
671 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
672 fi
673
652 local dir dirs=() PYTHON_ABI 674 local dir dirs=() PYTHON_ABI
653 675
654 if [[ "$#" -eq 0 ]]; then 676 if [[ "$#" -eq 0 ]]; then
655 if [[ "${WORKDIR}" == "${S}" ]]; then 677 if [[ "${WORKDIR}" == "${S}" ]]; then
656 die "${FUNCNAME}() cannot be used" 678 die "${FUNCNAME}() cannot be used"
666 cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed" 688 cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
667 done 689 done
668 done 690 done
669} 691}
670 692
671# @FUNCTION: python_set_build_dir_symlink
672# @USAGE: <directory="build">
673# @DESCRIPTION:
674# Create build directory symlink.
675python_set_build_dir_symlink() {
676 local dir="$1"
677
678 [[ -z "${PYTHON_ABI}" ]] && die "PYTHON_ABI variable not set"
679 [[ -z "${dir}" ]] && dir="build"
680
681 # Do not delete preexistent directories.
682 rm -f "${dir}" || die "Deletion of '${dir}' failed"
683 ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed"
684}
685
686# @FUNCTION: python_generate_wrapper_scripts 693# @FUNCTION: python_generate_wrapper_scripts
687# @USAGE: [-E|--respect-EPYTHON] [-f|--force] [-q|--quiet] [--] <file> [files] 694# @USAGE: [-E|--respect-EPYTHON] [-f|--force] [-q|--quiet] [--] <file> [files]
688# @DESCRIPTION: 695# @DESCRIPTION:
689# Generate wrapper scripts. Existing files are overwritten only with --force option. 696# Generate wrapper scripts. Existing files are overwritten only with --force option.
690# If --respect-EPYTHON option is specified, then generated wrapper scripts will 697# If --respect-EPYTHON option is specified, then generated wrapper scripts will
691# respect EPYTHON variable at run time. 698# respect EPYTHON variable at run time.
692python_generate_wrapper_scripts() { 699python_generate_wrapper_scripts() {
700 if ! _python_package_supporting_installation_for_multiple_python_abis; then
701 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
702 fi
703
693 _python_initialize_prefix_variables 704 _python_initialize_prefix_variables
694 705
695 local eselect_python_option file force="0" quiet="0" PYTHON_ABI python2_enabled="0" python3_enabled="0" respect_EPYTHON="0" 706 local eselect_python_option file force="0" quiet="0" PYTHON_ABI python2_enabled="0" python3_enabled="0" respect_EPYTHON="0"
696 707
697 while (($#)); do 708 while (($#)); do
788 raise ValueError 799 raise ValueError
789 except (OSError, ValueError): 800 except (OSError, ValueError):
790 sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n") 801 sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
791 sys.exit(1) 802 sys.exit(1)
792 803
793 EPYTHON = eselect_process.stdout.read().rstrip("\n") 804 EPYTHON = eselect_process.stdout.read()
794 if not isinstance(EPYTHON, str): 805 if not isinstance(EPYTHON, str):
795 # Python 3 806 # Python 3
796 EPYTHON = EPYTHON.decode() 807 EPYTHON = EPYTHON.decode()
808 EPYTHON = EPYTHON.rstrip("\n")
797 809
798 EPYTHON_matched = EPYTHON_re.match(EPYTHON) 810 EPYTHON_matched = EPYTHON_re.match(EPYTHON)
799 if EPYTHON_matched: 811 if EPYTHON_matched:
800 PYTHON_ABI = EPYTHON_matched.group(1) 812 PYTHON_ABI = EPYTHON_matched.group(1)
801 else: 813 else:
802 sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % EPYTHON) 814 sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON)
803 sys.exit(1) 815 sys.exit(1)
804EOF 816EOF
805 if [[ "$?" != "0" ]]; then 817 if [[ "$?" != "0" ]]; then
806 die "${FUNCNAME}(): Generation of '$1' failed" 818 die "${FUNCNAME}(): Generation of '$1' failed"
807 fi 819 fi
813 raise ValueError 825 raise ValueError
814except (OSError, ValueError): 826except (OSError, ValueError):
815 sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n") 827 sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
816 sys.exit(1) 828 sys.exit(1)
817 829
818EPYTHON = eselect_process.stdout.read().rstrip("\n") 830EPYTHON = eselect_process.stdout.read()
819if not isinstance(EPYTHON, str): 831if not isinstance(EPYTHON, str):
820 # Python 3 832 # Python 3
821 EPYTHON = EPYTHON.decode() 833 EPYTHON = EPYTHON.decode()
834EPYTHON = EPYTHON.rstrip("\n")
822 835
823EPYTHON_matched = EPYTHON_re.match(EPYTHON) 836EPYTHON_matched = EPYTHON_re.match(EPYTHON)
824if EPYTHON_matched: 837if EPYTHON_matched:
825 PYTHON_ABI = EPYTHON_matched.group(1) 838 PYTHON_ABI = EPYTHON_matched.group(1)
826else: 839else:
827 sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % EPYTHON) 840 sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON)
828 sys.exit(1) 841 sys.exit(1)
829EOF 842EOF
830 if [[ "$?" != "0" ]]; then 843 if [[ "$?" != "0" ]]; then
831 die "${FUNCNAME}(): Generation of '$1' failed" 844 die "${FUNCNAME}(): Generation of '$1' failed"
832 fi 845 fi
881 fperms +x "${file#${ED%/}}" || die "fperms '${file}' failed" 894 fperms +x "${file#${ED%/}}" || die "fperms '${file}' failed"
882 done 895 done
883} 896}
884 897
885# ================================================================================================ 898# ================================================================================================
886# ====== FUNCTIONS FOR PACKAGES NOT SUPPORTING INSTALLATION FOR MULTIPLE VERSIONS OF PYTHON ====== 899# ========= FUNCTIONS FOR PACKAGES NOT SUPPORTING INSTALLATION FOR MULTIPLE PYTHON ABIS ==========
887# ================================================================================================ 900# ================================================================================================
888 901
889# @FUNCTION: python_set_active_version 902# @FUNCTION: python_set_active_version
890# @USAGE: <CPython_ABI|2|3> 903# @USAGE: <CPython_ABI|2|3>
891# @DESCRIPTION: 904# @DESCRIPTION:
892# Set specified version of CPython as active version of Python. 905# Set specified version of CPython as active version of Python.
893python_set_active_version() { 906python_set_active_version() {
894 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 907 if _python_package_supporting_installation_for_multiple_python_abis; then
895 die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple versions of Python" 908 die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
896 fi 909 fi
897 910
898 if [[ "$#" -ne 1 ]]; then 911 if [[ "$#" -ne 1 ]]; then
899 die "${FUNCNAME}() requires 1 argument" 912 die "${FUNCNAME}() requires 1 argument"
900 fi 913 fi
933 946
934# @FUNCTION: python_need_rebuild 947# @FUNCTION: python_need_rebuild
935# @DESCRIPTION: Mark current package for rebuilding by python-updater after 948# @DESCRIPTION: Mark current package for rebuilding by python-updater after
936# switching of active version of Python. 949# switching of active version of Python.
937python_need_rebuild() { 950python_need_rebuild() {
938 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 951 if _python_package_supporting_installation_for_multiple_python_abis; then
939 die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple versions of Python" 952 die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
940 fi 953 fi
941 954
942 export PYTHON_NEED_REBUILD="$(PYTHON --ABI)" 955 export PYTHON_NEED_REBUILD="$(PYTHON --ABI)"
943} 956}
944 957
1021 die "${FUNCNAME}(): '-2', '-3' or '--final-ABI' options cannot be specified simultaneously" 1034 die "${FUNCNAME}(): '-2', '-3' or '--final-ABI' options cannot be specified simultaneously"
1022 fi 1035 fi
1023 1036
1024 if [[ "$#" -eq 0 ]]; then 1037 if [[ "$#" -eq 0 ]]; then
1025 if [[ "${final_ABI}" == "1" ]]; then 1038 if [[ "${final_ABI}" == "1" ]]; then
1026 if has "${EAPI:-0}" 0 1 2 3 4 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then 1039 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1027 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple versions of Python" 1040 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1028 fi 1041 fi
1029 validate_PYTHON_ABIS 1042 validate_PYTHON_ABIS
1030 PYTHON_ABI="${PYTHON_ABIS##* }" 1043 PYTHON_ABI="${PYTHON_ABIS##* }"
1031 elif [[ "${python2}" == "1" ]]; then 1044 elif [[ "${python2}" == "1" ]]; then
1032 PYTHON_ABI="$(eselect python show --python2 --ABI)" 1045 PYTHON_ABI="$(eselect python show --python2 --ABI)"
1040 if [[ -z "${PYTHON_ABI}" ]]; then 1053 if [[ -z "${PYTHON_ABI}" ]]; then
1041 die "${FUNCNAME}(): Active Python 3 interpreter not set" 1054 die "${FUNCNAME}(): Active Python 3 interpreter not set"
1042 elif [[ "${PYTHON_ABI}" != "3."* ]]; then 1055 elif [[ "${PYTHON_ABI}" != "3."* ]]; then
1043 die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`" 1056 die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
1044 fi 1057 fi
1045 elif [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then 1058 elif ! _python_package_supporting_installation_for_multiple_python_abis; then
1046 PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")" 1059 PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")"
1047 elif [[ -z "${PYTHON_ABI}" ]]; then 1060 elif [[ -z "${PYTHON_ABI}" ]]; then
1048 die "${FUNCNAME}(): Invalid usage: ${FUNCNAME}() should be used in ABI-specific local scope" 1061 die "${FUNCNAME}(): Invalid usage: ${FUNCNAME}() should be used in ABI-specific local scope"
1049 fi 1062 fi
1050 elif [[ "$#" -eq 1 ]]; then 1063 elif [[ "$#" -eq 1 ]]; then
1106 esac 1119 esac
1107 shift 1120 shift
1108 done 1121 done
1109 1122
1110 if [[ "${final_ABI}" == "1" ]]; then 1123 if [[ "${final_ABI}" == "1" ]]; then
1124 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1125 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1126 fi
1111 PYTHON_ABI="$(PYTHON -f --ABI)" 1127 PYTHON_ABI="$(PYTHON -f --ABI)"
1112 elif [[ -z "${PYTHON_ABI}" ]]; then 1128 elif [[ -z "${PYTHON_ABI}" ]]; then
1113 PYTHON_ABI="$(PYTHON --ABI)" 1129 PYTHON_ABI="$(PYTHON --ABI)"
1114 fi 1130 fi
1115 1131
1138 esac 1154 esac
1139 shift 1155 shift
1140 done 1156 done
1141 1157
1142 if [[ "${final_ABI}" == "1" ]]; then 1158 if [[ "${final_ABI}" == "1" ]]; then
1159 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1160 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1161 fi
1143 PYTHON_ABI="$(PYTHON -f --ABI)" 1162 PYTHON_ABI="$(PYTHON -f --ABI)"
1144 elif [[ -z "${PYTHON_ABI}" ]]; then 1163 elif [[ -z "${PYTHON_ABI}" ]]; then
1145 PYTHON_ABI="$(PYTHON --ABI)" 1164 PYTHON_ABI="$(PYTHON --ABI)"
1146 fi 1165 fi
1147 1166
1174 esac 1193 esac
1175 shift 1194 shift
1176 done 1195 done
1177 1196
1178 if [[ "${final_ABI}" == "1" ]]; then 1197 if [[ "${final_ABI}" == "1" ]]; then
1198 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1199 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1200 fi
1179 PYTHON_ABI="$(PYTHON -f --ABI)" 1201 PYTHON_ABI="$(PYTHON -f --ABI)"
1180 elif [[ -z "${PYTHON_ABI}" ]]; then 1202 elif [[ -z "${PYTHON_ABI}" ]]; then
1181 PYTHON_ABI="$(PYTHON --ABI)" 1203 PYTHON_ABI="$(PYTHON --ABI)"
1182 fi 1204 fi
1183 1205
1210 esac 1232 esac
1211 shift 1233 shift
1212 done 1234 done
1213 1235
1214 if [[ "${final_ABI}" == "1" ]]; then 1236 if [[ "${final_ABI}" == "1" ]]; then
1237 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1238 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1239 fi
1215 PYTHON_ABI="$(PYTHON -f --ABI)" 1240 PYTHON_ABI="$(PYTHON -f --ABI)"
1216 elif [[ -z "${PYTHON_ABI}" ]]; then 1241 elif [[ -z "${PYTHON_ABI}" ]]; then
1217 PYTHON_ABI="$(PYTHON --ABI)" 1242 PYTHON_ABI="$(PYTHON --ABI)"
1218 fi 1243 fi
1219 1244
1233 local options=() 1258 local options=()
1234 1259
1235 while (($#)); do 1260 while (($#)); do
1236 case "$1" in 1261 case "$1" in
1237 -f|--final-ABI) 1262 -f|--final-ABI)
1263 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1264 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1265 fi
1238 options+=("$1") 1266 options+=("$1")
1239 ;; 1267 ;;
1240 -*) 1268 -*)
1241 die "${FUNCNAME}(): Unrecognized option '$1'" 1269 die "${FUNCNAME}(): Unrecognized option '$1'"
1242 ;; 1270 ;;
1276 esac 1304 esac
1277 shift 1305 shift
1278 done 1306 done
1279 1307
1280 if [[ "${final_ABI}" == "1" ]]; then 1308 if [[ "${final_ABI}" == "1" ]]; then
1309 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1310 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1311 fi
1281 PYTHON_ABI="$(PYTHON -f --ABI)" 1312 PYTHON_ABI="$(PYTHON -f --ABI)"
1282 elif [[ -z "${PYTHON_ABI}" ]]; then 1313 elif [[ -z "${PYTHON_ABI}" ]]; then
1283 PYTHON_ABI="$(PYTHON --ABI)" 1314 PYTHON_ABI="$(PYTHON --ABI)"
1284 fi 1315 fi
1285 1316
1354 fi 1385 fi
1355 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))" 1386 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))"
1356 fi 1387 fi
1357 1388
1358 if [[ "${final_ABI}" == "1" ]]; then 1389 if [[ "${final_ABI}" == "1" ]]; then
1390 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1391 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1392 fi
1359 "$(PYTHON -f)" -c "${python_command}" 1393 "$(PYTHON -f)" -c "${python_command}"
1360 else 1394 else
1361 "$(PYTHON ${PYTHON_ABI})" -c "${python_command}" 1395 "$(PYTHON ${PYTHON_ABI})" -c "${python_command}"
1362 fi 1396 fi
1363} 1397}
1371 return 0 1405 return 0
1372 elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then 1406 elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then
1373 return 0 1407 return 0
1374 else 1408 else
1375 return 1 1409 return 1
1410 fi
1411}
1412
1413_python_package_supporting_installation_for_multiple_python_abis() {
1414 if [[ "${EBUILD_PHASE}" == "depend" ]]; then
1415 die "${FUNCNAME}() cannot be used in global scope"
1416 fi
1417
1418 if has "${EAPI:-0}" 0 1 2 3 4; then
1419 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
1420 return 0
1421 else
1422 return 1
1423 fi
1424 else
1425 die "${FUNCNAME}(): Support for EAPI=\"${EAPI}\" not implemented"
1376 fi 1426 fi
1377} 1427}
1378 1428
1379_python_initialize_prefix_variables() { 1429_python_initialize_prefix_variables() {
1380 if has "${EAPI:-0}" 0 1 2; then 1430 if has "${EAPI:-0}" 0 1 2; then
1493 die "${FUNCNAME}(): '${argument}' does not exist" 1543 die "${FUNCNAME}(): '${argument}' does not exist"
1494 elif [[ -f "${argument}" ]]; then 1544 elif [[ -f "${argument}" ]]; then
1495 files+=("${argument}") 1545 files+=("${argument}")
1496 elif [[ -d "${argument}" ]]; then 1546 elif [[ -d "${argument}" ]]; then
1497 if [[ "${recursive}" == "1" ]]; then 1547 if [[ "${recursive}" == "1" ]]; then
1498 if [[ "${only_executables}" == "1" ]]; then 1548 while read -d $'\0' -r file; do
1499 files+=($(find "${argument}" -perm /111 -type f)) 1549 files+=("${file}")
1500 else 1550 done < <(find "${argument}" $([[ "${only_executables}" == "1" ]] && echo -perm /111) -type f -print0)
1501 files+=($(find "${argument}" -type f))
1502 fi
1503 else 1551 else
1504 die "${FUNCNAME}(): '${argument}' is not a regular file" 1552 die "${FUNCNAME}(): '${argument}' is not a regular file"
1505 fi 1553 fi
1506 else 1554 else
1507 die "${FUNCNAME}(): '${argument}' is not a regular file or a directory" 1555 die "${FUNCNAME}(): '${argument}' is not a regular file or a directory"
1549_python_test_hook() { 1597_python_test_hook() {
1550 if [[ "$#" -ne 1 ]]; then 1598 if [[ "$#" -ne 1 ]]; then
1551 die "${FUNCNAME}() requires 1 argument" 1599 die "${FUNCNAME}() requires 1 argument"
1552 fi 1600 fi
1553 1601
1554 if [[ -n "${SUPPORT_PYTHON_ABIS}" && "$(type -t "${FUNCNAME[3]}_$1_hook")" == "function" ]]; then 1602 if _python_package_supporting_installation_for_multiple_python_abis && [[ "$(type -t "${FUNCNAME[3]}_$1_hook")" == "function" ]]; then
1555 "${FUNCNAME[3]}_$1_hook" 1603 "${FUNCNAME[3]}_$1_hook"
1556 fi 1604 fi
1557} 1605}
1558 1606
1559# @FUNCTION: python_execute_nosetests 1607# @FUNCTION: python_execute_nosetests
1560# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments] 1608# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
1561# @DESCRIPTION: 1609# @DESCRIPTION:
1562# Execute nosetests for all enabled versions of Python. 1610# Execute nosetests for all enabled Python ABIs.
1563# In ebuilds of packages supporting installation for multiple versions of Python, this function 1611# In ebuilds of packages supporting installation for multiple Python ABIs, this function calls
1564# calls python_execute_nosetests_pre_hook() and python_execute_nosetests_post_hook(), if they are defined. 1612# python_execute_nosetests_pre_hook() and python_execute_nosetests_post_hook(), if they are defined.
1565python_execute_nosetests() { 1613python_execute_nosetests() {
1566 _python_set_color_variables 1614 _python_set_color_variables
1567 1615
1568 local PYTHONPATH_template= separate_build_dirs= 1616 local PYTHONPATH_template= separate_build_dirs=
1569 1617
1610 nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" || return "$?" 1658 nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" || return "$?"
1611 fi 1659 fi
1612 1660
1613 _python_test_hook post 1661 _python_test_hook post
1614 } 1662 }
1615 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 1663 if _python_package_supporting_installation_for_multiple_python_abis; then
1616 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@" 1664 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
1617 else 1665 else
1618 if [[ -n "${separate_build_dirs}" ]]; then 1666 if [[ -n "${separate_build_dirs}" ]]; then
1619 die "${FUNCNAME}(): Invalid usage" 1667 die "${FUNCNAME}(): Invalid usage"
1620 fi 1668 fi
1625} 1673}
1626 1674
1627# @FUNCTION: python_execute_py.test 1675# @FUNCTION: python_execute_py.test
1628# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments] 1676# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
1629# @DESCRIPTION: 1677# @DESCRIPTION:
1630# Execute py.test for all enabled versions of Python. 1678# Execute py.test for all enabled Python ABIs.
1631# In ebuilds of packages supporting installation for multiple versions of Python, this function 1679# In ebuilds of packages supporting installation for multiple Python ABIs, this function calls
1632# calls python_execute_py.test_pre_hook() and python_execute_py.test_post_hook(), if they are defined. 1680# python_execute_py.test_pre_hook() and python_execute_py.test_post_hook(), if they are defined.
1633python_execute_py.test() { 1681python_execute_py.test() {
1634 _python_set_color_variables 1682 _python_set_color_variables
1635 1683
1636 local PYTHONPATH_template= separate_build_dirs= 1684 local PYTHONPATH_template= separate_build_dirs=
1637 1685
1678 py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@" || return "$?" 1726 py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@" || return "$?"
1679 fi 1727 fi
1680 1728
1681 _python_test_hook post 1729 _python_test_hook post
1682 } 1730 }
1683 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 1731 if _python_package_supporting_installation_for_multiple_python_abis; then
1684 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@" 1732 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
1685 else 1733 else
1686 if [[ -n "${separate_build_dirs}" ]]; then 1734 if [[ -n "${separate_build_dirs}" ]]; then
1687 die "${FUNCNAME}(): Invalid usage" 1735 die "${FUNCNAME}(): Invalid usage"
1688 fi 1736 fi
1693} 1741}
1694 1742
1695# @FUNCTION: python_execute_trial 1743# @FUNCTION: python_execute_trial
1696# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments] 1744# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
1697# @DESCRIPTION: 1745# @DESCRIPTION:
1698# Execute trial for all enabled versions of Python. 1746# Execute trial for all enabled Python ABIs.
1699# In ebuilds of packages supporting installation for multiple versions of Python, this function 1747# In ebuilds of packages supporting installation for multiple Python ABIs, this function
1700# calls python_execute_trial_pre_hook() and python_execute_trial_post_hook(), if they are defined. 1748# calls python_execute_trial_pre_hook() and python_execute_trial_post_hook(), if they are defined.
1701python_execute_trial() { 1749python_execute_trial() {
1702 _python_set_color_variables 1750 _python_set_color_variables
1703 1751
1704 local PYTHONPATH_template= separate_build_dirs= 1752 local PYTHONPATH_template= separate_build_dirs=
1746 trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" || return "$?" 1794 trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" || return "$?"
1747 fi 1795 fi
1748 1796
1749 _python_test_hook post 1797 _python_test_hook post
1750 } 1798 }
1751 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 1799 if _python_package_supporting_installation_for_multiple_python_abis; then
1752 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@" 1800 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
1753 else 1801 else
1754 if [[ -n "${separate_build_dirs}" ]]; then 1802 if [[ -n "${separate_build_dirs}" ]]; then
1755 die "${FUNCNAME}(): Invalid usage" 1803 die "${FUNCNAME}(): Invalid usage"
1756 fi 1804 fi
1795# This function can be used only in pkg_postinst() phase. 1843# This function can be used only in pkg_postinst() phase.
1796python_mod_optimize() { 1844python_mod_optimize() {
1797 _python_initialize_prefix_variables 1845 _python_initialize_prefix_variables
1798 1846
1799 # Check if phase is pkg_postinst(). 1847 # Check if phase is pkg_postinst().
1800 [[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase" 1848 [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
1801 1849
1802 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 1850 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
1803 local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=() 1851 local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
1804 1852
1805 # Strip trailing slash from ROOT. 1853 # Strip trailing slash from ROOT.
1806 root="${EROOT%/}" 1854 root="${EROOT%/}"
1807 1855
1973 _python_set_color_variables 2021 _python_set_color_variables
1974 2022
1975 local path py_file PYTHON_ABI="${PYTHON_ABI}" SEARCH_PATH=() root 2023 local path py_file PYTHON_ABI="${PYTHON_ABI}" SEARCH_PATH=() root
1976 2024
1977 # Check if phase is pkg_postrm(). 2025 # Check if phase is pkg_postrm().
1978 [[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase" 2026 [[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
1979 2027
1980 # Strip trailing slash from ROOT. 2028 # Strip trailing slash from ROOT.
1981 root="${EROOT%/}" 2029 root="${EROOT%/}"
1982 2030
1983 if (($#)); then 2031 if (($#)); then
1984 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 2032 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
1985 while (($#)); do 2033 while (($#)); do
1986 if ! _python_implementation && [[ "$1" =~ ^"${EPREFIX}"/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then 2034 if ! _python_implementation && [[ "$1" =~ ^"${EPREFIX}"/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
1987 die "${FUNCNAME}() does not support absolute paths of directories/files in site-packages directories" 2035 die "${FUNCNAME}() does not support absolute paths of directories/files in site-packages directories"
1988 elif [[ "$1" =~ ^/ ]]; then 2036 elif [[ "$1" =~ ^/ ]]; then
1989 SEARCH_PATH+=("${root}/${1#/}") 2037 SEARCH_PATH+=("${root}/${1#/}")
2056# @FUNCTION: python_version 2104# @FUNCTION: python_version
2057# @DESCRIPTION: 2105# @DESCRIPTION:
2058# Run without arguments and it will export the version of python 2106# Run without arguments and it will export the version of python
2059# currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR 2107# currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
2060python_version() { 2108python_version() {
2061 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 2109 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
2062 eerror "Use PYTHON() and/or python_get_*() instead of ${FUNCNAME}()." 2110 eerror "Use PYTHON() and/or python_get_*() instead of ${FUNCNAME}()."
2063 die "${FUNCNAME}() cannot be used in this EAPI" 2111 die "${FUNCNAME}() cannot be used in this EAPI"
2064 fi 2112 fi
2065 2113
2114 _python_set_color_variables
2115
2066 if [[ "${FUNCNAME[1]}" != "distutils_python_version" ]]; then 2116 if [[ "${FUNCNAME[1]}" != "distutils_python_version" ]]; then
2067 einfo 2117 echo
2118 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
2119 echo " ${_RED}*${_NORMAL} ${_RED}Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables.${_NORMAL}"
2120 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2121 echo
2122
2123 einfo &> /dev/null
2068 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." 2124 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
2069 einfo "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables." 2125 einfo "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables." &> /dev/null
2070 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." 2126 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
2071 einfo 2127 einfo &> /dev/null
2072 fi 2128 fi
2073 2129
2074 [[ -n "${PYVER}" ]] && return 0 2130 [[ -n "${PYVER}" ]] && return 0
2075 local tmpstr 2131 local tmpstr
2076 python="${python:-${EPREFIX}/usr/bin/python}" 2132 python="${python:-${EPREFIX}/usr/bin/python}"
2095# Example: 2151# Example:
2096# if python_mod_exists gtk; then 2152# if python_mod_exists gtk; then
2097# echo "gtk support enabled" 2153# echo "gtk support enabled"
2098# fi 2154# fi
2099python_mod_exists() { 2155python_mod_exists() {
2100 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 2156 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
2101 eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()." 2157 eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
2102 die "${FUNCNAME}() cannot be used in this EAPI" 2158 die "${FUNCNAME}() cannot be used in this EAPI"
2103 fi 2159 fi
2104 2160
2105 einfo 2161 echo
2162 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
2163 echo " ${_RED}*${_NORMAL} ${_RED}Use USE dependencies and/or has_version() instead of ${FUNCNAME}().${_NORMAL}"
2164 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2165 echo
2166
2167 einfo &> /dev/null
2106 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." 2168 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
2107 einfo "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()." 2169 einfo "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()." &> /dev/null
2108 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." 2170 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
2109 einfo 2171 einfo &> /dev/null
2110 2172
2111 if [[ "$#" -ne 1 ]]; then 2173 if [[ "$#" -ne 1 ]]; then
2112 die "${FUNCNAME}() requires 1 argument" 2174 die "${FUNCNAME}() requires 1 argument"
2113 fi 2175 fi
2114 "$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null 2176 "$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null
2117# @FUNCTION: python_tkinter_exists 2179# @FUNCTION: python_tkinter_exists
2118# @DESCRIPTION: 2180# @DESCRIPTION:
2119# Run without arguments, checks if Python was compiled with Tkinter 2181# Run without arguments, checks if Python was compiled with Tkinter
2120# support. If not, prints an error message and dies. 2182# support. If not, prints an error message and dies.
2121python_tkinter_exists() { 2183python_tkinter_exists() {
2122 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 2184 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
2123 eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." 2185 eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
2124 die "${FUNCNAME}() cannot be used in this EAPI" 2186 die "${FUNCNAME}() cannot be used in this EAPI"
2125 fi 2187 fi
2126 2188
2127 if [[ "${FUNCNAME[1]}" != "distutils_python_tkinter" ]]; then 2189 if [[ "${FUNCNAME[1]}" != "distutils_python_tkinter" ]]; then
2128 einfo 2190 echo
2191 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
2192 echo " ${_RED}*${_NORMAL} ${_RED}Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}().${_NORMAL}"
2193 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2194 echo
2195
2196 einfo &> /dev/null
2129 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." 2197 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
2130 einfo "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." 2198 einfo "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." &> /dev/null
2131 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." 2199 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
2132 einfo 2200 einfo &> /dev/null
2133 fi 2201 fi
2134 2202
2135 if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info 2203 if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info
2136if version_info[0] == 3: 2204if version_info[0] == 3:
2137 import tkinter 2205 import tkinter
2152# 2220#
2153# Example: 2221# Example:
2154# python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py 2222# python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
2155# 2223#
2156python_mod_compile() { 2224python_mod_compile() {
2157 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 2225 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
2158 eerror "Use python_mod_optimize() instead of ${FUNCNAME}()." 2226 eerror "Use python_mod_optimize() instead of ${FUNCNAME}()."
2159 die "${FUNCNAME}() cannot be used in this EAPI" 2227 die "${FUNCNAME}() cannot be used in this EAPI"
2160 fi 2228 fi
2161 2229
2162 _python_initialize_prefix_variables 2230 _python_initialize_prefix_variables
2163 2231
2164 local f myroot myfiles=() 2232 local f myroot myfiles=()
2165 2233
2166 # Check if phase is pkg_postinst() 2234 # Check if phase is pkg_postinst()
2167 [[ ${EBUILD_PHASE} != postinst ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase" 2235 [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
2168 2236
2169 # strip trailing slash 2237 # strip trailing slash
2170 myroot="${EROOT%/}" 2238 myroot="${EROOT%/}"
2171 2239
2172 # respect ROOT 2240 # respect ROOT

Legend:
Removed from v.1.94  
changed lines
  Added in v.1.95

  ViewVC Help
Powered by ViewVC 1.1.20