Installation#
In order to use \(\Psi\)-TaLiRo, you will need to install the package into your Python environment.
Installation of Python packages is handled by the pip program. You can install this project
using pip like so:
pip install psy-taliro
pip will attempt to install packages to the system-wide Python location by default. If you
you do not have permission to install packages to this location, you can install \(\Psi\)-TaLiRo
to a user-specific Python location using the --user flag like so:
pip install --user psy-taliro
Since Python packages are all installed to a single location, conflicts can arise if multiple packages depend on the same package but use different versions since only the last-installed version will be kept. To avoid conflicts the Python community has adopted virtual environments which create project-specific python environments to keep dependencies separate. Many tools have been developed to help manage virtual environments, the following sections covers the installation for a few of the most common.
Virtualenv#
The oldest of the virtual environment management tools, the virtualenv package provides very low
-level in comparison to the other tools described here. To install virtualenv, run the following
command in your terminal:
python3 -m pip install --user virtualenv
Once installed, virtualenv can be used to create virtual environments with the command:
virtualenv <directory name>
Traditionally, virtual environments are stored in a directory named venv, sometimes written
.venv to hide it from command line tools. Once created, a virtual environment can be activated
by running the command
source <virtualenv directory>/bin/activate
This will open a shell configured to install packages to the virtual environment instead of
globally. After activating the virtual environment, the normal pip and python3 commands
can be used.
Starting in Python 3.3, a limited version of the virtualenv library is pre-installed called
venv. The advantage of this built-in library is that for simple tasks you do not need to install
an additional package, but for more advanced workflows installing virtualenv is still necessary.
To create a virtual environment using the built-in venv library you can use the following
command:
python3 -m venv <directory name>
Once you have created and activated the virtual environment, \(\Psi\)-TaLiRo can be installed using
the typical pip command.
<virtualenv directory>/bin/pip install psy-taliro
Pipenv#
Pipenv is a tool designed to emulate packaging tools like
npm from Javascript or cargo from Rust. The pipenv
tool creates a Pipfile.lock file which specifies the exact version of every dependency to
install, the purpose of which is to ensure reproducible environments when deploying a package.
pipenv stores every virtual environment for you in a special directory to avoid conflicts. While
pipenv can be installed using the pip command, it is recommended to install the package
using pipx instead. Once you install pipx on your system, you can
install pipenv with the following command.
pipx install pipenv
Once installed, a pipenv-managed virtual environment can be created using the command
pipenv --three
\(\Psi\)-TaLiRo can be installed to the virtual environment without activating it using the install
sub-command.
pipenv install psy-taliro
Finally, python scripts can be executed within the virtual environment by prefixing the normal run
command with pipenv run.
pipenv run python3 <script name>
If needed, a pipenv-managed virtual environment can be activated by using the command
pipenv shell
Poetry#
Like pipenv, poetry is another tool to create and manage virtual environments. Installation instructions for poetry can be found on its website. Once installed, a poetry-managed virtual environment can be created by running the command
poetry init
You can install \(\Psi\)-TaLiRo using the add sub-command.
poetry add psy-taliro
Finally, a script can be run inside a virtual environment by prefixing the command with
poetry run
poetry run python3 <script name>
Conda#
Other tools#
There are many other environment managers for python like conda , hatch, or pdm which can also be used to install python packages in isolation. Covering all of the tools is out of the scope of this documentation, but the pipenv and poetry tools are mentioned here because they have been used frequently in our work.