Check Manifest

0.51 · active · verified Sat Apr 11

check-manifest is a command-line tool designed to verify the completeness of the `MANIFEST.in` file in Python source packages, helping developers avoid accidentally omitting files from source distributions. It does this by comparing files under version control with those included in a generated source distribution. The current version is 0.51, and the project maintains an active release cadence, often aligning updates with new Python version support and essential bug fixes.

Warnings

Install

Quickstart

check-manifest is primarily used as a command-line tool. This quickstart demonstrates how to run it within a Python script to verify a project's `MANIFEST.in` (or generate one if missing). It sets up a temporary project with `git` to simulate a real-world scenario, then runs `check-manifest` to identify missing files and subsequently uses the `-u` flag to automatically update the `MANIFEST.in`.

import subprocess
import os
import shutil

# Create a dummy project structure for demonstration
project_dir = "my_package_to_check"
os.makedirs(f"{project_dir}/my_package", exist_ok=True)
with open(f"{project_dir}/setup.py", "w") as f:
    f.write("from setuptools import setup\nsetup(name='my_package', version='0.1.0')\n")
with open(f"{project_dir}/my_package/__init__.py", "w") as f:
    f.write("import os\n
__version__ = '0.1.0'\n")
with open(f"{project_dir}/README.md", "w") as f:
    f.write("# My Package")

print(f"Created dummy project in {project_dir}/")

# Simulate initial git init and add/commit for check-manifest to work
# check-manifest needs a VCS to compare against.
subprocess.run(["git", "init", "-b", "main"], cwd=project_dir, capture_output=True, text=True)
subprocess.run(["git", "add", "."], cwd=project_dir, capture_output=True, text=True)
subprocess.run(["git", "commit", "-m", "Initial commit"], cwd=project_dir, capture_output=True, text=True)

print("\n--- Running check-manifest (expecting no MANIFEST.in, so it will suggest one) ---")
# Run check-manifest without updating initially
result = subprocess.run(
    ["check-manifest"],
    cwd=project_dir,
    capture_output=True,
    text=True,
    check=False
)
print(result.stdout)
print(result.stderr)
if result.returncode != 0:
    print("check-manifest detected issues (as expected without MANIFEST.in).")

print("\n--- Running check-manifest with -u to update MANIFEST.in ---")
result_update = subprocess.run(
    ["check-manifest", "-u"],
    cwd=project_dir,
    capture_output=True,
    text=True,
    check=False
)
print(result_update.stdout)
print(result_update.stderr)
if result_update.returncode == 0:
    print("check-manifest -u successfully created/updated MANIFEST.in.")
    with open(f"{project_dir}/MANIFEST.in", "r") as f:
        print("\n--- Generated MANIFEST.in content ---")
        print(f.read())
else:
    print("check-manifest -u failed.")

# Cleanup
shutil.rmtree(project_dir)
print(f"\nCleaned up dummy project directory: {project_dir}")

view raw JSON →