Skip to content

Latest commit

 

History

History
98 lines (70 loc) · 4.93 KB

README.md

File metadata and controls

98 lines (70 loc) · 4.93 KB

pydistcheck

conda-forge version conda-forge downloads PyPI Version PyPI downloads Documentation Status GitHub Actions GitHub Actions

What is pydistcheck?

pydistcheck is a command line interface (CLI) that you run on Python packages, which can:

  • detect common portability issues
  • print useful summaries of the package's contents

It's inspired by R's R CMD check.

Supported formats:

  • Python sdists
  • Python wheels
  • conda packages (both .conda and .tar.bz2)
  • any .tar.bz2, .tar.gz, or .zip archive

See "How to Test a Python Distribution" to see how it and similar tools like auditwheel, check-wheel-contents, and twine check fit into Python development workflows.

For more background on the value of such a tool, see the SciPy 2022 talk "Does that CSV Belong on PyPI? Probably Not" (video link).

Installation

Install with pip.

pip install pydistcheck

Or conda.

conda install -c conda-forge pydistcheck

For more details, see "Installation" (link).

Quickstart

Try it out on the test data in this project ...

pydistcheck tests/data/problematic-package-*

... to see the types of issues it checks for.

------------ check results -----------
1. [files-only-differ-by-case] Found files which differ only by case. Files: problematic-package-0.1.0/problematic_package/Question.py,problematic-package-0.1.0/problematic_package/question.PY,problematic-package-0.1.0/problematic_package/question.py
2. [mixed-file-extensions] Found a mix of file extensions for the same file type: .NDJSON (1), .jsonl (1), .ndjson (1)
3. [mixed-file-extensions] Found a mix of file extensions for the same file type: .yaml (2), .yml (1)
4. [path-contains-non-ascii-characters] Found file path containing non-ASCII characters: 'problematic-package-0.1.0/problematic_package/?veryone-loves-python.py'
5. [path-contains-spaces] Found path with spaces: 'problematic-package-0.1.0/beep boop.ini'
6. [path-contains-spaces] Found path with spaces: 'problematic-package-0.1.0/problematic_package/bad code/'
7. [path-contains-spaces] Found path with spaces: 'problematic-package-0.1.0/problematic_package/bad code/__init__.py'
8. [path-contains-spaces] Found path with spaces: 'problematic-package-0.1.0/problematic_package/bad code/ship-it.py'
9. [unexpected-files] Found unexpected directory 'problematic-package-0.1.0/.git/'.
10. [unexpected-files] Found unexpected file 'problematic-package-0.1.0/.gitignore'.
11. [unexpected-files] Found unexpected file 'problematic-package-0.1.0/.hadolint.yaml'.
12. [unexpected-files] Found unexpected file 'problematic-package-0.1.0/problematic_package/.gitignore'.
errors found while checking: 12

And on a built distribution containing compiled objects ...

pydistcheck tests/data/debug-baseballmetrics*.whl

... pydistcheck can detect the inclusion of debug symbols (which increase distribution size).

checking 'tests/data/debug-baseballmetrics-0.1.0-py3-none-macosx_10_15_x86_64.macosx_11_6_x86_64.macosx_12_5_x86_64.whl'
------------ check results -----------
1. [compiled-objects-have-debug-symbols] Found compiled object containing debug symbols. For details, extract the distribution contents and run 'dsymutil -s "lib/lib_baseballmetrics.dylib"'.
errors found while checking: 1

checking 'tests/data/debug-baseballmetrics-py3-none-manylinux_2_28_x86_64.manylinux_2_5_x86_64.manylinux1_x86_64.whl'
------------ check results -----------
1. [compiled-objects-have-debug-symbols] Found compiled object containing debug symbols. For details, extract the distribution contents and run 'objdump --all-headers "lib/lib_baseballmetrics.so"'.
errors found while checking: 1

See https://pydistcheck.readthedocs.io/en/latest/ to learn more.

References