Loading...
Loading...
Configure Python package metadata, setup.py, and pyproject.toml for distribution using UV or setuptools. Use when setting up Python packages, configuring build systems, or preparing projects for PyPI publication.
npx skill4agent add armanzeroeight/fastagent-plugins python-packagingpyproject.toml[project]
name = "my-package"
version = "0.1.0"
description = "Package description"
readme = "README.md"
requires-python = ">=3.9"
license = {text = "MIT"}
authors = [
{name = "Your Name", email = "you@example.com"}
]
keywords = ["keyword1", "keyword2"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"requests>=2.28.0",
]
[project.optional-dependencies]
dev = [
"pytest>=7.0.0",
"black>=23.0.0",
"mypy>=1.0.0",
]
[project.scripts]
my-cli = "my_package.cli:main"
[project.urls]
Homepage = "https://github.com/username/my-package"
Repository = "https://github.com/username/my-package"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"nameversionrequires-pythondependenciesoptional-dependenciesscripts>=2.28.0,<3.0.0~=2.28.0>=2.28.0==2.28.0pyproject.toml[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "my-package"
version = "0.1.0"
description = "Package description"
readme = "README.md"
requires-python = ">=3.9"
license = {text = "MIT"}
authors = [
{name = "Your Name", email = "you@example.com"}
]
keywords = ["keyword1", "keyword2"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
]
dependencies = [
"requests>=2.28.0",
]
[project.optional-dependencies]
dev = [
"pytest>=7.0.0",
"black>=23.0.0",
"mypy>=1.0.0",
]
[project.scripts]
my-cli = "my_package.cli:main"
[project.urls]
Homepage = "https://github.com/username/my-package"
Repository = "https://github.com/username/my-package"setup.pyfrom setuptools import setup, find_packages
setup(
name="my-package",
version="0.1.0",
description="Package description",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="Your Name",
author_email="you@example.com",
url="https://github.com/username/my-package",
packages=find_packages(where="src"),
package_dir={"": "src"},
python_requires=">=3.9",
install_requires=[
"requests>=2.28.0",
],
extras_require={
"dev": [
"pytest>=7.0.0",
"black>=23.0.0",
"mypy>=1.0.0",
],
},
entry_points={
"console_scripts": [
"my-cli=my_package.cli:main",
],
},
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
],
)my-package/
├── my_package/
│ ├── __init__.py
│ └── module.py
├── tests/
├── pyproject.toml
└── README.mdmy-package/
├── src/
│ └── my_package/
│ ├── __init__.py
│ └── module.py
├── tests/
├── pyproject.toml
└── README.md[tool.hatch.build.targets.wheel]
packages = ["src/my_package"][tool.setuptools.packages.find]
where = ["src"]packages=find_packages(where="src"),
package_dir={"": "src"},[project]
version = "0.1.0"[project]
dynamic = ["version"]
[tool.setuptools.dynamic]
version = {attr = "my_package.__version__"}src/my_package/__init__.py__version__ = "0.1.0"from setuptools import setup
from setuptools_scm import get_version
setup(
use_scm_version=True,
setup_requires=["setuptools_scm"],
)[project.scripts]
my-cli = "my_package.cli:main"
another-tool = "my_package.tools:run"# my_package/cli.py
def main():
print("Hello from my-cli!")
if __name__ == "__main__":
main()[tool.setuptools.package-data]
my_package = ["data/*.json", "templates/*.html"]MANIFEST.ininclude README.md
include LICENSE
recursive-include src/my_package/data *classifiers = [
# Development status
"Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
# Audience
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
# License
"License :: OSI Approved :: MIT License",
# Python versions
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
# Topics
"Topic :: Software Development :: Libraries",
"Topic :: Internet :: WWW/HTTP",
]# Build distribution
uv build
# Publish to PyPI
uv publish
# Or use twine
uv build
twine upload dist/*# Install build tools
pip install build twine
# Build distribution
python -m build
# Publish to PyPI
twine upload dist/*# Install in editable mode with UV
uv pip install -e .
# Or with pip
pip install -e .
# Test the package
python -c "import my_package; print(my_package.__version__)"
# Test console scripts
my-cli --help[tool.hatch.build.targets.wheel]
packages = ["src/package1", "src/package2"][project.optional-dependencies]
dev = ["pytest", "black", "mypy"]
docs = ["sphinx", "sphinx-rtd-theme"]
aws = ["boto3"]
all = ["pytest", "black", "mypy", "sphinx", "boto3"]pip install my-package[dev]pip install my-package[all][project]
dependencies = [
"requests",
"pywin32; platform_system=='Windows'",
"python-daemon; platform_system=='Linux'",
]uv build # or python -m buildtwine check dist/*uv pip install dist/*.whlmy-cli --versionimport my_package
print(my_package.__version__)__init__.py"script-name = "package.module:function"package-datapython -m tarfile -l dist/*.tar.gz>=,<