Python 开发者指南¶
本指南是一个全面的资源,有助于对 Python 贡献 – 为新的和有经验的贡献者。它是由维护 Python 的同一个社区来 维护 。我们欢迎你对 Python 的贡献!
快速参考¶
以下是获得 安装 和贡献一个补丁所需的基本步骤。这是一个检查清单,一旦你知道了基本知识。完整的说明请见 安装指南。
将 CPython仓库 分叉到你的 GitHub 账户,并 获取源代码 使用:
git clone https://github.com/<your_username>/cpython cd cpython
构建 Python,在 UNIX 和 Mac OS 上使用
./configure --with-pydebug && make -j
而在 Windows 上则使用
PCbuild\build.bat -e -d
也请参见 更详细的说明、如何安装和构建依赖关系 以及 UNIX、Mac OS 和 Windows 的特定平台页面。
-
./python -m test -j3
在 most Mac OS X 系统上,用
./python
替换./python.exe
。在 Windows 上,使用python.bat
。 创建一个新的分支,将你为这个 issue 所做的工作放在那里,例如
git checkout -b fix-issue-12345 main
如果一个 issue 还不存在,请 创建它。琐碎的issue (例如,错别字修正)不需要创建任何 issue。
一旦你修复了问题,运行测试,运行
make patchcheck
,如果一切正常,提交。Push the branch on your fork on GitHub and create a pull request. Include the issue number using
bpo-NNNN
in the pull request description. For example:bpo-12345: Fix some bug in spam module
Add a News entry into the
Misc/NEWS.d
directory as individual file. The news entry can be created by using blurb-it, or the blurb tool and itsblurb add
command. Please read more aboutblurb
in documentation.
备注
First time contributors will need to sign the Contributor Licensing Agreement (CLA) as described in the Licensing section of this guide.
Quick Links¶
Here are some links that you probably will reference frequently while contributing to Python:
PEPs (Python Enhancement Proposals)
Status of Python branches¶
Branch |
Schedule |
Status |
First release |
End-of-life |
Release manager |
---|---|---|---|---|---|
main |
features |
2022-10-03 |
2027-10 |
Pablo Galindo Salgado |
|
3.10 |
bugfix |
2021-10-04 |
2026-10 |
Pablo Galindo Salgado |
|
3.9 |
bugfix |
2020-10-05 |
2025-10 |
Łukasz Langa |
|
3.8 |
security |
2019-10-14 |
2024-10 |
Łukasz Langa |
|
3.7 |
security |
2018-06-27 |
2023-06-27 |
Ned Deily |
Dates in italic are scheduled and can be adjusted.
The main branch is currently the future Python 3.11, and is the only branch that accepts new features. The latest release for each Python version can be found on the download page.
Status:
- features
new features, bugfixes, and security fixes are accepted.
- prerelease
feature fixes, bugfixes, and security fixes are accepted for the upcoming feature release.
- bugfix
bugfixes and security fixes are accepted, new binaries are still released. (Also called maintenance mode or stable release)
- security
only security fixes are accepted and no more binaries are released, but new source-only versions can be released
- end-of-life
release cycle is frozen; no further changes can be pushed to it.
See also the Development Cycle page for more information about branches.
By default, the end-of-life is scheduled 5 years after the first release, but can be adjusted by the release manager of each branch. All Python 2 versions have reached end-of-life.
Contributing¶
We encourage everyone to contribute to Python and that’s why we have put up this developer’s guide. If you still have questions after reviewing the material in this guide, then the Core Python Mentorship group is available to help guide new contributors through the process.
A number of individuals from the Python community have contributed to a series of excellent guides at Open Source Guides.
Core developers and contributors alike will find the following guides useful:
Guide for contributing to Python:
New Contributors |
Documentarians |
Triagers |
Core Developers |
---|---|---|---|
Advanced tasks and topics for once you are comfortable:
Fixing issues found by the buildbots
Helping out with reviewing open pull requests. See how to review a Pull Request.
It is recommended that the above documents be read as needed. New contributors will build understanding of the CPython workflow by reading the sections mentioned in this table. You can stop where you feel comfortable and begin contributing immediately without reading and understanding these documents all at once. If you do choose to skip around within the documentation, be aware that it is written assuming preceding documentation has been read so you may find it necessary to backtrack to fill in missing concepts and terminology.
Proposing changes to Python itself¶
Improving Python’s code, documentation and tests are ongoing tasks that are never going to be “finished”, as Python operates as part of an ever-evolving system of technology. An even more challenging ongoing task than these necessary maintenance activities is finding ways to make Python, in the form of the standard library and the language definition, an even better tool in a developer’s toolkit.
While these kinds of change are much rarer than those described above, they do happen and that process is also described as part of this guide:
Other Interpreter Implementations¶
This guide is specifically for contributing to the Python reference interpreter, also known as CPython (while most of the standard library is written in Python, the interpreter core is written in C and integrates most easily with the C and C++ ecosystems).
There are other Python implementations, each with a different focus. Like CPython, they always have more things they would like to do than they have developers to work on them. Some major examples that may be of interest are:
PyPy: A Python interpreter focused on high speed (JIT-compiled) operation on major platforms
Jython: A Python interpreter focused on good integration with the Java Virtual Machine (JVM) environment
IronPython: A Python interpreter focused on good integration with the Common Language Runtime (CLR) provided by .NET and Mono
Stackless: A Python interpreter focused on providing lightweight microthreads while remaining largely compatible with CPython specific extension modules
Key Resources¶
- Issue tracker
Meta tracker (issue tracker for the issue tracker)
PEPs (Python Enhancement Proposals)
Additional Resources¶
Anyone can clone the sources for this guide. See Helping with the Developer’s Guide.
- Tool support
Various tools with configuration files as found in the Misc directory
Information about editors and their configurations can be found in the wiki
Code of Conduct¶
Please note that all interactions on Python Software Foundation-supported infrastructure is covered by the PSF Code of Conduct, which includes all infrastructure used in the development of Python itself (e.g. mailing lists, issue trackers, GitHub, etc.). In general this means everyone is expected to be open, considerate, and respectful of others no matter what their position is within the project.
Full Table of Contents¶
- Getting Started
- Where to Get Help
- Lifecycle of a Pull Request
- Running & Writing Tests
- Increase Test Coverage
- Helping with Documentation
- Documenting Python
- Silence Warnings From the Test Suite
- Fixing “easy” Issues (and Beyond)
- Issue Tracking
- Triaging an Issue
- Following Python’s Development
- Porting Python to a new platform
- How to Become a Core Developer
- Developer Log
- Accepting Pull Requests
- Development Cycle
- Continuous Integration
- Adding to the Stdlib
- Changing the Python Language
- Experts Index
- gdb Support
- Exploring CPython’s Internals
- Changing CPython’s Grammar
- Guide to CPython’s Parser
- Design of CPython’s Compiler
- Design of CPython’s Garbage Collector
- Updating standard library extension modules
- Changing Python’s C API
- Coverity Scan
- Dynamic Analysis with Clang
- Running a buildbot worker
- Core Developer Motivations and Affiliations
- Git Bootcamp and Cheat Sheet
- Forking CPython GitHub Repository
- Cloning a Forked CPython Repository
- Listing the Remote Repositories
- Setting Up Your Name and Email Address
- Enabling
autocrlf
on Windows - Creating and Switching Branches
- Deleting Branches
- Renaming Branch
- Staging and Committing Files
- Reverting Changes
- Stashing Changes
- Committing Changes
- Comparing Changes
- Pushing Changes
- Creating a Pull Request
- Updating your CPython Fork
- Applying a Patch to Git
- Downloading Other’s Patches
- Accepting and Merging a Pull Request
- Backporting Merged Changes
- Editing a Pull Request Prior to Merging
- Appendix: Topics