Skip to main content

Summary: define the metadata of your project in a single place, then make it available at setup-time and at runtime.

Let’s consider the about package as an example ; we add to our project files, in the source tree, a file named about.py that contains the metadata of the project:

about
|--- setup.py
|--- README.md
|...
|--- about
|    |--- __init__.py
|    |...
|    |--- about.py

This file contains the metadata (and a little boilerplate):

# coding: utf-8

metadata = dict(
  __name__        = "about",
  __version__     = "5.1.1",
  __license__     = "MIT License",
  __author__      = u"Sébastien Boisgérault <Sebastien.Boisgerault@gmail.com>",
  __url__         = "https://warehouse.python.org/project/about",
  __summary__     = "Software Metadata for Humans",
  __keywords__    = "Python / 2.7, OS independent, software development"
)

globals().update(metadata)

__all__ = metadata.keys()

Setup. To use this metadata, the setup.py file includes the code:

import about
import about.about

info = about.get_metadata(about.about)

# add extra information (contents, requirements, etc.).
info.update(...)

if __name__ == "__main__":
    setuptools.setup(**info)

Runtime. The metadata is stored as a collection of attributes of the about.about module. If we include in the about/__init__.py file the one-liner

from .about import *

they become available in the top-level module:

>>> import about
>>> print about.__name__
about
>>> print about.__version__
5.1.1
>>> print about.__license__
MIT License

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

about-5.2.tar.gz (9.7 kB view details)

Uploaded Source

File details

Details for the file about-5.2.tar.gz.

File metadata

  • Download URL: about-5.2.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for about-5.2.tar.gz
Algorithm Hash digest
SHA256 4a318ad1dcf6e9355b8ae18195c707d26413782b57ac5c740cc696b44350c959
MD5 40383c559df273d42565ad4add762353
BLAKE2b-256 09ec81a547694206ae277feac573fda6e4726bb4440c07dbc81a01625fe4f0b1

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

5.2 This release

1 file

5.1.1

1 file

5.1

1 file

5.0.1

1 file

5.0.0

1 file

4.0.0

1 file

2.2.1

1 file

2.2.0

1 file

2.1.0

1 file

2.0.0

1 file

0.3.0

1 file

0.2.1

1 file

0.2.0

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page