.. _pyinstall_auto: Install Python Extensions Automatically ======================================== Instructions how to install the **CSXCAD & openEMS Python interface**. Methods -------- CSXCAD and Python extensions can be installed using two methods: automatic install via ``./update_openEMS.sh`` using the ``--python`` flag, or building each Python extension separately. This page exclusively deals with the recommended script-assisted auto-installation process. .. seealso:: * For context, see :ref:`install_requirements_src` and :ref:`clone_build_install_src`. * For manual installation, see :ref:`pyinstall_manual`. Quick Start ------------ In the simplest cases, all one needs is adding the ``--python`` flag in ``./update_openEMS.sh``. For example, to install the C++ project and its Python extensions simultaneously to the prefix ``~/opt/openEMS``, run: .. code-block:: bash ./update_openEMS.sh ~/opt/openEMS --python In the latest openEMS development version (to be released as v0.0.37), Python extensions and their dependencies are installed into an isolated "virtual environment" in the ``venv`` subdirectory (e.g. ``~/opt/openEMS/venv``). This environment *must be activated* before using Python with CSXCAD or openEMS. .. code-block:: bash source ~/opt/openEMS/venv/bin/activate # leave the venv with "deactivate" .. important:: In a ``venv``, its environment is isolated from the operating system's own. System-wide Python packages are invisible, only Python packages installed specifically here can be seen. If you need other third-party packages, install them via ``pip3`` provided *within* this ``venv``. For example, to analyze S-parameters via scikit-rf: .. code-block:: bash source ~/opt/openEMS/venv/bin/activate # if not activated pip3 install scikit-rf Customize Install ------------------ To satisfy the needs of users from different backgrounds, users are: 1. *Not required* to install Python extensions to an isolated ``venv``, the ``venv`` can be disabled. 2. *Not required* to use the created ``venv`` environment, a pre-existing ``venv`` or an alternative venv path can be used. 3. *Not required* to manage packages via ``pip3``, or to have Internet access to PyPI. It's possible to manage dependencies manually using the system's package manager, without ``pip3``. Arguments ~~~~~~~~~~~ The Python installation behavior of ``update_openEMS.sh`` can be customized using the following arguments: .. option:: --python-venv-mode Python extensions installation mode: - ``auto``: create a new Python venv if no venv is already activated, otherwise use the existing venv (default). - ``venv``: create a new Python venv. - ``site``: create a new Python venv with ``--system-site-packages``. - ``disable``: don't create a new venv, install Python extension directly to a default path (usually in home directory (e.g. ``~/.local``). .. option:: --python-venv-dir Override default Python venv creation path. By default, use the ``venv`` subdirectory of the installation path. .. option:: --python-use-network