sys
¶
Module Contents¶
Classes¶
Rewrite Import node from AST. |
|
Walk the AST applying a set of rules. |
Functions¶
|
|
|
Sanity check the E3 install. |
|
|
|
Set environment for a Python distribution. |
|
Return location of the Python interpreter. |
|
Return path to scripts contained in this Python distribution. |
|
Check if stdin is a console or not. |
|
Adjust shebangs to freeze a Python distrib or make it relocatable. |
Attributes¶
- sys.logger¶
- exception sys.RewriteNodeError¶
Bases:
Exception
Common base class for all non-exit exceptions.
- class sys.RewriteImportRule(module: str, name: str = '.*', action: RuleAction | None = None)¶
Rewrite Import node from AST.
Skip or reject names imported by:
from <module> import <names>
or directly:
import <module>
- class RuleAction(*args, **kwds)¶
Bases:
enum.Enum
Possible rule actions when rewriting an import rule.
- reject = 0¶
- skip = 1¶
- rewrite_node(node: ast.stmt) ast.stmt ¶
Rewrite a node.
- Parameters:
node – ast node
- Returns:
a modified ast node
- class sys.RewriteImportNodeTransformer(rules: list[RewriteImportRule])¶
Bases:
ast.NodeTransformer
Walk the AST applying a set of rules.
Currently only the RewriteImportRule are supported.
- visit_ImportFrom(node: ast.stmt) ast.stmt ¶
- visit_Import(node: ast.stmt) ast.stmt ¶
- sys.version() str ¶
- sys.sanity_check() int ¶
Sanity check the E3 install.
- sys.main() None ¶
- sys.set_python_env(prefix: str) None ¶
Set environment for a Python distribution.
- Parameters:
prefix – root directory of the python distribution
- sys.interpreter(prefix: str | 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.
- Parameters:
prefix – root directory of the python distribution. if None location of the current interpreter is returned
- Returns:
python executable path
- sys.python_script(name: str, prefix: str | None = None) list[str] ¶
Return path to scripts contained in this Python distribution.
- Parameters:
name – the script name
prefix – root directory of the Python distribution. if None the distribution currently used by this script will be used
- Returns:
a list that will be the prefix of your command line
- sys.is_console() bool ¶
Check if stdin is a console or not.
- Returns:
True if stdin is an interactive console
- sys.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.
- Parameters:
python_distrib_dir – Python distrib prefix. If None the current Python is used.
freeze – if True use absolute paths in shebangs. If not use relative paths.
platform – if None use sys.platform. Otherwise should be a platform value as returned by sys.platform.