airflow.providers.standard.utils.python_virtualenv
¶
Utilities for creating a virtual environment.
Module Contents¶
Functions¶
|
Create a virtual environment and install the additional python packages. |
|
Render the python script to a file to execute in the virtual environment. |
- airflow.providers.standard.utils.python_virtualenv.prepare_virtualenv(venv_directory, python_bin, system_site_packages, requirements=None, requirements_file_path=None, pip_install_options=None, index_urls=None)[source]¶
Create a virtual environment and install the additional python packages.
- Parameters
venv_directory (str) – The path for directory where the environment will be created.
python_bin (str) – Path to the Python executable.
system_site_packages (bool) – Whether to include system_site_packages in your virtualenv. See virtualenv documentation for more information.
requirements (list[str] | None) – List of additional python packages.
requirements_file_path (str | None) – Path to the
requirements.txt
file.pip_install_options (list[str] | None) – a list of pip install options when installing requirements See ‘pip install -h’ for available options
index_urls (list[str] | None) – an optional list of index urls to load Python packages from. If not provided the system pip conf will be used to source packages from.
- Returns
Path to a binary file with Python in a virtual environment.
- Return type
- airflow.providers.standard.utils.python_virtualenv.write_python_script(jinja_context, filename, render_template_as_native_obj=False)[source]¶
Render the python script to a file to execute in the virtual environment.
- Parameters
jinja_context (dict) – The jinja context variables to unpack and replace with its placeholders in the template file.
filename (str) – The name of the file to dump the rendered script to.
render_template_as_native_obj (bool) – If
True
, rendered Jinja template would be converted to a native Python object