depfinder


Namedepfinder JSON
Version 2.10.0 PyPI version JSON
download
home_pagehttp://github.com/ericdill/depfinder
SummaryFind all the imports in your library
upload_time2023-05-05 18:09:41
maintainer
docs_urlhttps://pythonhosted.org/depfinder/
authorEric Dill
requires_python>=2.7
licenseBSD-3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # depfinder

[![image](https://github.com/ericdill/depfinder/actions/workflows/tests.yml/badge.svg)](https://github.com/ericdill/depfinder/actions/workflows/tests.yml)

[![image](http://codecov.io/github/ericdill/depfinder/coverage.svg?branch=main)](https://app.codecov.io/github/ericdill/depfinder?branch=main)

-   [docs](https://ericdill.github.io/depfinder)
-   [github repo](https://github.com/ericdill/depfinder)

## Installation

`depfinder` is on pypi. It is tested against Python 2.7 and 3.6-3.8.

```
pip install depfinder
```

It is available via conda.
```
conda install -c conda-forge depfinder
```

It is also via github.
```
git clone git@github.com:ericdill/depfinder
cd depfinder
python setup.py install
```

## Using 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 exception
```

Ok, 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? Well `builtin` are modules
that are built in to the standard library. `required` are
modules that are not from the standard library or from within the
`depfinder` package and `relative` are modules
that are imported from one module to another within the
`depfinder` source code.

Also see [this
notebook](https://github.com/ericdill/depfinder/blob/master/depfinder_usage.ipynb)

## Description

Find all the unique imports in your library, automatically, because who
likes do it by hand? [depfinder](https://github.com/ericdill/depfinder)
uses the [ast](https://docs.python.org/2/library/ast.html) (Abstract
Syntax Tree) module (and [more ast
docs](https://greentreesnakes.readthedocs.io/en/latest/)) to find all
:py`ast.Try`{.interpreted-text role="class"} and
:py`ast.ImportFrom`{.interpreted-text role="class"} nodes. These
:py`ast.Import`{.interpreted-text role="class"} and
:py`ast.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 library
- **builtin**
  : The import is built into the standard library, as determined by scraping the
    official python docs for the builtins with [stdlib-list](https://github.com/jackmaney/python-stdlib-list)
- **questionable**
  : The import occurs inside any combination of

    - {py:class}`ast.Try` ({py:class}`ast.TryExcept` on py27)
    - {py:class}`ast.FunctionDef` or {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.

## Testing

It has dependencies on,
[stdlib-list](https://github.com/jackmaney/python-stdlib-list) and
[pyyaml](https://pyyaml.org/wiki/PyYAML). I use `stdlib-list` to get the
list of libraries built in to the standard library. These requirements
can be installed via pip :

    pip install -r requirements.txt

Also install the test-requiements :

    pip install -r test-requirements.txt

Then you can run the tests from the root of the git repository :

    coverage run run_tests.py

## Releasing

manual:
1. create an annotated tag and push it to github. `git tag -a TAG and then `git push --tags`
1. `git checkout TAG`
1. `python -m build --sdist --wheel . --outdir dist`
1. `twine check dist/*`
1. `twine upload dist/* --verbose`

# API

```{eval-rst}
.. currentmodule:: depfinder.main
```

```{eval-rst}
.. autofunction:: get_imported_libs
```

```{eval-rst}
.. autofunction:: iterate_over_library
```

```{eval-rst}
.. autofunction:: simple_import_search
```

# IPython/Jupyter Notebook support

`depfinder` has support for v4 Jupyter notebooks.

```{eval-rst}
.. autofunction:: notebook_path_to_dependencies
```

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/ericdill/depfinder",
    "name": "depfinder",
    "maintainer": "",
    "docs_url": "https://pythonhosted.org/depfinder/",
    "requires_python": ">=2.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Eric Dill",
    "author_email": "thedizzle@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/93/d5/12650415524fac04dbc34807b2b15cf06b1c8fea3103fcb937ddbadc8c2a/depfinder-2.10.0.tar.gz",
    "platform": null,
    "description": "# depfinder\n\n[![image](https://github.com/ericdill/depfinder/actions/workflows/tests.yml/badge.svg)](https://github.com/ericdill/depfinder/actions/workflows/tests.yml)\n\n[![image](http://codecov.io/github/ericdill/depfinder/coverage.svg?branch=main)](https://app.codecov.io/github/ericdill/depfinder?branch=main)\n\n-   [docs](https://ericdill.github.io/depfinder)\n-   [github repo](https://github.com/ericdill/depfinder)\n\n## Installation\n\n`depfinder` is on pypi. It is tested against Python 2.7 and 3.6-3.8.\n\n```\npip install depfinder\n```\n\nIt is available via conda.\n```\nconda install -c conda-forge depfinder\n```\n\nIt is also via github.\n```\ngit clone git@github.com:ericdill/depfinder\ncd depfinder\npython setup.py install\n```\n\n## Using depfinder\n\n```\n$ depfinder -h\nusage: depfinder [-h] [-y] [-V] [--no-remap] [-v] [-q] [-k KEY] [--conda]\n                [--pdb]\n                file_or_directory\n\nTool for inspecting the dependencies of your python project.\n\npositional arguments:\n    file_or_directory  Valid options are a single python file, a single jupyter\n                        (ipython) notebook or a directory of files that include\n                        python files\n\noptional arguments:\n    -h, --help         show this help message and exit\n    -y, --yaml         Output in syntactically valid yaml when true. Defaults to\n                        False\n    -V, --version      Print out the version of depfinder and exit\n    --no-remap         Do not remap the names of the imported libraries to their\n                        proper conda name\n    -v, --verbose      Enable debug level logging info from depfinder\n    -q, --quiet        Turn off all logging from depfinder\n    -k KEY, --key KEY  Select some or all of the output keys. Valid options are\n                        'required', 'optional', 'builtin', 'relative', 'all'.\n                        Defaults to 'all'\n    --conda            Format output so it can be passed as an argument to conda\n                        install or conda create\n    --pdb              Enable PDB debugging on exception\n```\n\nOk, great. That's the help output. Not super helpful. What does the\noutput of depfinder look like when we run it on the source code for\ndepfinder?\n```\n$ depfinder depfinder\n{'builtin': ['__future__',\n                'argparse',\n                'ast',\n                'collections',\n                'copy',\n                'errno',\n                'json',\n                'logging',\n                'os',\n                'pprint',\n                're',\n                'subprocess',\n                'sys'],\n    'relative': ['_version', 'main'],\n    'required': ['pyyaml', 'stdlib-list']}\n```\nSo, what do these things mean? Well `builtin` are modules\nthat are built in to the standard library. `required` are\nmodules that are not from the standard library or from within the\n`depfinder` package and `relative` are modules\nthat are imported from one module to another within the\n`depfinder` source code.\n\nAlso see [this\nnotebook](https://github.com/ericdill/depfinder/blob/master/depfinder_usage.ipynb)\n\n## Description\n\nFind all the unique imports in your library, automatically, because who\nlikes do it by hand? [depfinder](https://github.com/ericdill/depfinder)\nuses the [ast](https://docs.python.org/2/library/ast.html) (Abstract\nSyntax Tree) module (and [more ast\ndocs](https://greentreesnakes.readthedocs.io/en/latest/)) to find all\n:py`ast.Try`{.interpreted-text role=\"class\"} and\n:py`ast.ImportFrom`{.interpreted-text role=\"class\"} nodes. These\n:py`ast.Import`{.interpreted-text role=\"class\"} and\n:py`ast.ImportFrom`{.interpreted-text role=\"class\"} nodes are then\ngrouped according to the following categories, in order of decreasing\nprecedence:\n\n- **relative**\n  : The import is a relative import from within the same library\n- **builtin**\n  : The import is built into the standard library, as determined by scraping the\n    official python docs for the builtins with [stdlib-list](https://github.com/jackmaney/python-stdlib-list)\n- **questionable**\n  : The import occurs inside any combination of\n\n    - {py:class}`ast.Try` ({py:class}`ast.TryExcept` on py27)\n    - {py:class}`ast.FunctionDef` or {py:class}`ast.AsyncFunctionDef`\n    - {py:class}`ast.If`, {py:class}`ast.While`, {py:class}`ast.For`, or\n      {py:class}`ast.AsyncFor`.\n    - {py:class}`ast.match_case`.\n\n    The module may be importable without these imports, but the it will likely\n    not have full functionality.\n- **required**\n  : The import occurs at the top level of the module and will get executed\n    when the module is imported. These imports must be accounted for in an\n    environment, or the module will not be importable.\n\n## Testing\n\nIt has dependencies on,\n[stdlib-list](https://github.com/jackmaney/python-stdlib-list) and\n[pyyaml](https://pyyaml.org/wiki/PyYAML). I use `stdlib-list` to get the\nlist of libraries built in to the standard library. These requirements\ncan be installed via pip :\n\n    pip install -r requirements.txt\n\nAlso install the test-requiements :\n\n    pip install -r test-requirements.txt\n\nThen you can run the tests from the root of the git repository :\n\n    coverage run run_tests.py\n\n## Releasing\n\nmanual:\n1. create an annotated tag and push it to github. `git tag -a TAG and then `git push --tags`\n1. `git checkout TAG`\n1. `python -m build --sdist --wheel . --outdir dist`\n1. `twine check dist/*`\n1. `twine upload dist/* --verbose`\n\n# API\n\n```{eval-rst}\n.. currentmodule:: depfinder.main\n```\n\n```{eval-rst}\n.. autofunction:: get_imported_libs\n```\n\n```{eval-rst}\n.. autofunction:: iterate_over_library\n```\n\n```{eval-rst}\n.. autofunction:: simple_import_search\n```\n\n# IPython/Jupyter Notebook support\n\n`depfinder` has support for v4 Jupyter notebooks.\n\n```{eval-rst}\n.. autofunction:: notebook_path_to_dependencies\n```\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Find all the imports in your library",
    "version": "2.10.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/ericdill/depfinder/issues",
        "Documentation": "https://ericdill.github.io/depfinder",
        "Homepage": "http://github.com/ericdill/depfinder",
        "Source Code": "https://github.com/ericdill/depfinder"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "52e423af5a0e69cc86a9b2bccfc779024c62e24727b2b4d5c700ef74a5f1427b",
                "md5": "11ef657ff2804b694b160803bfa2d649",
                "sha256": "3a7cdf3af2a06ceca306e0b717560bd9a841dafa007989fd0728dcd51e6701e8"
            },
            "downloads": -1,
            "filename": "depfinder-2.10.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "11ef657ff2804b694b160803bfa2d649",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=2.7",
            "size": 83235,
            "upload_time": "2023-05-05T18:09:39",
            "upload_time_iso_8601": "2023-05-05T18:09:39.584827Z",
            "url": "https://files.pythonhosted.org/packages/52/e4/23af5a0e69cc86a9b2bccfc779024c62e24727b2b4d5c700ef74a5f1427b/depfinder-2.10.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "93d512650415524fac04dbc34807b2b15cf06b1c8fea3103fcb937ddbadc8c2a",
                "md5": "512072a02287b38824c2cdb6b547d621",
                "sha256": "cbaf7c10d53689df8d0893193ff0eaf728e0f541bd935c464d33c614dc662791"
            },
            "downloads": -1,
            "filename": "depfinder-2.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "512072a02287b38824c2cdb6b547d621",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 96197,
            "upload_time": "2023-05-05T18:09:41",
            "upload_time_iso_8601": "2023-05-05T18:09:41.309209Z",
            "url": "https://files.pythonhosted.org/packages/93/d5/12650415524fac04dbc34807b2b15cf06b1c8fea3103fcb937ddbadc8c2a/depfinder-2.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-05 18:09:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ericdill",
    "github_project": "depfinder",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "depfinder"
}
        
Elapsed time: 0.06012s