Python Packaging Files Explained | Generated by AI

Home 2025.12

Question: What are MANIFEST.in and setup.py in Python, and how do they work?

Answer:

In Python, when creating distributable packages (e.g., uploading to PyPI or sharing code), two important files are commonly used with the older setup.py-based packaging system (still widely used, though moving toward pyproject.toml):

1. setup.py

2. MANIFEST.in

Summary of How They Work Together

Step File Used Result
Define package metadata & dependencies setup.py Required for install/build
Specify non-Python files to include in source tarball MANIFEST.in Only affects sdist (source distribution)
Build a source distribution python setup.py sdist Uses both files

Use pyproject.toml + setuptools declarative config instead of setup.py and MANIFEST.in:

# pyproject.toml
[build-system]
requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "my-package"
# ... metadata ...

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
"my_package" = ["*.txt", "data/*.json"]

This avoids MANIFEST.in entirely and makes packaging cleaner.

In short:

Both are still common in legacy projects, but new projects should prefer pyproject.toml.


Back

x-ai/grok-4.1-fast

Donate