python:chapter42

第四十二章:项目结构

完成本章学习后,你将能够:

  • 组织Python项目结构
  • 编写配置文件
  • 管理依赖
  • 发布项目到PyPI
my_project/
├── src/
│   └── my_package/
│       ├── __init__.py
│       ├── module1.py
│       └── module2.py
├── tests/
│   ├── __init__.py
│   └── test_module1.py
├── docs/
├── .gitignore
├── LICENSE
├── README.md
├── pyproject.toml
└── requirements.txt
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "my_project"
version = "1.0.0"
description = "A sample project"
readme = "README.md"
requires-python = ">=3.8"
license = {text = "MIT"}
authors = [
    {name = "Author", email = "author@example.com"}
]
classifiers = [
    "Development Status :: 4 - Beta",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: MIT License",
    "Programming Language :: Python :: 3",
]
dependencies = [
    "requests>=2.0",
    "numpy>=1.20",
]

[project.optional-dependencies]
dev = ["pytest", "black", "flake8", "mypy"]

1. 创建规范的项目结构 2. 配置CI/CD 3. 发布到PyPI

下一章:第四十三章:性能优化

该主题尚不存在

您访问的页面并不存在。如果允许,您可以使用创建该页面按钮来创建它。

  • python/chapter42.txt
  • 最后更改: 2026/04/09 14:44
  • 张叶安