Standard Metadata
Standard metadata refers to the basic information required for any Python package. This includes:
- Name: The package name, which must be unique and conform to Python naming conventions.
- Version: The package version, following PEP 440 versioning scheme.
-
Filetype: Indicates whether the package is a source distribution (
sdist
) or a binary distribution (bdist
). - Python Version: The Python version(s) the package is compatible with.
- Platform: The target platform for the package, e.g., Windows, Linux, macOS. Use “any” for platform-independent packages.
Examples
Twine
When using Twine to upload your package, ensure your setup.py
or pyproject.toml
includes the necessary metadata:
setup(
name='example_package',
version='0.1.0',
description='An example package',
python_requires='>=3.6',
classifiers=[
'Programming Language :: Python :: 3',
'Operating System :: OS Independent',
],
)
Native Python
For native Python packaging without Twine, the same metadata applies. Ensure your setup.py
or pyproject.toml
file is correctly populated:
[project]
name = "example_package"
version = "0.1.0"
description = "An example package"
requires-python = ">=3.6"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
Additional Metadata
Additional metadata provides more context about the package, enhancing discoverability and usability.
- Summary: A short, one-line summary of the package.
- Description: A longer description of the package. This can be detailed and may include HTML for formatting.
- License: The license under which the package is distributed.
- Home Page: URL to the project’s home page.
- Download URL: URL from where the package can be downloaded.
- Author: The name of the package author.
- Author Email: The email address of the package author.
- Maintainer: The name of the current maintainer, if different from the author.
- Maintainer Email: The email address of the current maintainer.
Examples
Twine
When preparing your package with Twine, include additional metadata in your setup.py
or pyproject.toml
:
setup(
author='Jane Doe',
author_email='jane.doe@example.com',
license='MIT',
url='https://example.com/project',
download_url='https://example.com/project/releases',
)
Native Python
For native packaging, the pyproject.toml
can also include these additional fields:
[project]
authors = [{name = "Jane Doe", email = "jane.doe@example.com"}]
license = "MIT"
urls = {
"Homepage" = "https://example.com/project",
"Download" = "https://example.com/project/releases"
}
Conclusion
Properly defining your package’s metadata is crucial for successful synchronization and distribution. By following the guidelines above and using the examples as a template, you can ensure your package is correctly recognized and processed correctly.
Comments
Please sign in to leave a comment.