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

Diff of /eclass/python.eclass

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

Revision 1.107 Revision 1.116
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2011 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.107 2010/12/26 11:30:27 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.116 2011/07/04 11:27:53 djc 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
14if ! has "${EAPI:-0}" 0 1 2 3; then 14if ! has "${EAPI:-0}" 0 1 2 3; then
15 die "API of python.eclass in EAPI=\"${EAPI}\" not established" 15 die "API of python.eclass in EAPI=\"${EAPI}\" not established"
16fi 16fi
17 17
18_CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7) 18_CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
19_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.0 3.1 3.2) 19_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.0 3.1 3.2 3.3)
20_JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython) 20_JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython)
21_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]}) 21_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]})
22 22
23# ================================================================================================ 23# ================================================================================================
24# ===================================== HANDLING OF METADATA ===================================== 24# ===================================== HANDLING OF METADATA =====================================
25# ================================================================================================ 25# ================================================================================================
26 26
27_python_check_python_abi_matching() { 27_python_check_python_abi_matching() {
28 local pattern patterns patterns_list="0" PYTHON_ABI
29
30 while (($#)); do
31 case "$1" in
32 --patterns-list)
33 patterns_list="1"
34 ;;
35 --)
36 shift
37 break
38 ;;
39 -*)
40 die "${FUNCNAME}(): Unrecognized option '$1'"
41 ;;
42 *)
43 break
44 ;;
45 esac
46 shift
47 done
48
28 if [[ "$#" -ne 2 ]]; then 49 if [[ "$#" -ne 2 ]]; then
29 die "${FUNCNAME}() requires 2 arguments" 50 die "${FUNCNAME}() requires 2 arguments"
30 fi 51 fi
31 52
53 PYTHON_ABI="$1"
54
55 if [[ "${patterns_list}" == "0" ]]; then
56 pattern="$2"
57
32 if [[ "$2" == *"-cpython" ]]; then 58 if [[ "${pattern}" == *"-cpython" ]]; then
33 [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ && "$1" == ${2%-cpython} ]] 59 [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ && "${PYTHON_ABI}" == ${pattern%-cpython} ]]
34 elif [[ "$2" == *"-jython" ]]; then 60 elif [[ "${pattern}" == *"-jython" ]]; then
35 [[ "$1" == $2 ]] 61 [[ "${PYTHON_ABI}" == ${pattern} ]]
36 else
37 if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
38 [[ "$1" == $2 ]]
39 elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
40 [[ "${1%-jython}" == $2 ]]
41 else 62 else
63 if [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
64 [[ "${PYTHON_ABI}" == ${pattern} ]]
65 elif [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
66 [[ "${PYTHON_ABI%-jython}" == ${pattern} ]]
67 else
42 die "${FUNCNAME}(): Unrecognized Python ABI '$1'" 68 die "${FUNCNAME}(): Unrecognized Python ABI '${PYTHON_ABI}'"
43 fi 69 fi
70 fi
71 else
72 patterns="${2// /$'\n'}"
73
74 while read pattern; do
75 if _python_check_python_abi_matching "${PYTHON_ABI}" "${pattern}"; then
76 return 0
77 fi
78 done <<< "${patterns}"
79
80 return 1
44 fi 81 fi
45} 82}
46 83
47# @ECLASS-VARIABLE: PYTHON_DEPEND 84# @ECLASS-VARIABLE: PYTHON_DEPEND
48# @DESCRIPTION: 85# @DESCRIPTION:
358# @DESCRIPTION: 395# @DESCRIPTION:
359# Perform sanity checks and initialize environment. 396# Perform sanity checks and initialize environment.
360# 397#
361# This function is exported in EAPI 2 and 3 when PYTHON_USE_WITH or PYTHON_USE_WITH_OR variable 398# This function is exported in EAPI 2 and 3 when PYTHON_USE_WITH or PYTHON_USE_WITH_OR variable
362# is set and always in EAPI >=4. Calling of this function is mandatory in EAPI >=4. 399# is set and always in EAPI >=4. Calling of this function is mandatory in EAPI >=4.
363#
364# This function can be used only in pkg_setup() phase.
365python_pkg_setup() { 400python_pkg_setup() {
366 # Check if phase is pkg_setup(). 401 if [[ "${EBUILD_PHASE}" != "setup" ]]; then
367 [[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase" 402 die "${FUNCNAME}() can be used only in pkg_setup() phase"
403 fi
368 404
369 if [[ "$#" -ne 0 ]]; then 405 if [[ "$#" -ne 0 ]]; then
370 die "${FUNCNAME}() does not accept arguments" 406 die "${FUNCNAME}() does not accept arguments"
371 fi 407 fi
372 408
513 549
514# @FUNCTION: python_clean_installation_image 550# @FUNCTION: python_clean_installation_image
515# @USAGE: [-q|--quiet] 551# @USAGE: [-q|--quiet]
516# @DESCRIPTION: 552# @DESCRIPTION:
517# Delete needless files in installation image. 553# Delete needless files in installation image.
554#
555# This function can be used only in src_install() phase.
518python_clean_installation_image() { 556python_clean_installation_image() {
557 if [[ "${EBUILD_PHASE}" != "install" ]]; then
558 die "${FUNCNAME}() can be used only in src_install() phase"
559 fi
560
519 _python_check_python_pkg_setup_execution 561 _python_check_python_pkg_setup_execution
520 _python_initialize_prefix_variables 562 _python_initialize_prefix_variables
521 563
522 local file files=() quiet="0" 564 local file files=() quiet="0"
523
524 # Check if phase is src_install().
525 [[ "${EBUILD_PHASE}" != "install" ]] && die "${FUNCNAME}() can be used only in src_install() phase"
526 565
527 while (($#)); do 566 while (($#)); do
528 case "$1" in 567 case "$1" in
529 -q|--quiet) 568 -q|--quiet)
530 quiet="1" 569 quiet="1"
581# @ECLASS-VARIABLE: SUPPORT_PYTHON_ABIS 620# @ECLASS-VARIABLE: SUPPORT_PYTHON_ABIS
582# @DESCRIPTION: 621# @DESCRIPTION:
583# Set this in EAPI <= 4 to indicate that current package supports installation for 622# Set this in EAPI <= 4 to indicate that current package supports installation for
584# multiple Python ABIs. 623# multiple Python ABIs.
585 624
625# @ECLASS-VARIABLE: PYTHON_TESTS_RESTRICTED_ABIS
626# @DESCRIPTION:
627# Space-separated list of Python ABI patterns. Testing in Python ABIs matching any Python ABI
628# patterns specified in this list is skipped.
629
586# @ECLASS-VARIABLE: PYTHON_EXPORT_PHASE_FUNCTIONS 630# @ECLASS-VARIABLE: PYTHON_EXPORT_PHASE_FUNCTIONS
587# @DESCRIPTION: 631# @DESCRIPTION:
588# Set this to export phase functions for the following ebuild phases: 632# Set this to export phase functions for the following ebuild phases:
589# src_prepare, src_configure, src_compile, src_test, src_install. 633# src_prepare(), src_configure(), src_compile(), src_test(), src_install().
590if ! has "${EAPI:-0}" 0 1; then 634if ! has "${EAPI:-0}" 0 1; then
591 python_src_prepare() { 635 python_src_prepare() {
592 _python_check_python_pkg_setup_execution 636 if [[ "${EBUILD_PHASE}" != "prepare" ]]; then
637 die "${FUNCNAME}() can be used only in src_prepare() phase"
638 fi
593 639
594 if ! _python_package_supporting_installation_for_multiple_python_abis; then 640 if ! _python_package_supporting_installation_for_multiple_python_abis; then
595 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" 641 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
596 fi 642 fi
597 643
644 _python_check_python_pkg_setup_execution
645
598 if [[ "$#" -ne 0 ]]; then 646 if [[ "$#" -ne 0 ]]; then
599 die "${FUNCNAME}() does not accept arguments" 647 die "${FUNCNAME}() does not accept arguments"
600 fi 648 fi
601 649
602 python_copy_sources 650 python_copy_sources
603 } 651 }
604 652
605 for python_default_function in src_configure src_compile src_test src_install; do 653 for python_default_function in src_configure src_compile src_test; do
606 eval "python_${python_default_function}() { 654 eval "python_${python_default_function}() {
607 _python_check_python_pkg_setup_execution 655 if [[ \"\${EBUILD_PHASE}\" != \"${python_default_function#src_}\" ]]; then
656 die \"\${FUNCNAME}() can be used only in ${python_default_function}() phase\"
657 fi
608 658
609 if ! _python_package_supporting_installation_for_multiple_python_abis; then 659 if ! _python_package_supporting_installation_for_multiple_python_abis; then
610 die \"\${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs\" 660 die \"\${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs\"
611 fi 661 fi
612 662
663 _python_check_python_pkg_setup_execution
664
613 python_execute_function -d -s -- \"\$@\" 665 python_execute_function -d -s -- \"\$@\"
614 }" 666 }"
615 done 667 done
616 unset python_default_function 668 unset python_default_function
617 669
670 python_src_install() {
671 if [[ "${EBUILD_PHASE}" != "install" ]]; then
672 die "${FUNCNAME}() can be used only in src_install() phase"
673 fi
674
675 if ! _python_package_supporting_installation_for_multiple_python_abis; then
676 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
677 fi
678
679 _python_check_python_pkg_setup_execution
680
681 if has "${EAPI:-0}" 0 1 2 3; then
682 python_execute_function -d -s -- "$@"
683 else
684 python_installation() {
685 emake DESTDIR="${T}/images/${PYTHON_ABI}" install "$@"
686 }
687 python_execute_function -s python_installation "$@"
688 unset python_installation
689
690 python_merge_intermediate_installation_images "${T}/images"
691 fi
692 }
693
618 if [[ -n "${PYTHON_EXPORT_PHASE_FUNCTIONS}" ]]; then 694 if [[ -n "${PYTHON_EXPORT_PHASE_FUNCTIONS}" ]]; then
619 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install 695 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
620 fi 696 fi
621fi 697fi
622 698
623if has "${EAPI:-0}" 0 1 2 3; then 699if has "${EAPI:-0}" 0 1 2 3 4; then
624 unset PYTHON_ABIS 700 unset PYTHON_ABIS
625fi 701fi
626 702
627_python_calculate_PYTHON_ABIS() { 703_python_calculate_PYTHON_ABIS() {
628 if ! _python_package_supporting_installation_for_multiple_python_abis; then 704 if ! _python_package_supporting_installation_for_multiple_python_abis; then
629 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" 705 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
630 fi 706 fi
631 707
632 _python_initial_sanity_checks 708 _python_initial_sanity_checks
633 709
634 if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then 710 if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then
635 local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI supported_PYTHON_ABIS 711 local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI supported_PYTHON_ABIS
636 712
637 restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}" 713 restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}"
638 714
639 if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then 715 if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
668 744
669 if [[ "${cpython_enabled}" == "0" ]]; then 745 if [[ "${cpython_enabled}" == "0" ]]; then
670 die "USE_PYTHON variable does not enable any CPython ABI" 746 die "USE_PYTHON variable does not enable any CPython ABI"
671 fi 747 fi
672 else 748 else
673 local python_version python2_version= python3_version= support_python_major_version 749 local python_version python2_version python3_version support_python_major_version
674 750
675 if ! has_version "dev-lang/python"; then 751 if ! has_version "dev-lang/python"; then
676 die "${FUNCNAME}(): 'dev-lang/python' is not installed" 752 die "${FUNCNAME}(): 'dev-lang/python' is not installed"
677 fi 753 fi
678 754
808# @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] 884# @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]
809# @DESCRIPTION: 885# @DESCRIPTION:
810# Execute specified function for each value of PYTHON_ABIS, optionally passing additional 886# Execute specified function for each value of PYTHON_ABIS, optionally passing additional
811# arguments. The specified function can use PYTHON_ABI and BUILDDIR variables. 887# arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
812python_execute_function() { 888python_execute_function() {
813 _python_check_python_pkg_setup_execution
814
815 if ! _python_package_supporting_installation_for_multiple_python_abis; then 889 if ! _python_package_supporting_installation_for_multiple_python_abis; then
816 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" 890 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
817 fi 891 fi
818 892
893 _python_check_python_pkg_setup_execution
819 _python_set_color_variables 894 _python_set_color_variables
820 895
821 local action action_message action_message_template= default_function="0" failure_message failure_message_template= final_ABI="0" function iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" return_code separate_build_dirs="0" source_dir= 896 local action action_message action_message_template default_function="0" failure_message failure_message_template final_ABI="0" function iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" return_code separate_build_dirs="0" source_dir
822 897
823 while (($#)); do 898 while (($#)); do
824 case "$1" in 899 case "$1" in
825 --action-message) 900 --action-message)
826 action_message_template="$2" 901 action_message_template="$2"
938 iterated_PYTHON_ABIS="$(PYTHON -f --ABI)" 1013 iterated_PYTHON_ABIS="$(PYTHON -f --ABI)"
939 else 1014 else
940 iterated_PYTHON_ABIS="${PYTHON_ABIS}" 1015 iterated_PYTHON_ABIS="${PYTHON_ABIS}"
941 fi 1016 fi
942 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do 1017 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
1018 if [[ "${EBUILD_PHASE}" == "test" ]] && _python_check_python_abi_matching --patterns-list "${PYTHON_ABI}" "${PYTHON_TESTS_RESTRICTED_ABIS}"; then
1019 if [[ "${quiet}" == "0" ]]; then
1020 echo " ${_GREEN}*${_NORMAL} ${_BLUE}Testing of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version) skipped${_NORMAL}"
1021 fi
1022 continue
1023 fi
1024
943 _python_prepare_flags 1025 _python_prepare_flags
944 1026
945 if [[ "${quiet}" == "0" ]]; then 1027 if [[ "${quiet}" == "0" ]]; then
946 if [[ -n "${action_message_template}" ]]; then 1028 if [[ -n "${action_message_template}" ]]; then
947 eval "action_message=\"${action_message_template}\"" 1029 eval "action_message=\"${action_message_template}\""
1041# @FUNCTION: python_copy_sources 1123# @FUNCTION: python_copy_sources
1042# @USAGE: <directory="${S}"> [directory] 1124# @USAGE: <directory="${S}"> [directory]
1043# @DESCRIPTION: 1125# @DESCRIPTION:
1044# Copy unpacked sources of current package to separate build directory for each Python ABI. 1126# Copy unpacked sources of current package to separate build directory for each Python ABI.
1045python_copy_sources() { 1127python_copy_sources() {
1046 _python_check_python_pkg_setup_execution
1047
1048 if ! _python_package_supporting_installation_for_multiple_python_abis; then 1128 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1049 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" 1129 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1050 fi 1130 fi
1131
1132 _python_check_python_pkg_setup_execution
1051 1133
1052 local dir dirs=() PYTHON_ABI 1134 local dir dirs=() PYTHON_ABI
1053 1135
1054 if [[ "$#" -eq 0 ]]; then 1136 if [[ "$#" -eq 0 ]]; then
1055 if [[ "${WORKDIR}" == "${S}" ]]; then 1137 if [[ "${WORKDIR}" == "${S}" ]]; then
1072# @USAGE: [-E|--respect-EPYTHON] [-f|--force] [-q|--quiet] [--] <file> [files] 1154# @USAGE: [-E|--respect-EPYTHON] [-f|--force] [-q|--quiet] [--] <file> [files]
1073# @DESCRIPTION: 1155# @DESCRIPTION:
1074# Generate wrapper scripts. Existing files are overwritten only with --force option. 1156# Generate wrapper scripts. Existing files are overwritten only with --force option.
1075# If --respect-EPYTHON option is specified, then generated wrapper scripts will 1157# If --respect-EPYTHON option is specified, then generated wrapper scripts will
1076# respect EPYTHON variable at run time. 1158# respect EPYTHON variable at run time.
1159#
1160# This function can be used only in src_install() phase.
1077python_generate_wrapper_scripts() { 1161python_generate_wrapper_scripts() {
1078 _python_check_python_pkg_setup_execution 1162 if [[ "${EBUILD_PHASE}" != "install" ]]; then
1163 die "${FUNCNAME}() can be used only in src_install() phase"
1164 fi
1079 1165
1080 if ! _python_package_supporting_installation_for_multiple_python_abis; then 1166 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1081 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" 1167 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1082 fi 1168 fi
1083 1169
1170 _python_check_python_pkg_setup_execution
1084 _python_initialize_prefix_variables 1171 _python_initialize_prefix_variables
1085 1172
1086 local eselect_python_option file force="0" quiet="0" PYTHON_ABI PYTHON_ABIS_list python2_enabled="0" python3_enabled="0" respect_EPYTHON="0" 1173 local eselect_python_option file force="0" quiet="0" PYTHON_ABI PYTHON_ABIS_list python2_enabled="0" python3_enabled="0" respect_EPYTHON="0"
1087 1174
1088 while (($#)); do 1175 while (($#)); do
1319 1406
1320# @FUNCTION: python_merge_intermediate_installation_images 1407# @FUNCTION: python_merge_intermediate_installation_images
1321# @USAGE: [-q|--quiet] [--] <intermediate_installation_images_directory> 1408# @USAGE: [-q|--quiet] [--] <intermediate_installation_images_directory>
1322# @DESCRIPTION: 1409# @DESCRIPTION:
1323# Merge intermediate installation images into installation image. 1410# Merge intermediate installation images into installation image.
1411#
1412# This function can be used only in src_install() phase.
1324python_merge_intermediate_installation_images() { 1413python_merge_intermediate_installation_images() {
1414 if [[ "${EBUILD_PHASE}" != "install" ]]; then
1415 die "${FUNCNAME}() can be used only in src_install() phase"
1416 fi
1417
1418 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1419 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1420 fi
1421
1325 _python_check_python_pkg_setup_execution 1422 _python_check_python_pkg_setup_execution
1326 _python_initialize_prefix_variables 1423 _python_initialize_prefix_variables
1327 1424
1328 local b file files=() intermediate_installation_images_directory PYTHON_ABI quiet="0" regex shebang version_executable wrapper_scripts=() wrapper_scripts_set=() 1425 local b file files=() intermediate_installation_images_directory PYTHON_ABI quiet="0" regex shebang version_executable wrapper_scripts=() wrapper_scripts_set=()
1329
1330 # Check if phase is src_install().
1331 [[ "${EBUILD_PHASE}" != "install" ]] && die "${FUNCNAME}() can be used only in src_install() phase"
1332 1426
1333 while (($#)); do 1427 while (($#)); do
1334 case "$1" in 1428 case "$1" in
1335 -q|--quiet) 1429 -q|--quiet)
1336 quiet="1" 1430 quiet="1"
1447 fi 1541 fi
1448 done 1542 done
1449 1543
1450 popd > /dev/null || die "popd failed" 1544 popd > /dev/null || die "popd failed"
1451 1545
1546 if ROOT="/" has_version sys-apps/coreutils; then
1452 cp -fr --preserve=all "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${ED}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed" 1547 cp -fr --preserve=all "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${D}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
1548 else
1549 cp -fpr "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${D}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
1550 fi
1453 done 1551 done
1454 1552
1455 rm -fr "${intermediate_installation_images_directory}" 1553 rm -fr "${intermediate_installation_images_directory}"
1456 1554
1457 if [[ "${#wrapper_scripts[@]}" -ge 1 ]]; then 1555 if [[ "${#wrapper_scripts[@]}" -ge 1 ]]; then
1498# If 2 argument is specified, then active version of CPython 2 is used. 1596# If 2 argument is specified, then active version of CPython 2 is used.
1499# If 3 argument is specified, then active version of CPython 3 is used. 1597# If 3 argument is specified, then active version of CPython 3 is used.
1500# 1598#
1501# This function can be used only in pkg_setup() phase. 1599# This function can be used only in pkg_setup() phase.
1502python_set_active_version() { 1600python_set_active_version() {
1503 # Check if phase is pkg_setup(). 1601 if [[ "${EBUILD_PHASE}" != "setup" ]]; then
1504 [[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase" 1602 die "${FUNCNAME}() can be used only in pkg_setup() phase"
1603 fi
1505 1604
1506 if _python_package_supporting_installation_for_multiple_python_abis; then 1605 if _python_package_supporting_installation_for_multiple_python_abis; then
1507 die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" 1606 die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
1508 fi 1607 fi
1509 1608
1549 1648
1550# @FUNCTION: python_need_rebuild 1649# @FUNCTION: python_need_rebuild
1551# @DESCRIPTION: Mark current package for rebuilding by python-updater after 1650# @DESCRIPTION: Mark current package for rebuilding by python-updater after
1552# switching of active version of Python. 1651# switching of active version of Python.
1553python_need_rebuild() { 1652python_need_rebuild() {
1554 _python_check_python_pkg_setup_execution
1555
1556 if _python_package_supporting_installation_for_multiple_python_abis; then 1653 if _python_package_supporting_installation_for_multiple_python_abis; then
1557 die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" 1654 die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
1558 fi 1655 fi
1656
1657 _python_check_python_pkg_setup_execution
1559 1658
1560 if [[ "$#" -ne 0 ]]; then 1659 if [[ "$#" -ne 0 ]]; then
1561 die "${FUNCNAME}() does not accept arguments" 1660 die "${FUNCNAME}() does not accept arguments"
1562 fi 1661 fi
1563 1662
2158# python_execute_nosetests_pre_hook() and python_execute_nosetests_post_hook(), if they are defined. 2257# python_execute_nosetests_pre_hook() and python_execute_nosetests_post_hook(), if they are defined.
2159python_execute_nosetests() { 2258python_execute_nosetests() {
2160 _python_check_python_pkg_setup_execution 2259 _python_check_python_pkg_setup_execution
2161 _python_set_color_variables 2260 _python_set_color_variables
2162 2261
2163 local PYTHONPATH_template= separate_build_dirs= 2262 local PYTHONPATH_template separate_build_dirs
2164 2263
2165 while (($#)); do 2264 while (($#)); do
2166 case "$1" in 2265 case "$1" in
2167 -P|--PYTHONPATH) 2266 -P|--PYTHONPATH)
2168 PYTHONPATH_template="$2" 2267 PYTHONPATH_template="$2"
2222# python_execute_py.test_pre_hook() and python_execute_py.test_post_hook(), if they are defined. 2321# python_execute_py.test_pre_hook() and python_execute_py.test_post_hook(), if they are defined.
2223python_execute_py.test() { 2322python_execute_py.test() {
2224 _python_check_python_pkg_setup_execution 2323 _python_check_python_pkg_setup_execution
2225 _python_set_color_variables 2324 _python_set_color_variables
2226 2325
2227 local PYTHONPATH_template= separate_build_dirs= 2326 local PYTHONPATH_template separate_build_dirs
2228 2327
2229 while (($#)); do 2328 while (($#)); do
2230 case "$1" in 2329 case "$1" in
2231 -P|--PYTHONPATH) 2330 -P|--PYTHONPATH)
2232 PYTHONPATH_template="$2" 2331 PYTHONPATH_template="$2"
2286# calls python_execute_trial_pre_hook() and python_execute_trial_post_hook(), if they are defined. 2385# calls python_execute_trial_pre_hook() and python_execute_trial_post_hook(), if they are defined.
2287python_execute_trial() { 2386python_execute_trial() {
2288 _python_check_python_pkg_setup_execution 2387 _python_check_python_pkg_setup_execution
2289 _python_set_color_variables 2388 _python_set_color_variables
2290 2389
2291 local PYTHONPATH_template= separate_build_dirs= 2390 local PYTHONPATH_template separate_build_dirs
2292 2391
2293 while (($#)); do 2392 while (($#)); do
2294 case "$1" in 2393 case "$1" in
2295 -P|--PYTHONPATH) 2394 -P|--PYTHONPATH)
2296 PYTHONPATH_template="$2" 2395 PYTHONPATH_template="$2"
2471# Byte-compile specified Python modules. 2570# Byte-compile specified Python modules.
2472# -d, -f, -l, -q and -x options passed to this function are passed to compileall.py. 2571# -d, -f, -l, -q and -x options passed to this function are passed to compileall.py.
2473# 2572#
2474# This function can be used only in pkg_postinst() phase. 2573# This function can be used only in pkg_postinst() phase.
2475python_mod_optimize() { 2574python_mod_optimize() {
2575 if [[ "${EBUILD_PHASE}" != "postinst" ]]; then
2576 die "${FUNCNAME}() can be used only in pkg_postinst() phase"
2577 fi
2578
2476 _python_check_python_pkg_setup_execution 2579 _python_check_python_pkg_setup_execution
2477 _python_initialize_prefix_variables 2580 _python_initialize_prefix_variables
2478
2479 # Check if phase is pkg_postinst().
2480 [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
2481 2581
2482 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis || _python_implementation || [[ "${CATEGORY}/${PN}" == "sys-apps/portage" ]]; then 2582 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis || _python_implementation || [[ "${CATEGORY}/${PN}" == "sys-apps/portage" ]]; then
2483 # PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs. 2583 # PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs.
2484 local allow_evaluated_non_sitedir_paths="0" dir dirs=() evaluated_dirs=() evaluated_files=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=() 2584 local allow_evaluated_non_sitedir_paths="0" dir dirs=() evaluated_dirs=() evaluated_files=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=()
2485 2585
2646 fi 2746 fi
2647 eend "${return_code}" 2747 eend "${return_code}"
2648 fi 2748 fi
2649 else 2749 else
2650 # Deprecated part of python_mod_optimize() 2750 # Deprecated part of python_mod_optimize()
2651 # ewarn 2751 ewarn
2652 # ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation" 2752 ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
2653 # ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-06-01." 2753 ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-08-01."
2654 # ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax." 2754 ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
2655 # ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." 2755 ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
2656 # ewarn 2756 ewarn
2657 2757
2658 local myroot mydirs=() myfiles=() myopts=() return_code="0" 2758 local myroot mydirs=() myfiles=() myopts=() return_code="0"
2659 2759
2660 # strip trailing slash 2760 # strip trailing slash
2661 myroot="${EROOT%/}" 2761 myroot="${EROOT%/}"
2730# @DESCRIPTION: 2830# @DESCRIPTION:
2731# Delete orphaned byte-compiled Python modules corresponding to specified Python modules. 2831# Delete orphaned byte-compiled Python modules corresponding to specified Python modules.
2732# 2832#
2733# This function can be used only in pkg_postrm() phase. 2833# This function can be used only in pkg_postrm() phase.
2734python_mod_cleanup() { 2834python_mod_cleanup() {
2835 if [[ "${EBUILD_PHASE}" != "postrm" ]]; then
2836 die "${FUNCNAME}() can be used only in pkg_postrm() phase"
2837 fi
2838
2735 _python_check_python_pkg_setup_execution 2839 _python_check_python_pkg_setup_execution
2736 _python_initialize_prefix_variables 2840 _python_initialize_prefix_variables
2737 2841
2738 local allow_evaluated_non_sitedir_paths="0" dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir 2842 local allow_evaluated_non_sitedir_paths="0" dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
2739
2740 # Check if phase is pkg_postrm().
2741 [[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
2742 2843
2743 if _python_package_supporting_installation_for_multiple_python_abis; then 2844 if _python_package_supporting_installation_for_multiple_python_abis; then
2744 if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then 2845 if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
2745 die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called" 2846 die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called"
2746 fi 2847 fi
2810 fi 2911 fi
2811 shift 2912 shift
2812 done 2913 done
2813 else 2914 else
2814 # Deprecated part of python_mod_cleanup() 2915 # Deprecated part of python_mod_cleanup()
2815 # ewarn 2916 ewarn
2816 # ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation" 2917 ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
2817 # ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-06-01." 2918 ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-08-01."
2818 # ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax." 2919 ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
2819 # ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." 2920 ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
2820 # ewarn 2921 ewarn
2821 2922
2822 search_paths=("${@#/}") 2923 search_paths=("${@#/}")
2823 search_paths=("${search_paths[@]/#/${root}/}") 2924 search_paths=("${search_paths[@]/#/${root}/}")
2824 fi 2925 fi
2825 2926
2827} 2928}
2828 2929
2829# ================================================================================================ 2930# ================================================================================================
2830# ===================================== DEPRECATED FUNCTIONS ===================================== 2931# ===================================== DEPRECATED FUNCTIONS =====================================
2831# ================================================================================================ 2932# ================================================================================================
2832
2833# Scheduled for deletion on 2011-01-01.
2834python_version() {
2835 eerror "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables."
2836 die "${FUNCNAME}() is banned"
2837}
2838
2839# Scheduled for deletion on 2011-01-01.
2840python_mod_exists() {
2841 eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
2842 die "${FUNCNAME}() is banned"
2843}
2844
2845# Scheduled for deletion on 2011-01-01.
2846python_tkinter_exists() {
2847 eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
2848 die "${FUNCNAME}() is banned"
2849}
2850
2851# Scheduled for deletion on 2011-04-01.
2852python_mod_compile() {
2853 eerror "Use python_mod_optimize() instead of ${FUNCNAME}()."
2854 die "${FUNCNAME}() is banned"
2855}

Legend:
Removed from v.1.107  
changed lines
  Added in v.1.116

  ViewVC Help
Powered by ViewVC 1.1.20