The dependency_finder sub-package attempts to determine all the dependencies of a given script, including the version of each dependency.
For each executable that is supported there is a sub-module containing a find_dependencies() function, and a series of heuristics for finding version information. There is also a sub-module core, which contains heuristics that are independent of the language, e.g. where the dependencies are under version control.
copyright: | Copyright 2006-2015 by the Sumatra team, see doc/authors.txt |
---|---|
license: | BSD 2-clause, see LICENSE for details. |
For users of the API, the principal function of interest is the following.
Return a list of dependencies for a given script and programming language.
This function returns a list of Dependency objects. There is a different Dependency subclass for each programming language, but all have the following attributes:
Contains information about a program component, and tries to determine version information.
If you are interested in improving the dependency finder for an existing program/language, or in adding a dependency finder for a new program or language, you may be interested in the following.
Try to find version information by calling a series of functions in turn.
Returns a possibly modified list of dependencies
Determine whether a file is under version control, and if so, obtain version information from this.
Look for path as an absolute path then relative to the current directory, then relative to search_dirs. Return the absolute path.
Try to find version information from the attributes of a Python module.
Determine whether a Python module is provided as an egg, and if so, obtain version information from this.
Find all imported top-level packages for a given Python file.
We cannot assume that the version of Python being used to run Sumatra is the same as that used to run the simulation/analysis. Therefore we need to run all the dependency finding and version checking in a subprocess with the correct version of Python.
Return a list of Dependency objects representing all the top-level modules or packages imported (directly or indirectly) by a given Python file.
save all dependencies to the file in the current folder
Find all files that are xopened, whether directly or indirectly, by a given Hoc file. Note that this only handles cases whether the path is given directly, not where it has been previously assigned to a strdef.
Find all files that are loaded with load_file(), whether directly or indirectly, by a given Hoc file. Note that this only handles cases whether the path is given directly, not where it has been previously assigned to a strdef. Also note that this is more complicated than xopen(), since NEURON also looks in any directories in $HOC_LIBRARY_PATH and $NEURONHOME/lib/hoc.
Return a list of Dependency objects representing all Hoc files imported (directly or indirectly) by a given Hoc file.
Find all files that are included, whether directly or indirectly, by a given .g file.
Return a list of Dependency objects representing all files included, whether directly or indirectly, by a given .g file.
Return list of dependencies.
First determines dependency info for filename. This is done through an external call (using the Rscript from exectuable.path) to a custom R script that uses parse and simple pattern-matching to find all calls in filename that load external packages (i.e., the R calls “library” and “require”). The result is returned in a string with package info delimited by pre-set tokens. Info includes: name, version, local path, and repo source (repo name but no URLs).
Second, parses the dependency info into Dependency objects, returned in a list.