| 1 | # Copyright 1999-2011 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.113 2011/07/04 10:59:25 djc 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 |
| … | |
… | |
| 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. |
|
|
| 365 | python_pkg_setup() { |
400 | python_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. |
| 518 | python_clean_installation_image() { |
556 | python_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(). |
| 590 | if ! has "${EAPI:-0}" 0 1; then |
634 | if ! 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; 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 | |
| 618 | python_src_install() { |
670 | python_src_install() { |
|
|
671 | if [[ "${EBUILD_PHASE}" != "install" ]]; then |
|
|
672 | die "${FUNCNAME}() can be used only in src_install() phase" |
|
|
673 | fi |
|
|
674 | |
| 619 | if ! _python_package_supporting_installation_for_multiple_python_abis; then |
675 | if ! _python_package_supporting_installation_for_multiple_python_abis; then |
| 620 | die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" |
676 | die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" |
| 621 | fi |
677 | fi |
| 622 | |
678 | |
| 623 | _python_check_python_pkg_setup_execution |
679 | _python_check_python_pkg_setup_execution |
| … | |
… | |
| 688 | |
744 | |
| 689 | if [[ "${cpython_enabled}" == "0" ]]; then |
745 | if [[ "${cpython_enabled}" == "0" ]]; then |
| 690 | die "USE_PYTHON variable does not enable any CPython ABI" |
746 | die "USE_PYTHON variable does not enable any CPython ABI" |
| 691 | fi |
747 | fi |
| 692 | else |
748 | else |
| 693 | local python_version python2_version= python3_version= support_python_major_version |
749 | local python_version python2_version python3_version support_python_major_version |
| 694 | |
750 | |
| 695 | if ! has_version "dev-lang/python"; then |
751 | if ! has_version "dev-lang/python"; then |
| 696 | die "${FUNCNAME}(): 'dev-lang/python' is not installed" |
752 | die "${FUNCNAME}(): 'dev-lang/python' is not installed" |
| 697 | fi |
753 | fi |
| 698 | |
754 | |
| … | |
… | |
| 828 | # @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] |
| 829 | # @DESCRIPTION: |
885 | # @DESCRIPTION: |
| 830 | # 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 |
| 831 | # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables. |
887 | # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables. |
| 832 | python_execute_function() { |
888 | python_execute_function() { |
| 833 | _python_check_python_pkg_setup_execution |
|
|
| 834 | |
|
|
| 835 | if ! _python_package_supporting_installation_for_multiple_python_abis; then |
889 | if ! _python_package_supporting_installation_for_multiple_python_abis; then |
| 836 | 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" |
| 837 | fi |
891 | fi |
| 838 | |
892 | |
|
|
893 | _python_check_python_pkg_setup_execution |
| 839 | _python_set_color_variables |
894 | _python_set_color_variables |
| 840 | |
895 | |
| 841 | 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 |
| 842 | |
897 | |
| 843 | while (($#)); do |
898 | while (($#)); do |
| 844 | case "$1" in |
899 | case "$1" in |
| 845 | --action-message) |
900 | --action-message) |
| 846 | action_message_template="$2" |
901 | action_message_template="$2" |
| … | |
… | |
| 958 | iterated_PYTHON_ABIS="$(PYTHON -f --ABI)" |
1013 | iterated_PYTHON_ABIS="$(PYTHON -f --ABI)" |
| 959 | else |
1014 | else |
| 960 | iterated_PYTHON_ABIS="${PYTHON_ABIS}" |
1015 | iterated_PYTHON_ABIS="${PYTHON_ABIS}" |
| 961 | fi |
1016 | fi |
| 962 | 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 | |
| 963 | _python_prepare_flags |
1025 | _python_prepare_flags |
| 964 | |
1026 | |
| 965 | if [[ "${quiet}" == "0" ]]; then |
1027 | if [[ "${quiet}" == "0" ]]; then |
| 966 | if [[ -n "${action_message_template}" ]]; then |
1028 | if [[ -n "${action_message_template}" ]]; then |
| 967 | eval "action_message=\"${action_message_template}\"" |
1029 | eval "action_message=\"${action_message_template}\"" |
| … | |
… | |
| 1061 | # @FUNCTION: python_copy_sources |
1123 | # @FUNCTION: python_copy_sources |
| 1062 | # @USAGE: <directory="${S}"> [directory] |
1124 | # @USAGE: <directory="${S}"> [directory] |
| 1063 | # @DESCRIPTION: |
1125 | # @DESCRIPTION: |
| 1064 | # 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. |
| 1065 | python_copy_sources() { |
1127 | python_copy_sources() { |
| 1066 | _python_check_python_pkg_setup_execution |
|
|
| 1067 | |
|
|
| 1068 | if ! _python_package_supporting_installation_for_multiple_python_abis; then |
1128 | if ! _python_package_supporting_installation_for_multiple_python_abis; then |
| 1069 | 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" |
| 1070 | fi |
1130 | fi |
|
|
1131 | |
|
|
1132 | _python_check_python_pkg_setup_execution |
| 1071 | |
1133 | |
| 1072 | local dir dirs=() PYTHON_ABI |
1134 | local dir dirs=() PYTHON_ABI |
| 1073 | |
1135 | |
| 1074 | if [[ "$#" -eq 0 ]]; then |
1136 | if [[ "$#" -eq 0 ]]; then |
| 1075 | if [[ "${WORKDIR}" == "${S}" ]]; then |
1137 | if [[ "${WORKDIR}" == "${S}" ]]; then |
| … | |
… | |
| 1092 | # @USAGE: [-E|--respect-EPYTHON] [-f|--force] [-q|--quiet] [--] <file> [files] |
1154 | # @USAGE: [-E|--respect-EPYTHON] [-f|--force] [-q|--quiet] [--] <file> [files] |
| 1093 | # @DESCRIPTION: |
1155 | # @DESCRIPTION: |
| 1094 | # Generate wrapper scripts. Existing files are overwritten only with --force option. |
1156 | # Generate wrapper scripts. Existing files are overwritten only with --force option. |
| 1095 | # If --respect-EPYTHON option is specified, then generated wrapper scripts will |
1157 | # If --respect-EPYTHON option is specified, then generated wrapper scripts will |
| 1096 | # 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. |
| 1097 | python_generate_wrapper_scripts() { |
1161 | python_generate_wrapper_scripts() { |
| 1098 | _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 |
| 1099 | |
1165 | |
| 1100 | if ! _python_package_supporting_installation_for_multiple_python_abis; then |
1166 | if ! _python_package_supporting_installation_for_multiple_python_abis; then |
| 1101 | 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" |
| 1102 | fi |
1168 | fi |
| 1103 | |
1169 | |
|
|
1170 | _python_check_python_pkg_setup_execution |
| 1104 | _python_initialize_prefix_variables |
1171 | _python_initialize_prefix_variables |
| 1105 | |
1172 | |
| 1106 | 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" |
| 1107 | |
1174 | |
| 1108 | while (($#)); do |
1175 | while (($#)); do |
| … | |
… | |
| 1339 | |
1406 | |
| 1340 | # @FUNCTION: python_merge_intermediate_installation_images |
1407 | # @FUNCTION: python_merge_intermediate_installation_images |
| 1341 | # @USAGE: [-q|--quiet] [--] <intermediate_installation_images_directory> |
1408 | # @USAGE: [-q|--quiet] [--] <intermediate_installation_images_directory> |
| 1342 | # @DESCRIPTION: |
1409 | # @DESCRIPTION: |
| 1343 | # 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. |
| 1344 | python_merge_intermediate_installation_images() { |
1413 | python_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 | |
| 1345 | _python_check_python_pkg_setup_execution |
1422 | _python_check_python_pkg_setup_execution |
| 1346 | _python_initialize_prefix_variables |
1423 | _python_initialize_prefix_variables |
| 1347 | |
1424 | |
| 1348 | 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=() |
| 1349 | |
|
|
| 1350 | # Check if phase is src_install(). |
|
|
| 1351 | [[ "${EBUILD_PHASE}" != "install" ]] && die "${FUNCNAME}() can be used only in src_install() phase" |
|
|
| 1352 | |
1426 | |
| 1353 | while (($#)); do |
1427 | while (($#)); do |
| 1354 | case "$1" in |
1428 | case "$1" in |
| 1355 | -q|--quiet) |
1429 | -q|--quiet) |
| 1356 | quiet="1" |
1430 | quiet="1" |
| … | |
… | |
| 1522 | # 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. |
| 1523 | # 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. |
| 1524 | # |
1598 | # |
| 1525 | # This function can be used only in pkg_setup() phase. |
1599 | # This function can be used only in pkg_setup() phase. |
| 1526 | python_set_active_version() { |
1600 | python_set_active_version() { |
| 1527 | # Check if phase is pkg_setup(). |
1601 | if [[ "${EBUILD_PHASE}" != "setup" ]]; then |
| 1528 | [[ "${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 |
| 1529 | |
1604 | |
| 1530 | if _python_package_supporting_installation_for_multiple_python_abis; then |
1605 | if _python_package_supporting_installation_for_multiple_python_abis; then |
| 1531 | 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" |
| 1532 | fi |
1607 | fi |
| 1533 | |
1608 | |
| … | |
… | |
| 1573 | |
1648 | |
| 1574 | # @FUNCTION: python_need_rebuild |
1649 | # @FUNCTION: python_need_rebuild |
| 1575 | # @DESCRIPTION: Mark current package for rebuilding by python-updater after |
1650 | # @DESCRIPTION: Mark current package for rebuilding by python-updater after |
| 1576 | # switching of active version of Python. |
1651 | # switching of active version of Python. |
| 1577 | python_need_rebuild() { |
1652 | python_need_rebuild() { |
| 1578 | _python_check_python_pkg_setup_execution |
|
|
| 1579 | |
|
|
| 1580 | if _python_package_supporting_installation_for_multiple_python_abis; then |
1653 | if _python_package_supporting_installation_for_multiple_python_abis; then |
| 1581 | 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" |
| 1582 | fi |
1655 | fi |
|
|
1656 | |
|
|
1657 | _python_check_python_pkg_setup_execution |
| 1583 | |
1658 | |
| 1584 | if [[ "$#" -ne 0 ]]; then |
1659 | if [[ "$#" -ne 0 ]]; then |
| 1585 | die "${FUNCNAME}() does not accept arguments" |
1660 | die "${FUNCNAME}() does not accept arguments" |
| 1586 | fi |
1661 | fi |
| 1587 | |
1662 | |
| … | |
… | |
| 2182 | # 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. |
| 2183 | python_execute_nosetests() { |
2258 | python_execute_nosetests() { |
| 2184 | _python_check_python_pkg_setup_execution |
2259 | _python_check_python_pkg_setup_execution |
| 2185 | _python_set_color_variables |
2260 | _python_set_color_variables |
| 2186 | |
2261 | |
| 2187 | local PYTHONPATH_template= separate_build_dirs= |
2262 | local PYTHONPATH_template separate_build_dirs |
| 2188 | |
2263 | |
| 2189 | while (($#)); do |
2264 | while (($#)); do |
| 2190 | case "$1" in |
2265 | case "$1" in |
| 2191 | -P|--PYTHONPATH) |
2266 | -P|--PYTHONPATH) |
| 2192 | PYTHONPATH_template="$2" |
2267 | PYTHONPATH_template="$2" |
| … | |
… | |
| 2246 | # 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. |
| 2247 | python_execute_py.test() { |
2322 | python_execute_py.test() { |
| 2248 | _python_check_python_pkg_setup_execution |
2323 | _python_check_python_pkg_setup_execution |
| 2249 | _python_set_color_variables |
2324 | _python_set_color_variables |
| 2250 | |
2325 | |
| 2251 | local PYTHONPATH_template= separate_build_dirs= |
2326 | local PYTHONPATH_template separate_build_dirs |
| 2252 | |
2327 | |
| 2253 | while (($#)); do |
2328 | while (($#)); do |
| 2254 | case "$1" in |
2329 | case "$1" in |
| 2255 | -P|--PYTHONPATH) |
2330 | -P|--PYTHONPATH) |
| 2256 | PYTHONPATH_template="$2" |
2331 | PYTHONPATH_template="$2" |
| … | |
… | |
| 2310 | # 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. |
| 2311 | python_execute_trial() { |
2386 | python_execute_trial() { |
| 2312 | _python_check_python_pkg_setup_execution |
2387 | _python_check_python_pkg_setup_execution |
| 2313 | _python_set_color_variables |
2388 | _python_set_color_variables |
| 2314 | |
2389 | |
| 2315 | local PYTHONPATH_template= separate_build_dirs= |
2390 | local PYTHONPATH_template separate_build_dirs |
| 2316 | |
2391 | |
| 2317 | while (($#)); do |
2392 | while (($#)); do |
| 2318 | case "$1" in |
2393 | case "$1" in |
| 2319 | -P|--PYTHONPATH) |
2394 | -P|--PYTHONPATH) |
| 2320 | PYTHONPATH_template="$2" |
2395 | PYTHONPATH_template="$2" |
| … | |
… | |
| 2495 | # Byte-compile specified Python modules. |
2570 | # Byte-compile specified Python modules. |
| 2496 | # -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. |
| 2497 | # |
2572 | # |
| 2498 | # This function can be used only in pkg_postinst() phase. |
2573 | # This function can be used only in pkg_postinst() phase. |
| 2499 | python_mod_optimize() { |
2574 | python_mod_optimize() { |
|
|
2575 | if [[ "${EBUILD_PHASE}" != "postinst" ]]; then |
|
|
2576 | die "${FUNCNAME}() can be used only in pkg_postinst() phase" |
|
|
2577 | fi |
|
|
2578 | |
| 2500 | _python_check_python_pkg_setup_execution |
2579 | _python_check_python_pkg_setup_execution |
| 2501 | _python_initialize_prefix_variables |
2580 | _python_initialize_prefix_variables |
| 2502 | |
|
|
| 2503 | # Check if phase is pkg_postinst(). |
|
|
| 2504 | [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase" |
|
|
| 2505 | |
2581 | |
| 2506 | 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 |
| 2507 | # 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. |
| 2508 | 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=() |
| 2509 | |
2585 | |
| … | |
… | |
| 2754 | # @DESCRIPTION: |
2830 | # @DESCRIPTION: |
| 2755 | # Delete orphaned byte-compiled Python modules corresponding to specified Python modules. |
2831 | # Delete orphaned byte-compiled Python modules corresponding to specified Python modules. |
| 2756 | # |
2832 | # |
| 2757 | # This function can be used only in pkg_postrm() phase. |
2833 | # This function can be used only in pkg_postrm() phase. |
| 2758 | python_mod_cleanup() { |
2834 | python_mod_cleanup() { |
|
|
2835 | if [[ "${EBUILD_PHASE}" != "postrm" ]]; then |
|
|
2836 | die "${FUNCNAME}() can be used only in pkg_postrm() phase" |
|
|
2837 | fi |
|
|
2838 | |
| 2759 | _python_check_python_pkg_setup_execution |
2839 | _python_check_python_pkg_setup_execution |
| 2760 | _python_initialize_prefix_variables |
2840 | _python_initialize_prefix_variables |
| 2761 | |
2841 | |
| 2762 | 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 |
| 2763 | |
|
|
| 2764 | # Check if phase is pkg_postrm(). |
|
|
| 2765 | [[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase" |
|
|
| 2766 | |
2843 | |
| 2767 | if _python_package_supporting_installation_for_multiple_python_abis; then |
2844 | if _python_package_supporting_installation_for_multiple_python_abis; then |
| 2768 | 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 |
| 2769 | die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called" |
2846 | die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called" |
| 2770 | fi |
2847 | fi |