Package: dante
DanteDante is a dependency management and validation tool for python projects.PurposeDante was written to simplify dependency management in python by using lock
files to keep consistent environments for both development and deployment. It
does not manage installation of environments and packages but focuses on
validation.Dante will help you keep track of dependencies with just a few simple commands.
Unlike some other tools, it is not as opinionated, and is highly configurable.
While it uses standard requirements files, a parser can be written for any
other file type.Recommended conventionFiles to use:requirements.txtfor used project packagesrequirements.lockfor deployment packagesrequirements-dev.txtfor used development packagesrequirements-dev.lockfor all test environment packagesLock files enforce exact versions for all packages.
When deploying and preparing the environment only install from lock files.InstallationDante can be found on PyPI and can simply be installed with:pip install danteSince version 2, it no longer installs it's own dependencies, but instead
vendors them to avoid possible false positives.ConfigurationDante has a default configuration which can be overridden using a standardsetup.cfgfile. Configurable properties are as follows:PropertyDescriptionchecksChecks to run when calling thecheckcommand. Defaults areconflicts,cyclic,missing,validate.ignore_listList of package keys to ignore. Defaults aredante,pip,setuptools, andwheel.allow_named_versionsWhether to allow custom named versions (invalid by default) for packages. Default isfalse.named_version_patternsList of regex patterns that will determine named versions. Default is empty.requirements_filesList of requirement files used in the project. Defaults torequirements.txt.lock_filesList of lock files used in the project. Defaults torequirements.lock.lock_file_pathPath of the lock file that will be generated withdante lock --save.parserParser to use to read/write requirements/lock files. Currently only the default is supported.any_versionUndefined version name. Default isAny.graph_nameName of the graph that will be created. Defaults todante-graph.graph_filenameFilename of the graph that will be created. Defaults todante-graph.pdfin the working directory.graph_formatFormat of the graph that will be created. Defaults topdf. Supports all graphviz formats.graph_engineEngine of the graph that will be created. Defaults todot. Supports all graphviz engines.graph_attributesCustom graph attributes. Supports all graphviz attributes.graph_strictWhether the graphviz graph follows strict rules. Defaults toTrue.graph_node_attributesCustom graph node attributes. Defaults to settingshapetobox3d. Supports all graphviz node attributes.graph_edge_attributesCustom graph edge attributes. Defaults to settingfontsizeto10. Supports all graphviz edge attributes.FunctionalityCommandsCommandDescriptionlistList all dependenciestreeShow dependency treeconfigPrint configurationvalidateValidate requirements and lock filesconflictsCheck for conflicts in required dependenciescyclicCheck for cyclic dependenciesmissingShow missing dependenciescheckRun a complete list of checkslockDisplay or generate lock file from environment and/or requirements file(s)graphExport a dependency graph using graphvizNote: Almost all command flags have shorthands that are equivalent to the first
letter of their name. They can be displayed with the help command.VersionThe version flag will get dante to display it's installed version end exit:dante --versionDante commandDante has several flags on the CLI's top level:--all- Shows all packages (Does not use the ignore list)--ignore IGNORE- Ignore specified package. Can be used multiple times.Dependency listLists all packages relevant to the project:dante list [--requirements REQUIREMENTS]FlagShorthandDescription--requirements-rRequirements file to use (will ignoresetup.cfg)Unlikepip freezeunless it's used with the--allflag dante will only
display packages that are required for the project. This is determined by using
installed packages and requirements files.Dependency treeDisplays a dependency tree for a single package or the entire environment:dante tree [--package PACKAGE] [--requirements REQUIREMENTS]FlagShorthandDescription--package-pPackage to display the tree for--requirements-rRequirements file to use (will ignoresetup.cfg)ConfigurationDisplays the current configuration in JSON format:dante configExample result:{"dante":{"any_version":"Any","checks":["conflicts","cyclic","missing","validate"],"ignore_list":["dante","pip","setuptools","wheel"],"allow_named_versions":true,"named_version_patterns":["0.*version"],"lock_file_path":"requirements-dev.lock","requirements_files":["requirements-dev.lock"],"lock_files":["requirements-dev.lock"],"graph_name":"dante-graph","graph_filename":null,"graph_format":"pdf","graph_engine":"dot","graph_strict":true},"graph_attributes":{},"graph_node_attributes":{"shape":"box3d"},"graph_edge_attributes":{"fontsize":"10"}}ValidationPerforms various checks on requirements and lock files:dante validate [-requirments REQUIREMENTS] [--lock LOCK] [--strict]FlagShorthandDescription--requirements-rRequirements file to use (will ignoresetup.cfg)--lock-lLock file to use (will ignoresetup.cfg)--strict-rRun strict checksThe checks performed are as follows:Check if all set requirements are set to a version or a version rangeCheck if all locked requirements are set to an exact versionCheck if all installed package versions match the locked requirement versionsCheck if all required versions match the locked requirement versionsSuccessful run will print out:All set requirements locked
No unset locks found
All package versions matching
All requirement versions matchingRunning validation with the--strictflag will add some additional checks:Check if there are installed packages that are not required by anythingCheck if there are locked requirements that are not required by anythingIt is recommended to use the strict check whenever it's possible.Successful run will print out:No non-required packages found
No non-required locks foundConflicting dependenciesDetects conflicts between installed packages:dante conflictsConflicts can occur when multiple packages require the same package with
incompatible versions (e.g. one requires <1.0.0 and the other >2.0.0).
Successful run will print out:No conflicts foundCyclic dependenciesDetects cyclical dependencies in installed packages:dante cyclicThis can occur when there is a cyclical path in package dependencies (e.g.package1requirespackage2which requirespackage3, which in turn
requirespackage1). Successful run will print out:No cyclic dependencies foundMissing dependenciesDetects if there are required packages that are not installed in the environment:dante missing [--requirements REQUIREMENTS]FlagShorthandDescription--requirements-rRequirements file to use (will ignoresetup.cfg)Successful run will print out:No missing dependencies foundCheckRuns all defined checks at once:dante check [--requirements REQUIREMENTS] [--lock LOCK] [--strict]FlagShorthandDescription--requirements-rRequirements file to use (will ignoresetup.cfg)--lock-lLock file to use (will ignoresetup.cfg)--strict-rRun strict checksSuccessful run with all checks will print out:All set requirements locked
No unset locks found
All package versions matching
All requirement versions matching
No non-required packages found
No non-required locks found
No conflicts found
No cyclic dependencies found
No missing dependencies foundLockDisplays or saves locked requirements for the current project:dante lock [--requirements REQUIREMENTS] [--save] [--file FILE]FlagShorthandDescription--requirements-rRequirements file to use (will ignoresetup.cfg)--save-sSave to file--file-fFilename to save to (will overridesetup.cfg)Locked requirements are determined by walking through all installed packages
and provided requirements recursively retrieving their dependencies.Only the requirements that are needed for the project will be returned.GraphReturns a dependency graph description or renders it to a file:dante graph [--strict] [--render] [--view] [--name NAME] [--filename FILENAME]
                   [--format FORMAT] [--engine ENGINE]
                   [--graph_attr GRAPH_ATTR] [--node_attr NODE_ATTR]
                   [--edge_attr EDGE_ATTR]FlagShorthandDescription--render-rRender graph to file--view-vDisplay graph after rendering--strict-sUse strict graph rules--nameGraph name--filenameFilename to save graph to--formatGraph file format--engineGraph engine--graph_attrGraph attributes--node_attrGraph node attributes--edge_attrGraph edge attributesApiDante exposes it's operations through the api module, so they can be imported
and used in your libraries/applications:Example for retrieving installed packages:fromdante.apiimportdependency_listinstalled_packages=dependency_list()CIDante can be used as a CI checking tool, with proper configuration insetup.cfgconfigured, all it takes to run a check on any CI is:dante checkDante includes error codes when run through the CLI, so it will fail the build
if any problems are detected.Note: It's recommended to use the strict check whenever it's possible, since
unnecessary requirements can still cause problems in the environments
(e.g. can overwrite other package's files...):dante check --strictTestsTo run tests simply install all dependencies fromrequirements-dev.lockand run:pytest --cov-config setup.cfgRoadmap:Full documentation