By writing this metadata out in pyproject.toml
[project]
name = "example-pyproject"
version = "0.1.0"
description = "Example packaging project"
readme = "README.md"
license = "BSD-3-Clause"
license-files = ["LICENSE.txt"]
# Who built this project? How can they be contacted?
authors = [
{name = "Megan Scott", email = "megan.scott@alaska.edu"},
]
# Who is maintaining it now? And how do we contact them?
maintainers = [
{name = "Jim Ross", email = "jim.ross@alaska.edu"},
]
[project]
name = "example-pyproject"
version = "0.1.0"
description = "Example packaging project"
readme = "README.md"
license = "BSD-3-Clause"
license-files = ["LICENSE.txt"]
authors = [
{name = "Megan Scott", email = "megan.scott@alaska.edu"},
]
maintainers = [
{name = "Jim Ross", email = "jim.ross@alaska.edu"},
]
# What Python versions are supported
requires-python = ">=3.10"
# What is needed for the project to run
dependencies = [
"numpy >= 1.25",
]
[project]
name = "example-pyproject"
version = "0.1.0"
description = "Example packaging project"
readme = "README.md"
license = "..."
authors = [
{name = "Megan Scott", email = "megan.scott@alaska.edu"},
]
maintainers = [
{name = "Jim Ross", email = "jim.ross@alaska.edu"},
]
requires-python = ">=3.10"
dependencies = [
"numpy >= 1.25",
]
keywords = ["packaging"]
classifiers = [
"Development Status :: 3 - Alpha",
]
[project]
name = "example-pyproject"
version = "0.1.0"
# ...
urls = {
# What is the landing page
Homepage = "https://example-pyproject.acme.com",
# Where is the source
Source = "https://github.com/acme/example-pyproject",
# Where to report bugs or request features
Issues = "https://github.com/acme/example-pyproject/issues/new"
}
Alternatively
[project.urls]
Homepage = "https://example-pyproject.acme.com"
Source = "https://github.com/acme/example-pyproject"
Issues = "https://github.com/acme/example-pyproject/issues/new"
example-pyproject/ # <--- Git repo directory
example-pyproject/
├── LICENSE.txt # <--- License file we picked
└── README.md # <--- Initial docs new people see
example-pyproject/
├── LICENSE.txt
├── README.md
└── example_pyproject # <--- Place source code here
example-pyproject/
├── LICENSE.txt
├── README.md
└── example_pyproject
└── __init__.py # <--- Make this a Python package
example-pyproject/
├── LICENSE.txt
├── README.md
└── example_pyproject
example-pyproject/
├── LICENSE.txt
├── README.md
├── example_pyproject
└── pyproject.toml # <--- Include our package metadata
example-pyproject/
├── CONTRIBUTING.md # <--- Add maintainer docs
├── LICENSE.txt
├── README.md
├── docs # <--- Add user docs
├── example_pyproject
└── pyproject.toml
example-pyproject/
├── CONTRIBUTING.md
├── LICENSE.txt
├── README.md
├── docs
├── example_pyproject
├── pyproject.toml
└── tests/ # <--- Include unit tests
example-pyproject/
├── .github/workflows # <--- GitHub CI
├── CONTRIBUTING.md
├── LICENSE.txt
├── README.md
├── docs
├── example_pyproject
├── pyproject.toml
├── readthedocs.yml # <--- ReadTheDocs build
└── tests/
example-pyproject/
├── .github/pull_request_template.md # <--- Checklist for PRs
├── .github/issue_template.md # <--- Checklist for issues
├── .github/workflows
├── CONTRIBUTING.md
├── LICENSE.txt
├── README.md
├── docs/
├── example_pyproject
├── pyproject.toml
├── readthedocs.yml
└── tests/
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools",
]
[build-system]
build-backend = "hatchling.build"
requires = [
"hatchling",
]
https://packaging.python.org/en/latest/glossary/#term-Build-Backend
pyproject.toml
¶[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=74.1.0",
"cython>=3",
]
...
[tool.setuptools]
ext-modules = [
{name = "example-pyproject.mylib", sources = ["example_pyproject/mylib.pyx"]},
]
example-pyproject/
├── LICENSE.txt
├── README.md
└── example_pyproject
├── __init__.py
└── mylib.pyx # <--- Cython module
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools",
"setuptools-scm>=8.1",
]
[project]
...
dynamic = ["version"]
[tool.setuptools_scm]
version_scheme = "guess-next-dev"
local_scheme = "dirty-tag"
write_to = "example_pyproject/_version.py"