Dependencies

As mentioned at the beginning of the Development section, using multiple Python libraries without questioning their maturity and long-term stability can be a huge time-saver when compiling Python scripts as ad-hoc solutions for complex problems. However, we have to be more cautious when including external libraries into our core code. In general, we should keep the number of imported libraries low and avoid libraries with significant shortcomings or uncertain future support. Otherwise, we risk the long-term stability of HydPy itself. Whenever reasonable, import only packages of the Python Standard Library, or at least restrict yourself to reliable, mature and stable site-packages.

In the development of HydPy, we consider three groups of site-packages: required dependencies, optional dependencies, and dependencies only relevant for development.

“Required dependencies” are site-packages being imported within each HydPy application by necessity. See the “install_requires” argument within the setup.py file for the current list of required dependencies. At the time of writing these are only the highly accepted and easily installable site-packages NumPy, SciPy, and wrapt, providing essential features not available within the Python Standard Library.

“Optional dependencies” are site-packages needed for specific HydPy features only. One good example is the netCDF4 module. The first reason for declaring this site-package optional is its limited scope for reading and writing NetCDF-CF time series files. Users can choose other file formats as well. The second reason is that its installation is not always working smoothly. See the documentation on class OptionalImport on how to define optional imports.

“Development dependencies” are site-packages relevant for framework or model developers only. One example is the coverage library, checking whether the available tests execute certain source code lines or not. The requirements.txt file lists most development dependencies. Additionally, we rely on Sphinx in conjunction with its extensions listed in conf.py for generating the HTML documentation.