显示页面讨论过去修订反向链接回到顶部 本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。 ====== 第四十二章:项目结构 ====== ===== 本章目标 ===== 完成本章学习后,你将能够: * 组织Python项目结构 * 编写配置文件 * 管理依赖 * 发布项目到PyPI ===== 项目结构 ===== <code> 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 </code> ===== pyproject.toml ===== <code> [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"] </code> ===== 本章练习 ===== 1. 创建规范的项目结构 2. 配置CI/CD 3. 发布到PyPI 下一章:[[python_course:chapter43|第四十三章:性能优化]] 登录 Detach Close 该主题尚不存在 您访问的页面并不存在。如果允许,您可以使用创建该页面按钮来创建它。 python/chapter42.txt 最后更改: 2026/04/09 14:44由 张叶安 登录