Contributing to PDM#
First off, thanks for taking the time to contribute! Contributions include but are not restricted to:
- Reporting bugs
- Contributing to code
- Writing tests
- Writing documentation
The following is a set of guidelines for contributing.
A recommended flow of contributing to an Open Source project#
This section is for beginners to OSS. If you are an experienced OSS developer, you can skip this section.
- First, fork this project to your own namespace using the fork button at the top right of the repository page.
- Clone the upstream repository to local:
1 2 3
git clone https://github.com/pdm-project/pdm.git # Or if you prefer SSH clone: git clone [email protected]:pdm-project/pdm.git
- Add the fork as a new remote:
where
1 2
git remote add fork https://github.com/yourname/pdm.git git fetch fork
fork
is the remote name of the fork repository.
ProTips:
- Don't modify code on the main branch, the main branch should always keep track of origin/main.
To update main branch to date:
1 2 3 |
|
- Create a new branch based on the up-to-date main branch for new patches.
- Create a Pull Request from that patch branch.
Local development#
We recommend working in a virtual environment.
Feel free to create a virtual environment with either the venv
module or the virtualenv
tool.
For example:
1 2 3 |
|
Make sure your pip
is newer than 21.3
to install PDM in develop/editable mode.
1 2 |
|
Make sure PDM uses the virtual environment you just created:
1 2 |
|
Install PDM development dependencies:
1 |
|
Now, all dependencies are installed into the Python environment you chose, which will be used for development after this point.
Run tests#
1 |
|
The test suite is still simple and needs expansion! Please help write more test cases.
Note
You can also run your test suite against all supported Python version using tox
with the tox-pdm
plugin.
You can either run it by yourself with:
1 |
|
or from pdm
with:
1 |
|
Code style#
PDM uses pre-commit
for linting. Install pre-commit
first, for example with pip or pipx:
1 |
|
1 |
|
Then initialize pre-commit
:
1 |
|
You can now lint the code with:
1 |
|
PDM uses black
for code style and isort
for sorting import statements. If you are not following them,
the CI will fail and your Pull Request will not be merged.
News fragments#
When you make changes such as fixing a bug or adding a feature, you must add a news fragment describing
your change. News fragments are placed in the news/
directory, and should be named according to this pattern: <issue_num>.<issue_type>.md
(e.g., 566.bugfix.md
).
Issue Types#
feature
: Features and improvementsbugfix
: Bug fixesrefactor
: Code restructuresdoc
: Added or improved documentationdep
: Changes to dependenciesremoval
: Removals or deprecations in the APImisc
: Miscellaneous changes that don't fit any of the other categories
The contents of the file should be a single sentence in the imperative
mood that describes your changes. (e.g., Deduplicate the plugins list.
) See entries in the Change Log for more examples.
Preview the documentation#
PDM docs development requires a few additional dependencies. Install them as:
1 |
|
Now, whenever you make some changes to the docs/
and you want to preview the build result, simply do:
1 |
|
Release#
Once all changes are done and ready to release, you can preview the changelog contents by running:
1 |
|
Make sure the next version and the changelog are as expected in the output.
Then cut a release on the main branch:
1 |
|
GitHub action will create the release and upload the distributions to PyPI.
Read more options about version bumping by pdm run release --help
.