:py:mod:`sys` ============= .. py:module:: sys .. autoapi-nested-parse:: System utilities and Python script handling. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: sys.RewriteImportRule sys.RewriteImportNodeTransformer Functions ~~~~~~~~~ .. autoapisummary:: sys.version sys.sanity_check sys.main sys.set_python_env sys.interpreter sys.python_script sys.is_console sys.relocate_python_distrib Attributes ~~~~~~~~~~ .. autoapisummary:: sys.logger .. py:data:: logger .. py:exception:: RewriteNodeError Bases: :py:obj:`Exception` Exception raised when AST node rewriting fails. .. py:class:: RewriteImportRule(module: str, name: str = '.*', action: RuleAction | None = None) Rewrite Import node from AST. Skip or reject names imported by:: from import or directly:: import .. py:class:: RuleAction(*args, **kwds) Bases: :py:obj:`enum.Enum` Possible rule actions when rewriting an import rule. .. py:attribute:: reject :value: 0 .. py:attribute:: skip :value: 1 .. py:method:: rewrite_node(node: ast.stmt) -> ast.stmt Rewrite a node. :param node: ast node :return: a modified ast node .. py:class:: RewriteImportNodeTransformer(rules: list[RewriteImportRule]) Bases: :py:obj:`ast.NodeTransformer` Walk the AST applying a set of rules. Currently only the RewriteImportRule are supported. .. py:method:: visit_ImportFrom(node: ast.stmt) -> ast.stmt Visit ImportFrom node. :param node: AST node to visit .. py:method:: visit_Import(node: ast.stmt) -> ast.stmt Visit Import node. :param node: AST node to visit .. py:function:: version() -> str Return the e3-core package version. .. py:function:: sanity_check() -> int Sanity check the E3 install. .. py:function:: main() -> None Run the e3 command line tool. .. py:function:: set_python_env(prefix: str) -> None Set environment for a Python distribution. :param prefix: root directory of the python distribution .. py:function:: interpreter(prefix: str | pathlib.Path | None = None) -> str Return location of the Python interpreter. When there are both a python3 and python binary file return the path to the python3 binary. :param prefix: root directory of the python distribution. if None location of the current interpreter is returned :return: python executable path .. py:function:: python_script(name: str, prefix: str | None = None) -> list[str] Return path to scripts contained in this Python distribution. :param name: the script name :param prefix: root directory of the Python distribution. if None the distribution currently used by this script will be used :return: a list that will be the prefix of your command line .. py:function:: is_console() -> bool Check if stdin is a console or not. :return: True if stdin is an interactive console .. py:function:: relocate_python_distrib(python_distrib_dir: str | None = None, freeze: bool = False, platform: str | None = None) -> None Adjust shebangs to freeze a Python distrib or make it relocatable. :param python_distrib_dir: Python distrib prefix. If None the current Python is used. :param freeze: if True use absolute paths in shebangs. If not use relative paths. :param platform: if None use sys.platform. Otherwise should be a platform value as returned by sys.platform.