Package: depman
A lightweight dependency manager for managing project dependencies in multiple contexts. The use case driving development is that of distinguishing between development, testing, and production dependencies in a simple and unified way. However, the application is general purpose and can be used in any project requiring the management of dependencies in multiple contexts.Currently, only dependencies resolved viaapt-getandpipare supported.  However, support for other dependency types is planned for future releases (seeFuture Featuresfor more details).Installation$ pip install depmanUsageusage: depman [-h] [-f <depfile>] [-t <type>] [-o <outfile>] [--no-header]
              <command> [<context>]

A lightweight dependency manager.

positional arguments:
  <command>             'satisfy' satisfies the dependencies specified in
                        <depfile>. 'validate' only validates <depfile> and
                        does not perform any system operations. 'export'
                        exports requirements to a specified file (using -o)
  <context>             The dependency context to perform <command> on

optional arguments:
  -h, --help            show this help message and exit
  -f <depfile>, --depfile <depfile>
                        The requirements file to load
  -t <type>, --type <type>
                        Restrict operations to dependencies of this type
  -o <outfile>, --outfile <outfile>
                        File to write results to
  --no-header           No export headerIf not supplied,<depfile>and<context>default torequirements.ymlandall, respectively.Example(s)Suppose you have the followingrequirements.ymlin your current working directoryincludes:
  dev:
    - test

dev:
  apt:
    - libxml2-dev=2.9.1+dfsg1-5+deb8u2
    - libxslt1-dev

  pip:
    - lxml
    - Sphinx

  yatr:
    - install-from-source:
        before: libxslt1-dev

test:
  pip:
    - nose
    - coverage

prod:
  pip:
    - gevent:
        version: '<=1.0.2'
    - syn>=0.0.14
    - six:
        always_upgrade: yes
    - numpy
    - openopt:
        after: numpy

  yatr:
    - install-from-source-2:
        before: gevent
        after: libxslt1-dev
    - cleanup:
        yatrfile: other_tasks.ymlThis file specifies three dependency contexts:dev,test,prod.  In general, any top-level key inrequirements.ymlspecifies a dependency context.  The one exception to this rule isincludes, which defines inclusion relationships between contexts.  In this example, thedevcontext includes thetestcontext, and so will attempt to satisfy the dependencies for thetestcontext in addition to thedevcontext wheneverdepman satisfy devis run from the command line.Currently, only three dependency types are supported in any context:apt,pip, andyatr.  However, support for other dependency types is planned for future releases (seeFuture Features).Dependencies are specified in each context under each dependency type as YAML list elements.  If the element is a string, the dependency in question will be treated as satisfied if some version of the package denoted by the string exists on the system.  For more detailed dependency requirements, the name of the package can be listed as the key to a YAML dictionary of dependency options.  This can be seen, for example, in thegeventdependency, in which a version less than or equal to1.0.2is specified as a requirement.  Additionally, thesixpackage contains thealways_upgradeoption, which causes depman to always attempt to upgrade the package, regardless of the current version installed.Package version relations can be specified in various ways.  In theprodcontext,pipis constrained to only install a version ofsynthat is greater than or equal to0.0.14.  Likewise, in thedevcontext,aptis constrained to install version2.9.1+dfsg1-5+deb8u2oflibxml2-dev.  And, as seen above, thepipgeventdependency is constrained to a version less than or equal to1.0.2Relative dependency satisfaction ordering may be specified by use of thebeforeandafterkeys.  In this example, satisfying theprodcontext will lead to an invocation ofpipto installnumpy, followed by a separate invocation ofpipto installopenopt.  Such features are useful for minimizing the hassle of installing of packages that do not properly declare their dependencies.  It should be noted that namespaces are not currently supported, so specifyingbeforeorafterfor a name that belongs to multiple dependencies may lead to unexpected results.  Thebeforeandafterkeys should only be used when relative ordering is necessary, as unnecessary usage may lead to sub-optimal execution of dependency satisfaction operations.Theyatrdependency is a special type that will invokeyatrto execute the specified task from the specifiedyatrfilekey.  For example, theprodcontext specifies that a task namedcleanupdefined inother_tasks.ymlis to be run.  If noyatrfilekey is specified, the specified tasks should be defined in a file namedyatrfile.ymllocated in the same directory as the depman requirements file.  Unless constrained from doing so bybeforeandafterspecifications,depmanwill always attempt to satisfyaptdependencies beforepipdependencies, andpipdependencies before runningyatrtasks.  Thus, thecleanuptask will run last in this example if either theprodorallcontexts are selected.yatr“dependencies” are not true dependencies, but task invocations, and thus cannot truly be satisfied.  As a result, invokingdepmanto satisfy ayatrdependency will always cause the task defined therein to be executed.yatrdependencies can be used to perform scripted installs, cleanup and provisioning actions, and other tasks that are otherwise beyond the scope of a lightweight dependency manager.On the command line,depmanalso accepts the special contextallas a valid parameter.  Runningdepman satisfy allcauses depman to satisfy the dependencies in all of the defined dependency contexts.  In this example, it would cause depman to satisfy the dependencies fordev,test, andprod.  Runningdepman satisfyis equivalent to runningdepman satisfy all.On a machine where none of the specified packages are installed, runningdepman satisfy allin this example is equivalent to running the following sequence of commands:$ yatr install-from-source
$ apt-get update
$ apt-get install -y libxml2-dev=2.9.1+dfsg1-5+deb8u2 libxslt1-dev
$ yatr install-from-source-2
$ pip install Sphinx coverage gevent==1.0.2 lxml nose numpy six syn
$ pip install openopt
$ yatr -f other_tasks.yml cleanupLikewise, runningdepman satisfy teston a fresh machine is equivalent to:$ pip install coverage noseRunningdepman satisfy devis equivalent to:$ yatr install-from-source
$ apt-get update
$ apt-get install -y libxml2-dev=2.9.1+dfsg1-5+deb8u2 libxslt1-dev
$ pip install Sphinx coverage lxml noseAnd runningdepman satisfy prodis equivalent to:$ yatr install-from-source-2
$ pip install gevent==1.0.2 numpy six syn
$ pip install openopt
$ yatr -f other_tasks.yml cleanupExportDependencies can also be exported.  In this example, runningdepman export prod -t pip -o requirements.txtwill produce a filerequirements.txtin the current directory that looks like:# Auto-generated by depman 0.3.4
gevent<=1.0.2
numpy
openopt
six
syn>=0.0.14The header comment can be suppressed by supplying the--no-headeroption.Future FeaturesThe following features are planned for future releases:apt PPA supportSupport for other package managersTop-level package manager optionsanycontext