Generate __about__.py with dunder meta.
Project description
metametameta
Generate dunder metadata file with __title__, __author__, etc. Also tools to discover these in other packages.
Installation
pipx install metametameta
Usage
Defaults to putting an __about__.py file in the module directory, assuming your package name is your main module name.
Make best guess what your metadata source is. Give up if there are two possibilities.
metametameta auto
Run on CI server to see if your about file is out of sync
metametameta sync-check
metametameta poetry # or setup_cfg or pep621 or poetry or importlib or the experimental setup_py
Or set everything explicitly:
metametameta poetry --name "something" --source some.toml --output OUTPUT "mod/meta/__meta__.py"
Subcommand per source.
Usage: metametameta [-h] [--version] [--verbose] [--quiet] {setup_cfg,pep621,poetry,importlib,setup_py,auto,sync-check} ...
metametameta: Generate __about__.py from various sources.
Positional Arguments:
{setup_cfg,pep621,poetry,importlib,setup_py,auto,sync-check}
sub-command help
setup_cfg Generate from setup.cfg
pep621 Generate from PEP 621 pyproject.toml
poetry Generate from poetry pyproject.toml
importlib Generate from installed package metadata
setup_py Generate from setup.py using AST (experimental)
auto Automatically detect the source and generate the metadata file.
sync-check Check if __about__.py is in sync with the metadata source
Options:
-h, --help show this help message and exit
--version show program's version number and exit
--verbose verbose output
--quiet minimal output
Subcommand help (they all have the same switches)
usage: metametameta poetry [-h] [--name NAME] [--source SOURCE] [--output OUTPUT]
options:
-h, --help show this help message and exit
--name NAME Name of the project (from file if omitted)
--source SOURCE Path to pyproject.toml
--output OUTPUT Output file
Programmatic interface.
import metametameta as mmm
mmm.generate_from_pep621()
Motivation
There are many modern ways to get metadata about packages, as of 2024, importlib.metadata and it's backports will get you lots of metadata for yours and other packages.
The newest way is PEP-621, see also packaging.python.org
The oldest way to provide metadata was to use dunder variables in your package, e.g. __author__, __version__, etc.
The method was never strongly standardized, neither officially nor informally. Here is one early proponent of this sort of metadata.
- Metadata fields can appear in any or no python file in a project.
- Sometimes they are at the top of a single file python module, common locations for metadata:
__init__.py__meta__.py__about__.py
- Some metadata elements could reasonably be in every single file.
- There are no particular standards for the type of
__author__. It could be a string, space delimited string, list or tuple. That is true for the other metadata elements as well. - Sometimes the metadata values are code, e.g.
__version__could be a string or some tuple or data class representing a version.
Workflow
On each build, regenerate the __about__.py. Pick one source of your canonical metadata, e.g. pyproject.toml,
setup.py (experimental), setup.cfg.
Using metadata
If you have a lot of packages and you are doing analytics or something with them, you could compile all the metadata as declared in the source code. It could be different from the metadata that shows on the PyPI page. If you are searching for contact info for a package maintainer, this might be useful.
Another marginal use case is in error logging. Error loggers gather up info from just about anywhere, anything can
be a clue including metadata of dependencies. So this is one more source of that. See bug_trail for a proof of
concept for this usage.
Another marginal use case is that is a folksonomy, a taxonomy created by the people. The official metadata is
governed by the Python Packaging Authority and the Python Software Foundation. If, say, you wanted to add a metadata
item for __mailing_address__ you could easily do it with source code metadata.
Project Health & Info
| Metric | Health | Metric | Info |
|---|---|---|---|
| Tests | License | ||
| Coverage | PyPI | ||
| Lint / Pre-commit | Python Versions | ||
| Quality Gate | Docs | ||
| CI Build | Downloads | ||
| Maintainability | Last Commit |
| Category | Health |
|---|---|
| Open Issues | |
| Stars |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file metametameta-0.1.5.tar.gz.
File metadata
- Download URL: metametameta-0.1.5.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39d0a1e72d3453ab332c02fcebaa9ac84a39d7a69dc45bf953e687607babf93c
|
|
| MD5 |
91141108a1e6eb48304b832566dfef10
|
|
| BLAKE2b-256 |
de1ed945be6eb5f8dbbbd8f5a7d4f7e8e41f1045483aae73bbb4a6891d9084f2
|
Provenance
The following attestation bundles were made for metametameta-0.1.5.tar.gz:
Publisher:
publish_to_pypi.yml on matthewdeanmartin/metametameta
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metametameta-0.1.5.tar.gz -
Subject digest:
39d0a1e72d3453ab332c02fcebaa9ac84a39d7a69dc45bf953e687607babf93c - Sigstore transparency entry: 584029207
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/metametameta@23a43eb587ecb8e7222a2ec82027801ec51326a7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_to_pypi.yml@23a43eb587ecb8e7222a2ec82027801ec51326a7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file metametameta-0.1.5-py3-none-any.whl.
File metadata
- Download URL: metametameta-0.1.5-py3-none-any.whl
- Upload date:
- Size: 26.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f75f054019b4bc9ec4e33b679e9688bf1173db999c2b22b91ed5e142fac2ff56
|
|
| MD5 |
ef5699de959c318b546efde1103f4b4d
|
|
| BLAKE2b-256 |
1545e06459054a406b23f233686cc75e1d6aa946a426d10a36fc0c50892a684b
|
Provenance
The following attestation bundles were made for metametameta-0.1.5-py3-none-any.whl:
Publisher:
publish_to_pypi.yml on matthewdeanmartin/metametameta
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metametameta-0.1.5-py3-none-any.whl -
Subject digest:
f75f054019b4bc9ec4e33b679e9688bf1173db999c2b22b91ed5e142fac2ff56 - Sigstore transparency entry: 584029208
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/metametameta@23a43eb587ecb8e7222a2ec82027801ec51326a7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_to_pypi.yml@23a43eb587ecb8e7222a2ec82027801ec51326a7 -
Trigger Event:
workflow_dispatch
-
Statement type: