pax_global_header00006660000000000000000000000064140066155300014512gustar00rootroot0000000000000052 comment=8b4ba6bf7a70ebbde77743c81b371b4ac7ec2982 dependency-info-1.7.0/000077500000000000000000000000001400661553000145665ustar00rootroot00000000000000dependency-info-1.7.0/.editorconfig000066400000000000000000000005071400661553000172450ustar00rootroot00000000000000# Editor Configuration (http://editorconfig.org) root = true [*] charset = utf-8 indent_style = space indent_size = 4 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true max_line_length = 88 [*.{json,yml}] indent_size = 2 [*.{md,rst}] trim_trailing_whitespace = false [Makefile] indent_style = tab dependency-info-1.7.0/.gitattributes000066400000000000000000000000451400661553000174600ustar00rootroot00000000000000src/depinfo/_version.py export-subst dependency-info-1.7.0/.github/000077500000000000000000000000001400661553000161265ustar00rootroot00000000000000dependency-info-1.7.0/.github/CODE_OF_CONDUCT.md000066400000000000000000000122441400661553000207300ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [midnighter@posteo.net](mailto:midnighter@posteo.net?subject=Code%20of%20Conduct). All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. dependency-info-1.7.0/.github/CONTRIBUTING.rst000066400000000000000000000065751400661553000206040ustar00rootroot00000000000000============ Contributing ============ Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. You can contribute in many ways: Report Bugs =========== Report bugs at https://github.com/Midnighter/dependency-info/issues. If you are reporting a bug, please follow the template guidelines. The more detailed your report, the easier and thus faster we can help you. Fix Bugs ======== Look through the GitHub issues for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to implement it. Implement Features ================== Look through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it. Write Documentation =================== dependency-info could always use more documentation, whether as part of the official documentation, in docstrings, or even on the web in blog posts, articles, and such. Submit Feedback =============== The best way to send feedback is to file an issue at https://github.com/Midnighter/dependency-info/issues. If you are proposing a feature: * Explain in detail how it would work. * Keep the scope as narrow as possible, to make it easier to implement. * Remember that this is a volunteer-driven project, and that contributions are welcome :) Get Started! ============ Ready to contribute? Here's how to set up dependency-info for local development. 1. Fork the https://github.com/Midnighter/dependency-info repository on GitHub. 2. Clone your fork locally .. code-block:: console git clone git@github.com:your_name_here/dependency-info.git 3. Install your local copy into a a Python virtual environment. You can `read this guide to learn more `_ about them and how to create one. Alternatively, particularly if you are a Windows or Mac user, you can also use `Anaconda `_. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development .. code-block:: console mkvirtualenv my-env cd dependency-info/ pip install -e .[development] 4. Create a branch for local development using the ``devel`` branch as a starting point. Use ``fix`` or ``feat`` as a prefix .. code-block:: console git checkout devel git checkout -b fix-name-of-your-bugfix Now you can make your changes locally. 5. When you're done making changes, apply the quality assurance tools and check that your changes pass our test suite. This is all included with tox .. code-block:: console make qa tox 6. Commit your changes and push your branch to GitHub. Please use `semantic commit messages `_. .. code-block:: console git add . git commit -m "fix: Your summary of changes" git push origin fix-name-of-your-bugfix 7. Open the link displayed in the message when pushing your new branch in order to submit a pull request. Pull Request Guidelines ======================= Before you submit a pull request, check that it meets these guidelines: 1. The pull request should include tests. 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring. dependency-info-1.7.0/.github/ISSUE_TEMPLATE/000077500000000000000000000000001400661553000203115ustar00rootroot00000000000000dependency-info-1.7.0/.github/ISSUE_TEMPLATE/01-bug-report.md000066400000000000000000000017751400661553000231510ustar00rootroot00000000000000--- name: Bug report about: Report a bug to help improve this project --- #### Problem description Please explain: * **what** you tried to achieve, * **how** you went about it (referring to the code sample), and * **why** the current behaviour is a problem and what output you expected instead. #### Code Sample Create a [minimal, complete, verifiable example](https://stackoverflow.com/help/mcve). ```python ``` ``` ``` ### Context
``` ```
dependency-info-1.7.0/.github/ISSUE_TEMPLATE/02-question.md000066400000000000000000000010311400661553000227140ustar00rootroot00000000000000--- name: Question about: Ask a question --- ### Checklist - [ ] I searched the [documentation](https://dependency-info.readthedocs.io). - [ ] I looked through [similar issues on GitHub](https://github.com/Midnighter/dependency-info/issues). - [ ] I looked up "How to do ... in dependency-info" on a search engine. ### Question dependency-info-1.7.0/.github/ISSUE_TEMPLATE/03-feature-request.md000066400000000000000000000017561400661553000242050ustar00rootroot00000000000000--- name: Feature request about: Suggest an idea for this project --- ### Checklist - [ ] There are [no similar issues or pull requests](https://github.com/Midnighter/dependency-info/issues) for this yet. ### Is your feature related to a problem? Please describe it. ## Describe the solution you would like. ## Describe alternatives you considered ## Additional context dependency-info-1.7.0/.github/PULL_REQUEST_TEMPLATE.md000066400000000000000000000002171400661553000217270ustar00rootroot00000000000000* [ ] fix #(issue number) * [ ] description of feature/fix * [ ] tests added/passed * [ ] add an entry to the [next release](../CHANGELOG.rst) dependency-info-1.7.0/.github/SUPPORT.md000066400000000000000000000001351400661553000176230ustar00rootroot00000000000000## Support * Please open [an issue](https://github.com/Midnighter/dependency-info/issues). dependency-info-1.7.0/.github/workflows/000077500000000000000000000000001400661553000201635ustar00rootroot00000000000000dependency-info-1.7.0/.github/workflows/main.yml000066400000000000000000000045731400661553000216430ustar00rootroot00000000000000name: CI-CD on: push: branches: - stable - devel tags: - '[0-9]+.[0-9]+.[0-9]+' - '[0-9]+.[0-9]+.[0-9]+rc[0-9]+' pull_request: branches: - stable - devel jobs: test: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: [3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel python -m pip install tox tox-gh-actions - name: Test with tox run: tox -- --cov-report=xml - name: Report coverage shell: bash run: bash <(curl -s https://codecov.io/bash) release: needs: test if: startsWith(github.ref, 'refs/tags') runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest] python-version: [3.8] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Get tag id: tag run: echo "::set-output name=version::${GITHUB_REF#refs/tags/}" - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel python -m pip install twine pep517 - name: Check PEP517 install run: python -m pep517.check . - name: Build package run: python -m pep517.build --source --binary . - name: Check the package run: twine check dist/* - name: Publish to PyPI env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: twine upload --skip-existing --non-interactive dist/* - name: Create GitHub release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} release_name: ${{ github.ref }} body: > Please see https://github.com/${{ github.repository }}/blob/${{ steps.tag.outputs.version }}/CHANGELOG.rst for the full release notes. draft: false prerelease: false dependency-info-1.7.0/.gitignore000066400000000000000000000023671400661553000165660ustar00rootroot00000000000000# Created by .ignore support plugin (hsz.mobi) ### Python template # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ dependency-info-1.7.0/CHANGELOG.rst000066400000000000000000000010451400661553000166070ustar00rootroot00000000000000========== Change Log ========== Next Release ------------ 1.7.0 (2021-02-03) ------------------ * Improve parsing of package information (#6). 1.6.0 (2020-10-11) ------------------ * Switch to versioneer-518. * Remove ``pipdeptree`` and use ``importlib.metadata`` instead. * Support Python version 3.6 - 3.9. 1.5.1 (2019-02-17) ------------------ * Improve internal quality control. 1.5.0 (2019-02-07) ------------------ * Require a newer pipdeptree version. * Introduce black. * Fix parametrized test cases. * Update package configuration. dependency-info-1.7.0/LICENSE000066400000000000000000000236751400661553000156100ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS dependency-info-1.7.0/MANIFEST.in000066400000000000000000000001321400661553000163200ustar00rootroot00000000000000include src/depinfo/_version.py include README.rst include LICENSE include pyproject.toml dependency-info-1.7.0/README.rst000066400000000000000000000043211400661553000162550ustar00rootroot00000000000000============================== Package Dependency Information ============================== .. image:: https://img.shields.io/pypi/v/depinfo.svg :target: https://pypi.org/project/depinfo/ :alt: Current PyPI Version .. image:: https://img.shields.io/pypi/pyversions/depinfo.svg :target: https://pypi.org/project/dependency-info/ :alt: Supported Python Versions .. image:: https://img.shields.io/pypi/l/depinfo.svg :target: https://www.apache.org/licenses/LICENSE-2.0 :alt: Apache Software License Version 2.0 .. image:: https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg :target: .github/CODE_OF_CONDUCT.md :alt: Code of Conduct .. image:: https://github.com/Midnighter/dependency-info/workflows/CI-CD/badge.svg :target: https://github.com/Midnighter/dependency-info/workflows/CI-CD :alt: GitHub Actions .. image:: https://codecov.io/gh/Midnighter/dependency-info/branch/stable/graph/badge.svg :target: https://codecov.io/gh/Midnighter/dependency-info :alt: Codecov .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black :alt: Code Style Black .. code-block:: python from depinfo import print_dependencies def show_versions(): print_dependencies("your-package-name") That's all there is to it. If instead you want to access and modify the information, you can make use of the underlying functions that return dictionaries that map package names to their current versions. By default it will include common build packages such as ``pip``. .. code-block:: python from depinfo import get_pkg_info help(get_pkg_info) Example ======= .. code-block:: python from depinfo import print_dependencies print_dependencies("depinfo") .. code-block:: console System Information ================== OS Linux OS-release 4.4.0-122-generic Python 3.6.5 Package Versions ================ pip 10.0.1 setuptools 39.0.1 wheel 0.31.0 Copyright ========= * Copyright © 2018-2021, Moritz E. Beber. * Free software distributed under the `Apache Software License 2.0 `_. dependency-info-1.7.0/pyproject.toml000066400000000000000000000003151400661553000175010ustar00rootroot00000000000000[build-system] build-backend = "setuptools.build_meta" requires = [ "setuptools>=40.6.0", "versioneer-518", "wheel" ] [tool.black] line-length = 88 python-version = ['py36', 'py37', 'py38', 'py39'] dependency-info-1.7.0/setup.cfg000066400000000000000000000031731400661553000164130ustar00rootroot00000000000000[metadata] name = depinfo url = https://github.com/Midnighter/dependency-info download_url = https://pypi.org/project/depinfo/ project_urls = Source Code = https://github.com/Midnighter/dependency-info Bug Tracker = https://github.com/Midnighter/dependency-info/issues author = Moritz E. Beber author_email = midnighter@posteo.net classifiers = Development Status :: 5 - Production/Stable Intended Audience :: Developers License :: OSI Approved :: Apache Software License Natural Language :: English Operating System :: OS Independent Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Topic :: Utilities license = Apache-2.0 description = List any package's direct dependencies and their versions. long_description = file: README.rst long_description_content_type = text/x-rst keywords = dependency dependencies tree version [options] zip_safe = True install_requires = importlib_metadata; python_version <'3.8' python_requires = >=3.6 tests_require = tox packages = find: package_dir = = src [options.packages.find] where = src [options.extras_require] development = black isort tox [bdist_wheel] universal = 1 # See the docstring in versioneer.py for instructions. Note that you must # re-run 'versioneer.py setup' after changing this section, and commit the # resulting files. [versioneer] VCS = git style = pep440 versionfile_source = src/depinfo/_version.py versionfile_build = depinfo/_version.py tag_prefix = dependency-info-1.7.0/setup.py000066400000000000000000000014771400661553000163110ustar00rootroot00000000000000#!/usr/bin/env python # Copyright (c) 2018, Moritz E. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Set up the dependency information package.""" import versioneer from setuptools import setup # All other arguments are defined in `setup.cfg`. setup(version=versioneer.get_version(), cmdclass=versioneer.get_cmdclass()) dependency-info-1.7.0/src/000077500000000000000000000000001400661553000153555ustar00rootroot00000000000000dependency-info-1.7.0/src/depinfo/000077500000000000000000000000001400661553000170015ustar00rootroot00000000000000dependency-info-1.7.0/src/depinfo/__init__.py000066400000000000000000000013051400661553000211110ustar00rootroot00000000000000# Copyright (c) 2018, Moritz E. Beber # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Create top level imports.""" __author__ = "Moritz E. Beber" __email__ = "midnighter@posteo.net" from .info import * dependency-info-1.7.0/src/depinfo/_version.py000066400000000000000000000000001400661553000211650ustar00rootroot00000000000000dependency-info-1.7.0/src/depinfo/info.py000066400000000000000000000061441400661553000203130ustar00rootroot00000000000000# Copyright (c) 2018, Moritz E. Beber # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Construct and print a package's dependencies.""" import platform import re from typing import Dict, Iterable, Tuple try: from importlib.metadata import PackageNotFoundError, distribution, version except ModuleNotFoundError: from importlib_metadata import PackageNotFoundError, distribution, version __all__ = ( "get_pkg_info", "get_sys_info", "print_dependencies", "print_info", "show_versions", ) def get_sys_info() -> Dict[str, str]: """Return system information as a dict.""" blob = dict() blob["OS"] = platform.system() blob["OS-release"] = platform.release() blob["Python"] = platform.python_version() return blob def _get_package_version(requirement: str) -> Tuple[str, str]: """ Return a package, version pair from a requirement description. Raises: importlib.metadata.PackageNotFoundError: If the package is not found in the environment. """ package = re.split(r"[;<>=\s]", requirement)[0] return package, version(package) def get_pkg_info( package_name: str, additional: Iterable[str] = ("pip", "flit", "pbr", "poetry", "setuptools", "wheel"), ) -> Dict[str, str]: """Return build and package dependencies as a dict.""" dist = distribution(package_name) dependencies = {package_name: dist.version} for requirement in dist.requires: try: pkg, ver = _get_package_version(requirement) except PackageNotFoundError: dependencies[requirement] = "not installed" else: dependencies[pkg] = ver for name in additional: try: pkg, ver = _get_package_version(name) except PackageNotFoundError: continue else: dependencies[pkg] = ver return dependencies def print_info(info: Dict[str, str]) -> None: """Print an information dict to stdout in order.""" longest_package = max(map(len, info)) longest_version = max(map(len, info.values())) for name in sorted(info): print(f"{name:<{longest_package}} {info[name]:>{longest_version}}") def print_dependencies(package_name: str) -> None: """Print the formatted information to standard out.""" info = get_sys_info() print("\nSystem Information") print("==================") print_info(info) info = get_pkg_info(package_name) print("\nPackage Versions") print("================") print_info(info) def show_versions() -> None: """Print dependency information for this package.""" print_dependencies("depinfo") dependency-info-1.7.0/tests/000077500000000000000000000000001400661553000157305ustar00rootroot00000000000000dependency-info-1.7.0/tests/test_info.py000066400000000000000000000075741400661553000203110ustar00rootroot00000000000000# Copyright (c) 2018, Moritz E. Beber # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Verify the expected functionality of dependency information.""" import platform from typing import Dict import pytest import depinfo from depinfo.info import _get_package_version def test_get_sys_info() -> None: """Expect correct platform information.""" blob = depinfo.get_sys_info() assert "OS" in blob assert "OS-release" in blob assert "Python" in blob assert blob["OS"] == platform.system() assert blob["OS-release"] == platform.release() assert blob["Python"] == platform.python_version() def test_get_pkg_info() -> None: """Expect minimal package dependencies.""" blob = depinfo.get_pkg_info("depinfo") assert "depinfo" in blob assert "pip" in blob assert "setuptools" in blob assert "wheel" in blob @pytest.mark.parametrize( "blob, output", [ pytest.param({}, "", marks=pytest.mark.raises(exception=ValueError)), ({"pip": "10.0.0", "wheel": "0.5"}, "pip 10.0.0\nwheel 0.5\n"), ], ) def test_print_info(capsys, blob: Dict[str, str], output: str) -> None: """Expect stdout in order and correctly formatted.""" depinfo.print_info(blob) captured = capsys.readouterr() assert captured.out == output @pytest.mark.parametrize( "requirement, package", [ ("pip", "pip"), ("pip (~=1.4)", "pip"), ("pip (==5.18.3)", "pip"), ("pip (<1.4.6)", "pip"), ("pip (>1.4.6)", "pip"), ("pip>=2.0.5", "pip"), ("pip==1.19.3", "pip"), ('pip>=6.1; extra == "development"', "pip"), ('pip>=6.1 ; extra == "development"', "pip"), ], ) def test_get_package_version(requirement, package): """Expect package to be parsed from requirement.""" p, _ = _get_package_version(requirement) assert p == package def test_print_dependencies(capsys) -> None: """Expect all printed information in order.""" depinfo.print_dependencies("depinfo") captured = capsys.readouterr() lines = captured.out.split("\n") assert lines[1].startswith("System Information") assert lines[2].startswith("==================") assert lines[3].startswith("OS") assert lines[4].startswith("OS-release") assert lines[5].startswith("Python") assert lines[7].startswith("Package Versions") assert lines[8].startswith("================") assert any(line.startswith("depinfo") for line in lines[9:]) assert any(line.startswith("pip") for line in lines[9:]) assert any(line.startswith("setuptools") for line in lines[9:]) assert any(line.startswith("wheel") for line in lines[9:]) def test_show_versions(capsys) -> None: """Expect all printed information in order.""" depinfo.show_versions() captured = capsys.readouterr() lines = captured.out.split("\n") assert lines[1].startswith("System Information") assert lines[2].startswith("==================") assert lines[3].startswith("OS") assert lines[4].startswith("OS-release") assert lines[5].startswith("Python") assert lines[7].startswith("Package Versions") assert lines[8].startswith("================") assert any(line.startswith("depinfo") for line in lines[9:]) assert any(line.startswith("pip") for line in lines[9:]) assert any(line.startswith("setuptools") for line in lines[9:]) assert any(line.startswith("wheel") for line in lines[9:]) dependency-info-1.7.0/tox.ini000066400000000000000000000034501400661553000161030ustar00rootroot00000000000000[tox] envlist = isort, black, flake8, safety, py3{6,7,8,9} isolated_build = true [gh-actions] python = 3.6: safety, py36 3.7: isort, black, flake8, safety, py37 3.8: safety, py38 3.9: safety, py39 [testenv] deps = pytest pytest-cov pytest-raises commands = pytest --cov=depinfo --cov-report=term {posargs} [testenv:isort] skip_install = True deps= isort commands= isort --check-only --diff {toxinidir}/src/depinfo {toxinidir}/tests {toxinidir}/setup.py [testenv:black] skip_install = True deps= black commands= black --check --diff {toxinidir}/src/depinfo {toxinidir}/tests {toxinidir}/setup.py [testenv:flake8] skip_install = True deps= flake8 flake8-docstrings flake8-bugbear commands= flake8 {toxinidir}/src/depinfo {toxinidir}/tests {toxinidir}/setup.py [testenv:safety] deps= safety commands= safety check --full-report ################################################################################ # Testing tools configuration # ################################################################################ [pytest] testpaths = tests markers = raises [coverage:paths] source = src/depinfo */site-packages/depinfo [coverage:run] branch = true parallel = true omit = src/depinfo/_version.py [coverage:report] exclude_lines = # Have to re-enable the standard pragma pragma: no cover precision = 2 omit = src/depinfo/_version.py [flake8] max-line-length = 88 exclude = __init__.py # The following conflict with `black` which is the more pedantic. ignore = E203 W503 D202 [isort] skip = __init__.py profile = black indent = 4 lines_after_imports = 2 known_first_party = depinfo known_third_party = pytest setuptools versioneer