setupmeta is a Python library designed to significantly reduce boilerplate in `setup.py` files by automatically inferring project metadata from common project conventions. It extracts information like long description from `README.rst`/`README.md`, version from `__version__.py` or Git tags, and dependencies from `requirements.txt`. It encourages a DRY (Don't Repeat Yourself) approach to Python packaging. The current version is 3.9.0, and it is actively maintained with a regular release cadence.
pip install setupmetaVerified import paths — ran on the pinned version, not inferred.
setupmeta significantly shortens your `setup.py`. By placing `setup_requires="setupmeta"` in your `setuptools.setup()` call, setupmeta will automatically deduce common project metadata from existing files (like `README.rst`, `__init__.py`, `requirements.txt`). The `python setup.py explain` command is invaluable for seeing exactly what metadata setupmeta has detected from your project's structure and files.
Ensure `git` is installed and meets the minimum version requirement in your build environment. If not using Git, specify the `version` explicitly in `setup()` or a dedicated `__version__.py` file.
Review your `setup.py` and remove any redundant metadata fields that you intend for setupmeta to deduce. Use `python setup.py explain` to inspect the final deduced metadata.
For new projects or existing projects adopting modern packaging, ensure you have a `pyproject.toml` file that lists `setuptools` and `setupmeta` as build-time dependencies, e.g.: `[build-system]\nrequires = ["setuptools>=61.2", "wheel", "setupmeta"]\nbuild-backend = "setuptools.build_meta"`. This ensures setupmeta is available during the build process.
Ensure a version is defined in one of the locations setupmeta checks, such as by adding `__version__ = "1.0.0"` to your main `__init__.py` file, creating a `VERSION.txt` file at the root, or tagging a Git commit.
Restructure your project to a standard layout (e.g., `src/mypackage/` or `mypackage/`) or explicitly define the `packages` or `py_modules` argument in your `setup.cfg` or `setup.py` to guide setupmeta.
Install `setupmeta` using `pip install setupmeta`. If it's for a build process, ensure `setupmeta` is listed in the `setup_requires` argument within your `setup.py` file to make it available during the build phase.