{"id":13501507,"url":"https://github.com/ddelange/pipgrip","last_synced_at":"2025-10-08T20:03:08.497Z","repository":{"id":36946224,"uuid":"230768810","full_name":"ddelange/pipgrip","owner":"ddelange","description":"Lightweight pip dependency resolver with deptree preview functionality based on the PubGrub algorithm","archived":false,"fork":false,"pushed_at":"2024-04-01T06:41:57.000Z","size":5890,"stargazers_count":170,"open_issues_count":2,"forks_count":14,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-14T06:11:27.482Z","etag":null,"topics":["dependency-resolution","dependency-resolver","dependency-trees","dephell","pip","pipdeptree","pubgrub","pypi","python","wheels"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddelange.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-29T15:28:50.000Z","updated_at":"2024-06-18T21:18:57.466Z","dependencies_parsed_at":"2023-01-17T07:24:25.651Z","dependency_job_id":"3a45de20-b074-4c36-8fe1-af656540f3d4","html_url":"https://github.com/ddelange/pipgrip","commit_stats":{"total_commits":74,"total_committers":7,"mean_commits":"10.571428571428571","dds":"0.10810810810810811","last_synced_commit":"cddf10dfd238d0b86028fe7f6aaec101dda28ee0"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddelange%2Fpipgrip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddelange%2Fpipgrip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddelange%2Fpipgrip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddelange%2Fpipgrip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddelange","download_url":"https://codeload.github.com/ddelange/pipgrip/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256115,"owners_count":20909240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-resolution","dependency-resolver","dependency-trees","dephell","pip","pipdeptree","pubgrub","pypi","python","wheels"],"created_at":"2024-07-31T22:01:39.853Z","updated_at":"2025-10-08T20:03:08.490Z","avatar_url":"https://github.com/ddelange.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# pipgrip\n\n[![build](https://img.shields.io/github/actions/workflow/status/ddelange/pipgrip/main.yml?branch=master\u0026logo=github\u0026cacheSeconds=86400)](https://github.com/ddelange/pipgrip/actions?query=branch%3Amaster)\n[![codecov](https://img.shields.io/codecov/c/github/ddelange/pipgrip/master?logo=codecov\u0026logoColor=white)](https://codecov.io/gh/ddelange/pipgrip)\n[![pypi](https://img.shields.io/pypi/v/pipgrip.svg?logo=pypi\u0026logoColor=white)](https://pypi.org/project/pipgrip/)\n[![homebrew](https://img.shields.io/homebrew/v/pipgrip?logo=homebrew\u0026logoColor=white)](https://formulae.brew.sh/formula/pipgrip)\n[![python](https://img.shields.io/pypi/pyversions/pipgrip.svg?logo=python\u0026logoColor=white)](https://pypi.org/project/pipgrip/)\n[![downloads](https://static.pepy.tech/badge/pipgrip)](https://pypistats.org/packages/pipgrip)\n\n[pipgrip](https://github.com/ddelange/pipgrip) is a lightweight pip dependency resolver with deptree preview functionality based on the [PubGrub algorithm](https://medium.com/@nex3/pubgrub-2fb6470504f), which is also used by [poetry](https://github.com/python-poetry/poetry). For one or more [PEP 508](https://www.python.org/dev/peps/pep-0508/) dependency specifications, pipgrip recursively fetches/builds the Python wheels necessary for version solving, and optionally renders the full resulting dependency tree.\n\n```\n$ pipgrip --tree fastapi~=0.94\n\nfastapi~=0.94 (0.95.1)\n├── pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,\u003c2.0.0,\u003e=1.6.2 (1.10.7)\n│   └── typing-extensions\u003e=4.2.0 (4.5.0)\n└── starlette\u003c0.27.0,\u003e=0.26.1 (0.26.1)\n    └── anyio\u003c5,\u003e=3.4.0 (3.6.2)\n        ├── idna\u003e=2.8 (3.4)\n        └── sniffio\u003e=1.1 (1.3.0)\n```\n\n#### pipgrip vs. poetry\n\n[poetry](https://github.com/python-poetry/poetry) offers package management with dependency resolution, essentially replacing pip/setuptools. This means that poetry packages don't contain `setup.py`, and hence are not compatible with `pip install -e`: poetry projects would have to be converted to setuptools-based projects with e.g. [dephell](https://github.com/dephell/dephell). To avoid such hassle, pipgrip only requires the selected package(s) + dependencies to be available to pip in the usual way.\n\n#### pipgrip vs. pipdeptree\n\nFor offline usage, [pipdeptree](https://github.com/naiquevin/pipdeptree) can inspect the current environment and show how the currently installed packages relate to each other. This however requires the packages to be pip-installed, and (despite warnings about e.g. cyclic dependencies) offers no form of dependency resolution since it's only based on the (single) package versions installed in the environment. Such shortcomings are avoided when using pipgrip, since **packages don't need to be installed and all versions available to pip are considered**.\n\n## Installation\n\nThis pure-Python, OS independent package is available on [PyPI](https://pypi.org/project/pipgrip/):\n\n```\npip install pipgrip\n```\n\n## Usage\n\nThis package can be used to:\n\n- **Render** an exhaustive dependency tree for any given pip-compatible package(s):\n  - `pipgrip --tree requests`\n- **Alleviate** [Python dependency hell](https://medium.com/knerd/the-nine-circles-of-python-dependency-hell-481d53e3e025) by resolving the latest viable combination of required packages\n- **Avoid** bugs by running pipgrip as a stage in CI pipelines\n- **Detect** version conflicts for given constraints and give human readable feedback about it\n- **Warn** for cyclic dependencies in local projects [and install them anyway]:\n  - `pipgrip -v --tree . [--install -e]`\n- **Install** complex packages without worries:\n  - `pipgrip --install aiobotocore[awscli]`\n- **Generate** a lockfile with a complete working set of dependencies for reproducible installs:\n  - `pipgrip --lock aiobotocore[awscli] \u0026\u0026 pip install aiobotocore[awscli] --constraint ./pipgrip.lock`\n- **Combine** dependency trees of multiple packages into one unified set of pinned packages:\n  - `pipgrip .[boto3] s3transfer==0.2.1 s3fs smart_open[s3]`\n\nSee also [known caveats](#known-caveats).\n\nOptionally, the environment variable `PIPGRIP_ADDITIONAL_REQUIREMENTS` can be populated with space/newline separated requirements, which will be appended to the requirements passed via CLI.\n\n```\n$ pipgrip --help\n\nUsage: pipgrip [OPTIONS] [DEPENDENCIES]...\n\n  pipgrip is a lightweight pip dependency resolver with deptree preview\n  functionality based on the PubGrub algorithm, which is also used by poetry. For\n  one or more PEP 508 dependency specifications, pipgrip recursively\n  fetches/builds the Python wheels necessary for version solving, and optionally\n  renders the full resulting dependency tree.\n\nOptions:\n  --install                     Install full dependency tree after resolving.\n  -e, --editable                Install a project in editable mode.\n  --user                        Install to the Python user install directory for\n                                your platform -- typically ~/.local/, or\n                                %APPDATA%\\Python on Windows.\n  -r, --requirements-file FILE  Install from the given requirements file. This\n                                option can be used multiple times.\n  --lock                        Write out pins to './pipgrip.lock'.\n  --pipe                        Output space-separated pins instead of newline-\n                                separated pins.\n  --json                        Output pins as JSON dict instead of newline-\n                                separated pins. Combine with --tree for a detailed\n                                nested JSON dependency tree.\n  --sort                        Sort pins alphabetically before writing out. Can\n                                be used bare, or in combination with --lock,\n                                --pipe, --json, --tree-json, or --tree-json-exact.\n  --tree                        Output human readable dependency tree (top-down).\n                                Combine with --json for a detailed nested JSON\n                                dependency tree. Use --tree-json instead for a\n                                simplified JSON dependency tree (requirement\n                                strings as keys, dependencies as values), or\n                                --tree-json-exact for exact pins as keys.\n  --tree-ascii                  Output human readable dependency tree with ASCII\n                                tree markers.\n  --reversed-tree               Output human readable dependency tree (bottom-up).\n  --max-depth INTEGER           Maximum (JSON) tree rendering depth (default -1).\n  --cache-dir DIRECTORY         Use a custom cache dir.\n  --no-cache-dir                Disable pip cache for the wheels downloaded by\n                                pipper. Overrides --cache-dir.\n  --index-url TEXT              Base URL of the Python Package Index (default\n                                https://pypi.org/simple).\n  --extra-index-url TEXT        Extra URLs of package indexes to use in addition\n                                to --index-url.\n  --threads INTEGER             Maximum amount of threads to use for running\n                                concurrent pip subprocesses.\n  --pre                         Include pre-release and development versions. By\n                                default, pip implicitly excludes pre-releases\n                                (unless specified otherwise by PEP 440).\n  -v, --verbose                 Control verbosity: -v will print cyclic\n                                dependencies (WARNING), -vv will show solving\n                                decisions (INFO), -vvv for development (DEBUG).\n  --skip-invalid-input          Skip invalid requirements (e.g. internal\n                                repositories, typos) and continue processing\n                                other dependencies.\n  --version                     Show the version and exit.\n  -h, --help                    Show this message and exit.\n```\n\n#### Dependency trees\n\nExhaustive dependency trees without the need to install any packages ([at most build some wheels](https://github.com/ddelange/pipgrip/issues/40)).\n\n```\n$ pipgrip --tree pipgrip\n\npipgrip (0.10.6)\n├── anytree\u003e=2.4.1 (2.9.0)\n│   └── six (1.16.0)\n├── click\u003e=7 (8.1.6)\n├── packaging\u003e=17 (23.1)\n├── pip\u003e=22.2 (23.2.1)\n├── setuptools\u003e=38.3 (68.0.0)\n└── wheel (0.41.1)\n```\n\nFor more details/further processing, combine `--tree` with `--json` for a detailed nested JSON dependency tree. See also `--tree-ascii` (no unicode tree markers), and `--tree-json` \u0026 `--tree-json-exact` (simplified JSON dependency trees).\n\n#### Lockfile generation\n\nUsing the `--lock` option, resolved (pinned) dependencies are additionally written to `./pipgrip.lock`.\n\n```\n$ pipgrip --tree --lock botocore==1.13.48 'boto3\u003e=1.10,\u003c1.10.50'\n\nbotocore==1.13.48 (1.13.48)\n├── docutils\u003c0.16,\u003e=0.10 (0.15.2)\n├── jmespath\u003c1.0.0,\u003e=0.7.1 (0.9.5)\n├── python-dateutil\u003c3.0.0,\u003e=2.1 (2.8.1)\n│   └── six\u003e=1.5 (1.14.0)\n└── urllib3\u003c1.26,\u003e=1.20 (1.25.8)\nboto3\u003c1.10.50,\u003e=1.10 (1.10.48)\n├── botocore\u003c1.14.0,\u003e=1.13.48 (1.13.48)\n│   ├── docutils\u003c0.16,\u003e=0.10 (0.15.2)\n│   ├── jmespath\u003c1.0.0,\u003e=0.7.1 (0.9.5)\n│   ├── python-dateutil\u003c3.0.0,\u003e=2.1 (2.8.1)\n│   │   └── six\u003e=1.5 (1.14.0)\n│   └── urllib3\u003c1.26,\u003e=1.20 (1.25.8)\n├── jmespath\u003c1.0.0,\u003e=0.7.1 (0.9.5)\n└── s3transfer\u003c0.3.0,\u003e=0.2.0 (0.2.1)\n    └── botocore\u003c2.0.0,\u003e=1.12.36 (1.13.48)\n        ├── docutils\u003c0.16,\u003e=0.10 (0.15.2)\n        ├── jmespath\u003c1.0.0,\u003e=0.7.1 (0.9.5)\n        ├── python-dateutil\u003c3.0.0,\u003e=2.1 (2.8.1)\n        │   └── six\u003e=1.5 (1.14.0)\n        └── urllib3\u003c1.26,\u003e=1.20 (1.25.8)\n\n$ cat ./pipgrip.lock\n\nbotocore==1.13.48\ndocutils==0.15.2\njmespath==0.9.5\npython-dateutil==2.8.1\nsix==1.14.0\nurllib3==1.25.8\nboto3==1.10.48\ns3transfer==0.2.1\n```\n\nNOTE:\nSince the selected botocore version is older than the one required by the recent versions of boto3, all boto3 versions will be checked for compatibility with botocore==1.13.48.\n\n#### Version conflicts\n\nIf version conflicts exist for the given (ranges of) package version(s), a verbose explanation is raised.\n\n```\n$ pipgrip auto-sklearn~=0.6 dragnet==2.0.4\n\nError: Because dragnet (2.0.4) depends on scikit-learn (\u003e=0.15.2,\u003c0.21.0)\n and auto-sklearn (0.6.0) depends on scikit-learn (\u003c0.22,\u003e=0.21.0), dragnet (2.0.4) is incompatible with auto-sklearn (0.6.0).\nAnd because no versions of auto-sklearn match \u003e0.6.0,\u003c1.0, dragnet (2.0.4) is incompatible with auto-sklearn (\u003e=0.6.0,\u003c1.0).\nSo, because root depends on both auto-sklearn (~=0.6) and dragnet (==2.0.4), version solving failed.\n```\n\nNOTE:\nIf older versions of auto-sklearn are allowed, PubGrub will try all acceptable versions of auto-sklearn. In this case, auto-sklearn==0.5.2 requires scikit-learn (\u003c0.20,\u003e=0.19), making it compatible with dragnet==2.0.4.\n\n#### Cyclic dependencies\n\nIf cyclic dependencies are found, it is noted in the resulting tree.\n\n```\n$ pipgrip --tree -v keras==2.2.2\n\nWARNING: Cyclic dependency found: keras depends on keras-applications and vice versa.\nWARNING: Cyclic dependency found: keras depends on keras-preprocessing and vice versa.\nkeras==2.2.2 (2.2.2)\n├── h5py (2.10.0)\n│   ├── numpy\u003e=1.7 (1.18.1)\n│   └── six (1.14.0)\n├── keras-applications==1.0.4 (1.0.4)\n│   ├── h5py (2.10.0)\n│   │   ├── numpy\u003e=1.7 (1.18.1)\n│   │   └── six (1.14.0)\n│   ├── keras\u003e=2.1.6 (2.2.2, cyclic)\n│   └── numpy\u003e=1.9.1 (1.18.1)\n├── keras-preprocessing==1.0.2 (1.0.2)\n│   ├── keras\u003e=2.1.6 (2.2.2, cyclic)\n│   ├── numpy\u003e=1.9.1 (1.18.1)\n│   ├── scipy\u003e=0.14 (1.4.1)\n│   │   └── numpy\u003e=1.13.3 (1.18.1)\n│   └── six\u003e=1.9.0 (1.14.0)\n├── numpy\u003e=1.9.1 (1.18.1)\n├── pyyaml (5.3)\n├── scipy\u003e=0.14 (1.4.1)\n│   └── numpy\u003e=1.13.3 (1.18.1)\n└── six\u003e=1.9.0 (1.14.0)\n```\n\n## Known caveats\n\n- PubGrub doesn't support [version epochs](https://www.python.org/dev/peps/pep-0440/#version-epochs), the [main reason](https://github.com/pypa/pip/issues/8203#issuecomment-704931138) PyPA chose [resolvelib](https://github.com/sarugaku/resolvelib) over PubGrub for their new resolver.\n- Package names are canonicalised in wheel metadata, resulting in e.g. `path.py -\u003e path-py` and `keras_preprocessing -\u003e keras-preprocessing` in output.\n- [VCS Support](https://pip.pypa.io/en/stable/topics/vcs-support): combining VCS requirements with `--editable`, as well as the [`@ -e svn+`](https://pip.pypa.io/en/stable/topics/vcs-support/#subversion) pattern are not supported.\n- Similar to setuptools' `install_requires`, omitting the `projectname @` prefix is not supported neither for VCS requirements (like `pip install git+https...`), nor for [PEP 440](https://www.python.org/dev/peps/pep-0440) direct references (like `pip install https...`).\n- Parsing requirements files (`-r`) does not support: [custom file encodings](https://pip.pypa.io/en/stable/reference/requirements-file-format/#encoding), [line continuations](https://pip.pypa.io/en/stable/reference/requirements-file-format/#line-continuations), [global/per-requirement options](https://pip.pypa.io/en/stable/reference/requirements-file-format/#supported-options)\n- `--reversed-tree` isn't implemented yet.\n- Since `pip install -r` does not accept `.` as requirement, it is omitted from `--lock` output. So when installing local projects, either `--pipe` or `--install` should be used (the latter basically does `pipgrip --lock . \u0026\u0026 pip install . --constraint ./pipgrip.lock`).\n- Local paths are not supported (like `pip install -e ../aiobotocore[boto3]`), except for the current directory (like `pipgrip --install -e .[boto3]`).\n\n## Development\n\n[![gitmoji](https://img.shields.io/badge/gitmoji-%20%F0%9F%98%9C%20%F0%9F%98%8D-ffdd67)](https://github.com/carloscuesta/gitmoji-cli)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)\n\nRun `make help` for options like installing for development, linting and testing.\n\n## See also\n\n- [PubGrub spec](https://github.com/dart-lang/pub/blob/SDK-2.2.1-dev.3.0/doc/solver.md)\n- [pip now has a dependency resolver](https://github.com/pypa/pip/issues/988#issuecomment-735776472)\n- [pipdeptree](https://github.com/naiquevin/pipdeptree)\n- [mixology](https://github.com/sdispater/mixology)\n- [poetry-semver](https://github.com/python-poetry/semver)\n- [johnnydep](https://github.com/wimglenn/johnnydep)\n\n-----\n\nBSD 3-Clause License\n\nCopyright (c) 2020 - 2024, ddelange, \u003cddelange@delange.dev\u003e\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nSPDX-License-Identifier: BSD-3-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddelange%2Fpipgrip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddelange%2Fpipgrip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddelange%2Fpipgrip/lists"}