Package: depfinder
depfinderdocsgithub repoInstallationdepfinderis on pypi. It is tested against Python 2.7 and 3.6-3.8.pip install depfinderIt is available via conda.conda install -c conda-forge depfinderIt is also via github.git clone git@github.com:ericdill/depfinder
cd depfinder
python setup.py installUsing depfinder$ depfinder -h
usage: depfinder [-h] [-y] [-V] [--no-remap] [-v] [-q] [-k KEY] [--conda]
                [--pdb]
                file_or_directory

Tool for inspecting the dependencies of your python project.

positional arguments:
    file_or_directory  Valid options are a single python file, a single jupyter
                        (ipython) notebook or a directory of files that include
                        python files

optional arguments:
    -h, --help         show this help message and exit
    -y, --yaml         Output in syntactically valid yaml when true. Defaults to
                        False
    -V, --version      Print out the version of depfinder and exit
    --no-remap         Do not remap the names of the imported libraries to their
                        proper conda name
    -v, --verbose      Enable debug level logging info from depfinder
    -q, --quiet        Turn off all logging from depfinder
    -k KEY, --key KEY  Select some or all of the output keys. Valid options are
                        'required', 'optional', 'builtin', 'relative', 'all'.
                        Defaults to 'all'
    --conda            Format output so it can be passed as an argument to conda
                        install or conda create
    --pdb              Enable PDB debugging on exceptionOk, great. That's the help output. Not super helpful. What does the
output of depfinder look like when we run it on the source code for
depfinder?$ depfinder depfinder
{'builtin': ['__future__',
                'argparse',
                'ast',
                'collections',
                'copy',
                'errno',
                'json',
                'logging',
                'os',
                'pprint',
                're',
                'subprocess',
                'sys'],
    'relative': ['_version', 'main'],
    'required': ['pyyaml', 'stdlib-list']}So, what do these things mean? Wellbuiltinare modules
that are built in to the standard library.requiredare
modules that are not from the standard library or from within thedepfinderpackage andrelativeare modules
that are imported from one module to another within thedepfindersource code.Also seethis
notebookDescriptionFind all the unique imports in your library, automatically, because who
likes do it by hand?depfinderuses theast(Abstract
Syntax Tree) module (andmore ast
docs) to find all
:pyast.Try{.interpreted-text role="class"} and
:pyast.ImportFrom{.interpreted-text role="class"} nodes. These
:pyast.Import{.interpreted-text role="class"} and
:pyast.ImportFrom{.interpreted-text role="class"} nodes are then
grouped according to the following categories, in order of decreasing
precedence:relative: The import is a relative import from within the same librarybuiltin: The import is built into the standard library, as determined by scraping the
official python docs for the builtins withstdlib-listquestionable: The import occurs inside any combination of{py:class}ast.Try({py:class}ast.TryExcepton py27){py:class}ast.FunctionDefor {py:class}ast.AsyncFunctionDef{py:class}ast.If, {py:class}ast.While, {py:class}ast.For, or
{py:class}ast.AsyncFor.{py:class}ast.match_case.The module may be importable without these imports, but the it will likely
not have full functionality.required: The import occurs at the top level of the module and will get executed
when the module is imported. These imports must be accounted for in an
environment, or the module will not be importable.TestingIt has dependencies on,stdlib-listandpyyaml. I usestdlib-listto get the
list of libraries built in to the standard library. These requirements
can be installed via pip :pip install -r requirements.txtAlso install the test-requiements :pip install -r test-requirements.txtThen you can run the tests from the root of the git repository :coverage run run_tests.pyReleasingmanual:create an annotated tag and push it to github.git tag -a TAG and thengit push --tags`git checkout TAGpython -m build --sdist --wheel . --outdir disttwine check dist/*twine upload dist/* --verboseAPI.. currentmodule:: depfinder.main.. autofunction:: get_imported_libs.. autofunction:: iterate_over_library.. autofunction:: simple_import_searchIPython/Jupyter Notebook supportdepfinderhas support for v4 Jupyter notebooks... autofunction:: notebook_path_to_dependencies