In the previous section you made your package “pip installable” by creating a setup.py
file.
You then installed the package, effectively making accessible between different analysis directories.
However, a package is never set in stone: as you work on your analyses, you will almost certainly likely make changes to it, for instance to add functionalities or to fix bugs.
You could just reinstall the package each time you make a modification to it, but this obviously becomes tedious if you are constantly making changes (maybe to hunt down a bug) and/or testing your package. In addition, you may simply forget to reinstall your package, leading to potentially very frustrating and time-consuming errors.
pip
has the ability to install the package in a so-called “editable” mode.
Instead of copying your package to the package installation location, pip will just
write a link to your package directory.
In this way, when importing your package, the python interpreter is redirected to
your package project directory.
To install your package in editable mode, use the -e
option for the install
command:
# In directory tstools-dist/
pip install -e .
pip uninstall tstools
tstools
is not among them
Hint: Use pip --help
to get alist of available pip
commands.tstools
in editable mode.tstools.vis.plot_trajectory_subset
so that it returns the maximum value
over the trajectory subset, in addition to the figure
and axis
.
Hint: You can use the numpy function amax
to find the maximum of an array.analysis1/data/timeseries1.csv
between
t=0 and t = 4 ?In editable mode, pip install
just write a file <package-name>.egg-link
at the package
installation location in place of the actual package. This file contains the location of the
package in your package project directory:
cat ~/python-workshop-venv/lib/python3.8/site-packages/tstools.egg-link
/home/thibault/python-packaging-workshop/tstools