Registry / devops / setupmeta

setupmeta

JSON →
library3.9.0pypypi✓ verified 22d ago

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 setupmeta
INSTALL
IMPORT
SIG · SETUPMETA
S
setupmeta
devopspythonv3.9.0
Install
2.0s avg
Import
694ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.768s · 19MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.0s · import 0.620s · 19MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

setup
from setuptools import setup
setupmeta is used by specifying it in `setup_requires` within the `setup()` call; it does not typically expose symbols for direct import into user code.

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.

import os import subprocess # Create a dummy project structure for demonstration project_name = "myproject_example" os.makedirs(project_name, exist_ok=True) with open(os.path.join(project_name, "__init__.py"), "w") as f: f.write("__version__ = '0.0.1'\n") f.write("__title__ = 'My Example Project'\n") with open(os.path.join(project_name, "../README.rst"), "w") as f: f.write("My Example Project\n") f.write("===================\n\n") f.write("A simple project to demonstrate setupmeta.") with open(os.path.join(project_name, "../requirements.txt"), "w") as f: f.write("click\n") f.write("requests>=2.0.0\n") # Create a minimal setup.py setup_py_content = """ from setuptools import setup setup( name="%s", versioning="distance", # Optional: activates tag-based versioning based on git setup_requires=["setupmeta"] # This tells setuptools to use setupmeta ) """ % project_name with open(os.path.join(project_name, "../setup.py"), "w") as f: f.write(setup_py_content) print(f"Project '{project_name}' and setup.py created. Now run: ") print(f"cd {os.path.dirname(os.path.abspath(__file__))}") print(f"python setup.py explain # To see what setupmeta deduces") print(f"python setup.py sdist bdist_wheel # To build distributions") # Example of running the command programmatically (requires project setup from above) # try: # # This command needs to be run from the directory containing setup.py # # For this example, assume it's run in the parent directory of 'myproject_example' # original_dir = os.getcwd() # os.chdir(os.path.dirname(os.path.abspath(__file__))) # subprocess.run(["python", "setup.py", "explain"], check=True) # finally: # os.chdir(original_dir)
Debug
Known issues
gotchaUsing tag-based versioning (e.g., `versioning='distance'` or `versioning='post'`) requires Git to be installed and accessible, with a version of 1.8.4 or higher. If Git is not available or too old, version detection will fail, which can be a common issue in CI/CD environments or minimal Docker images.
fix
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.
affects: All versions supporting `versioning` parameter.
gotchaAny parameters explicitly passed to `setuptools.setup()` will *always* take precedence over metadata deduced by setupmeta. This is by design, allowing granular control, but can lead to confusion if expected behavior is overridden by inadvertently explicit (or outdated) values in `setup.py`.
fix
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.
affects: All versions.
deprecatedsetupmeta's primary integration point is via `setup_requires` in `setup.py`. While functional, the `setup_requires` mechanism is considered legacy in modern Python packaging (PEP 517/518), which prefers specifying build dependencies in `pyproject.toml` under `build-system.requires`. Not configuring `pyproject.toml` correctly may lead to issues with modern build tools or future `setuptools` versions.
fix
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.
affects: All versions of setupmeta. Affects projects using `setuptools` >= 61.2.0, where stricter validation for `pyproject.toml` might occur.
Errors
Common errors & fixes
ValueError: Cannot guess version from files (looked in setup.cfg, pyproject.toml, .git/HEAD, __init__.py, version.py, __version__.py, VERSION.txt, .git_archival.txt)
setupmeta couldn't find the project's version number using any of its standard inference mechanisms, such as Git tags, a `__version__.py` file, or a `VERSION.txt` file.
fix
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.
NoPackageFoundException: Cannot find any package in source tree (looking for __init__.py files in sub-directories)
setupmeta failed to automatically detect Python packages because it couldn't find any directories containing an `__init__.py` file in the default project structure.
fix
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.
ModuleNotFoundError: No module named 'setupmeta'
The `setupmeta` package is not installed in the Python environment where `setup.py` is being executed, or it's not correctly specified in `setup_requires` for build systems.
fix
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.
Upgrade
Version history
3.9.0latest on PyPI · released Feb 17, 2026
Audit
Dependencies
setuptoolsrequiredsetupmeta extends setuptools' functionality and integrates directly with setuptools.setup().
gitoptionalRequired for tag-based versioning features (e.g., `versioning="distance"` or `"post"`). Git version 1.8.4 or higher is necessary.
Agent activity
3 hits · last 30 days
node
2
Resources
setupmeta — pip install setupmeta · libregistry