Getting Started

We’re pleased that you are interested in working on pip.

This document is meant to get you setup to work on pip and to act as a guide and reference to the development setup. If you face any issues during this process, please open an issue about it on the issue tracker.

Get the source code

To work on pip, you first need to get the source code of pip. The source code is available on GitHub.

  1. $ git clone https://github.com/pypa/pip
  2. $ cd pip

Development Environment

pip is a command line application written in Python. For developing pip, you should install Python on your computer.

For developing pip, you need to install tox. Often, you can run python -m pip install tox to install and use it.

Running pip From Source Tree

To run the pip executable from your source tree during development, install pip locally using editable installation (inside a virtualenv). You can then invoke your local source tree pip normally.

Unix/macOS

  1. virtualenv venv # You can also use "python -m venv venv" from python3.3+
  2. source venv/bin/activate
  3. python -m pip install -e .
  4. python -m pip --version

Windows

  1. virtualenv venv # You can also use "py -m venv venv" from python3.3+
  2. venv\Scripts\activate
  3. py -m pip install -e .
  4. py -m pip --version

Running Tests

pip’s tests are written using the pytest test framework, mock and pretend. tox is used to automate the setup and execution of pip’s tests.

It is preferable to run the tests in parallel for better experience during development, since the tests can take a long time to finish when run sequentially.

To run tests:

  1. $ tox -e py36 -- -n auto

To run tests without parallelization, run:

  1. $ tox -e py36

The example above runs tests against Python 3.6. You can also use other versions like py27 and pypy3.

tox has been configured to forward any additional arguments it is given to pytest. This enables the use of pytest’s rich CLI. As an example, you can select tests using the various ways that pytest provides:

  1. $ # Using file name
  2. $ tox -e py36 -- tests/functional/test_install.py
  3. $ # Using markers
  4. $ tox -e py36 -- -m unit
  5. $ # Using keywords
  6. $ tox -e py36 -- -k "install and not wheel"

Running pip’s test suite requires supported version control tools (subversion, bazaar, git, and mercurial) to be installed. If you are missing one of the VCS tools, you can tell pip to skip those tests:

  1. $ tox -e py36 -- -k "not svn"
  2. $ tox -e py36 -- -k "not (svn or git)"

Running Linters

pip uses pre-commit for managing linting of the codebase. pre-commit performs various checks on all files in pip and uses tools that help follow a consistent code style within the codebase.

To use linters locally, run:

  1. $ tox -e lint

Note

Avoid using # noqa comments to suppress linter warnings - wherever possible, warnings should be fixed instead. # noqa comments are reserved for rare cases where the recommended style causes severe readability problems.

Building Documentation

pip’s documentation is built using Sphinx. The documentation is written in reStructuredText.

To build it locally, run:

  1. $ tox -e docs

The built documentation can be found in the docs/build folder.

For each Pull Request made the documentation is deployed following this link:

  1. https://pip--<PR-NUMBER>.org.readthedocs.build/en/<PR-NUMBER>

What Next?

The following pages may be helpful for new contributors on where to look next in order to start contributing.

Important

Did this article help?

We are currently doing research to improve pip’s documentation and would love your feedback. Please email us &body=%0A%20%20%20%200.%20Document:%20development/getting-started.%20Page%20URL:%20https:/%20%0A%0A%20%20%20%201.%20What%20problem%20were%20you%20trying%20to%20solve%20when%20you%20came%20to%20this%20page?%20%0A%0A%20%20%20%202.%20What%20content%20was%20useful?%20%0A%0A%20%20%20%203.%20What%20content%20was%20not%20useful?) and let us know:

  1. What problem were you trying to solve when you came to this page?

  2. What content was useful?

  3. What content was not useful?