Gentoo Development Guide
PYTHON.ECLASS
Section: portage (5)Updated: May 2013
Index Return to Main Contents
NAME
python.eclass - Eclass for Python packagesDESCRIPTION
The python eclass contains miscellaneous, useful functions for Python packages.FUNCTIONS
- python_pkg_setup
-
Perform sanity checks and initialize environment.
This function is exported in EAPI 2 and 3 when PYTHON_USE_WITH or PYTHON_USE_WITH_OR variable is set and always in EAPI >=4. Calling of this function is mandatory in EAPI >=4.
- python_convert_shebangs [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_ABI|Python_version> <file|directory> [files|directories]
- Convert shebangs in specified files. Directories can be specified only with --recursive option.
- python_clean_py-compile_files [-q|--quiet]
- Clean py-compile files to disable byte-compilation.
- python_clean_installation_image [-q|--quiet]
-
Delete needless files in installation image.
This function can be used only in src_install() phase.
- python_execute_function [--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]
- Execute specified function for each value of PYTHON_ABIS, optionally passing additional arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
- python_copy_sources <directory="${S}"> [directory]
- Copy unpacked sources of current package to separate build directory for each Python ABI.
- python_generate_wrapper_scripts [-E|--respect-EPYTHON] [-f|--force] [-q|--quiet] [--] <file> [files]
-
Generate wrapper scripts. Existing files are overwritten only with --force option.
If --respect-EPYTHON option is specified, then generated wrapper scripts will
respect EPYTHON variable at run time.
This function can be used only in src_install() phase.
- python_merge_intermediate_installation_images [-q|--quiet] [--] <intermediate_installation_images_directory>
-
Merge intermediate installation images into installation image.
This function can be used only in src_install() phase.
- python_set_active_version <Python_ABI|2|3>
-
Set locally active version of Python.
If Python_ABI argument is specified, then version of Python corresponding to Python_ABI is used.
If 2 argument is specified, then active version of CPython 2 is used.
If 3 argument is specified, then active version of CPython 3 is used.
This function can be used only in pkg_setup() phase.
- python_need_rebuild
- Mark current package for rebuilding by python-updater after switching of active version of Python.
- PYTHON [-2] [-3] [--ABI] [-a|--absolute-path] [-f|--final-ABI] [--] <Python_ABI="${PYTHON_ABI}">
- Print filename of Python interpreter for specified Python ABI. If Python_ABI argument is ommitted, then PYTHON_ABI environment variable must be set and is used. If -2 option is specified, then active version of CPython 2 is used. If -3 option is specified, then active version of CPython 3 is used. If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. -2, -3 and --final-ABI options and Python_ABI argument cannot be specified simultaneously. If --ABI option is specified, then only specified Python ABI is printed instead of filename of Python interpreter. If --absolute-path option is specified, then absolute path to Python interpreter is printed. --ABI and --absolute-path options cannot be specified simultaneously.
- python_get_implementation [-f|--final-ABI]
- Print name of Python implementation. If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
- python_get_implementational_package [-f|--final-ABI]
- Print category, name and slot of package providing Python implementation. If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
- python_get_includedir [-b|--base-path] [-f|--final-ABI]
- Print path to Python include directory. If --base-path option is specified, then path not prefixed with "/" is printed. If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
- python_get_libdir [-b|--base-path] [-f|--final-ABI]
- Print path to Python standard library directory. If --base-path option is specified, then path not prefixed with "/" is printed. If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
- python_get_sitedir [-b|--base-path] [-f|--final-ABI]
- Print path to Python site-packages directory. If --base-path option is specified, then path not prefixed with "/" is printed. If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
- python_get_library [-b|--base-path] [-f|--final-ABI] [-l|--linker-option]
- Print path to Python library. If --base-path option is specified, then path not prefixed with "/" is printed. If --linker-option is specified, then "-l${library}" linker option is printed. If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
- python_get_version [-f|--final-ABI] [-l|--language] [--full] [--major] [--minor] [--micro]
- Print version of Python implementation. --full, --major, --minor and --micro options cannot be specified simultaneously. If --full, --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed. If --language option is specified, then version of Python language is printed. --language and --full options cannot be specified simultaneously. --language and --micro options cannot be specified simultaneously. If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
- python_get_implementation_and_version [-f|--final-ABI]
- Print name and version of Python implementation. If version of Python implementation is not bound to version of Python language, then version of Python language is additionally printed. If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
- python_execute_nosetests [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
- Execute nosetests for all enabled Python ABIs. In ebuilds of packages supporting installation for multiple Python ABIs, this function calls python_execute_nosetests_pre_hook() and python_execute_nosetests_post_hook(), if they are defined.
- python_execute_py.test [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
- Execute py.test for all enabled Python ABIs. In ebuilds of packages supporting installation for multiple Python ABIs, this function calls python_execute_py.test_pre_hook() and python_execute_py.test_post_hook(), if they are defined.
- python_execute_trial [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
- Execute trial for all enabled Python ABIs. In ebuilds of packages supporting installation for multiple Python ABIs, this function calls python_execute_trial_pre_hook() and python_execute_trial_post_hook(), if they are defined.
- python_enable_pyc
- Tell Python to automatically recompile modules to .pyc/.pyo if the timestamps/version stamps have changed.
- python_disable_pyc
- Tell Python not to automatically recompile modules to .pyc/.pyo even if the timestamps/version stamps do not match. This is done to protect sandbox.
- python_mod_optimize [--allow-evaluated-non-sitedir-paths] [-d directory] [-f] [-l] [-q] [-x regular_expression] [--] <file|directory> [files|directories]
-
Byte-compile specified Python modules.
-d, -f, -l, -q and -x options passed to this function are passed to compileall.py.
This function can be used only in pkg_postinst() phase.
- python_mod_cleanup [--allow-evaluated-non-sitedir-paths] [--] <file|directory> [files|directories]
-
Delete orphaned byte-compiled Python modules corresponding to specified Python modules.
This function can be used only in pkg_postrm() phase.
ECLASS VARIABLES
- PYTHON_DEPEND
-
Specification of dependency on dev-lang/python.
Syntax:
PYTHON_DEPEND: [[!]USE_flag? ]<version_components_group>[ version_components_group]
version_components_group: <major_version[:[minimal_version][:maximal_version]]>
major_version: <2|3|*>
minimal_version: <minimal_major_version.minimal_minor_version>
maximal_version: <maximal_major_version.maximal_minor_version> - PYTHON_USE_WITH
- Set this to a space separated list of USE flags the Python slot in use must be built with.
- PYTHON_USE_WITH_OR
- Set this to a space separated list of USE flags of which one must be turned on for the slot in use.
- PYTHON_USE_WITH_OPT
- Set this to a name of a USE flag if you need to make either PYTHON_USE_WITH or PYTHON_USE_WITH_OR atoms conditional under a USE flag.
- PYTHON_COLORS = "${PYTHON_COLORS:-0}"
- User-configurable colored output.
- SUPPORT_PYTHON_ABIS
- Set this in EAPI <= 4 to indicate that current package supports installation for multiple Python ABIs.
- PYTHON_TESTS_RESTRICTED_ABIS
- Space-separated list of Python ABI patterns. Testing in Python ABIs matching any Python ABI patterns specified in this list is skipped.
- PYTHON_EXPORT_PHASE_FUNCTIONS
- Set this to export phase functions for the following ebuild phases: src_prepare(), src_configure(), src_compile(), src_test(), src_install().
- PYTHON_VERSIONED_SCRIPTS
- Array of regular expressions of paths to versioned Python scripts. Python scripts in /usr/bin and /usr/sbin are versioned by default.
- PYTHON_VERSIONED_EXECUTABLES
- Array of regular expressions of paths to versioned executables (including Python scripts).
- PYTHON_NONVERSIONED_EXECUTABLES
- Array of regular expressions of paths to nonversioned executables (including Python scripts).
- PYTHON_TEST_VERBOSITY = "${PYTHON_TEST_VERBOSITY:-1}"
- User-configurable verbosity of tests of Python modules. Supported values: 0, 1, 2, 3, 4.
MAINTAINERS
Gentoo Python Project <python@gentoo.org>
REPORTING BUGS
Please report bugs via http://bugs.gentoo.org/FILES
/usr/portage/eclass/python.eclassSEE ALSO
ebuild(5)http://sources.gentoo.org/eclass/python.eclass?view=log
Index
This document was created by man2html, using the manual pages.
Time: 03:25:02 GMT, May 22, 2013