Pyroma
Pyroma is a Python library and command-line tool designed to test your project's packaging friendliness. It evaluates a Python project's metadata, structure, and configuration (e.g., `setup.py`, `pyproject.toml`) against a set of best practices to determine how well-prepared it is for distribution on PyPI. The current version is 5.0.1, with major releases occurring roughly annually and minor updates as needed.
Warnings
- breaking In Pyroma v5.0.0, the programmatic API (`run_pyroma`) and the command-line interface (CLI) shifted to operate on a *directory path* rather than directly on a `setup.py` file. Calls explicitly passing a `setup.py` file path will no longer work.
- breaking Pyroma v5.0.0 raised the minimum required Python version to 3.9. Projects attempting to use Pyroma on older Python runtimes will encounter an `ImportError` or installation failure.
- gotcha Pyroma assesses a project's 'packaging friendliness' based on its metadata and structure, not the functional correctness or code quality of the Python application itself. A project can be fully functional but receive a low Pyroma score if its packaging configuration is non-standard or incomplete.
- gotcha When using Pyroma via the CLI, ensure you are in the project's root directory or explicitly specify the project's root. If run without arguments from a non-project directory, it will attempt to analyze the current directory and might report 'No setup.py or pyproject.toml found' errors.
Install
-
pip install pyroma
Imports
- run_pyroma
import pyroma; pyroma.run_pyroma(...)
from pyroma import ratings; ratings.run_pyroma
Quickstart
import os
import shutil
from pathlib import Path
from pyroma import ratings
# Create a dummy project directory for testing
project_root = Path("temp_pyroma_project")
project_root.mkdir(exist_ok=True)
# Create a minimal setup.py, README.md, and __init__.py
(project_root / "setup.py").write_text(
"from setuptools import setup; setup(name='dummy', version='0.1.0', description='A dummy project for pyroma test', packages=['dummy_pkg'])"
)
(project_root / "README.md").write_text("# Dummy Project\n\nThis is a temporary project for pyroma testing.")
(project_root / "dummy_pkg").mkdir(exist_ok=True)
(project_root / "dummy_pkg" / "__init__.py").touch()
# Run pyroma on the dummy project
print(f"Running pyroma on: {project_root.resolve()}")
score, messages = ratings.run_pyroma(project_root)
print(f"\nPyroma Score: {score}/10")
print("Messages:")
if messages:
for message in messages:
print(f"- {message}")
else:
print("No messages (perfect score).")
# Clean up the dummy project
if project_root.exists():
shutil.rmtree(project_root)
print(f"\nCleaned up {project_root}")