Dependencies#
Types of dependencies#
skbase has three types of dependencies:
“core” dependencies that are required for
skbaseto install and run“soft” dependencies that are required to import or use specific, non-core functionality
“developer” dependencies are required for developing
skbasebut not required of end-users (e.g.,pre-commit)“test” dependencies are required for running
skbase’s unit tests
Making it easy to install and use skbase in a variety of projects is
on of skbase’s goals. Therefore, we seeks to minimizing the number of
dependencies needed to provide the project’s functionality.
Soft Dependencies#
A soft dependency is a dependency that is only required to import
certain modules, but not necessary to use most of the package’s functionality.
Accordingly, soft dependencies are not automatically installed alongside
skbase. If you want to install soft dependencies, you’ll either need
to do so manually or use follow the installation instructions and install
the optional “[all_extras]” version of the package.
Adding a soft dependency#
The project tries to keep its dependencies, including soft dependencies, minimized. Core developers will consider the pros and cons of any additional soft dependency when reviewing Pull Requests. In the event you need to add a new soft dependency or changing the version of an existing one, the following files need to be updated:
pyproject.toml, adding the dependency or version bounds in the
all_extrasdependency set. Following the PEP 621 convention, all dependencies including build time dependencies and optional dependencies are specified in this file.
Informative warnings or error messages for missing soft dependencies should be raised,
in a situation where a user would need them. This is handled through our
_check_soft_dependencies utility.
There are specific conventions to add such warnings in BaseObject-s.
To add BaseObject with a soft dependency, ensure the following:
imports of the soft dependency only happen inside the object (e.g., a particular methods or in
__init__after calls tosuper(cls).__init__).the
python_dependenciestag of theBaseObjectis populated with astr, or alistofstr, of import dependencies. Exceptions will automatically raised when constructing theBaseObjectin an environment without the required packages.in the python module containing the
BaseObject, the_check_soft_dependenciesutility is called at the top of the module, withseverity="warning". This will raise an informative warning message at module import.In a case where the package import differs from the package name (i.e.,
import package_stringis different frompip install different-package-string), the_check_soft_dependenciesutility should be used in__init__. Both the warning and constructor call should use thepackage_import_aliasargument for this.If the soft dependencies require specific python versions, the
python_versiontag should also be populated, with a PEP 440 compliant version specificationstrsuch as"<3.10"or">3.6,~=3.8".
Core or developer dependences#
Core and developer dependencies can only be added by core developers after discussion in a core developer meeting or in the project’s communication channels.
When adding a new core dependency or changing the version of an existing one, the following files need to be updated:
pyproject.toml, adding the dependency or version bounds in the
dependenciesdependency set.
When adding a new developer dependency or changing the version of an existing one, the following files need to be updated:
pyproject.toml, adding the dependency or version bounds in the
devdependency set.