Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workflow to work on a github fork of a python library?

Tags:

python

github

pip

I want to contribute some changes to a python package which is using github. I have forked it. It is a library I am using in a project (in a python 3.5.1 virtual environment).

The documentation at https://pip.pypa.io/en/latest/reference/pip_install/#vcs-support tell me how to install from a github fork, and it goes on to mention "editable installs" (https://pip.pypa.io/en/latest/reference/pip_install/#editable-installs) which basically does "development mode"

If it is a pure python package does it matter if I skip editable mode?

(since there would be no build steps necessary as I would only be changing python code. This would mean I can keep using the same import statements.)

like image 853
Tim Richardson Avatar asked May 10 '16 07:05

Tim Richardson


1 Answers

When you pip install without editable mode, the package is copied into your Python environment (such as env/lib/python3.5/site-packages). You can, of course, edit it right there, as it’s usually just a bunch of Python files, but that is inconvenient.

When you pip install with editable mode, pip only sets up a link from your environment to wherever the source code is. So, you can clone your GitHub fork into a convenient directory like ~/projects/libraryX, then do pip install -e ~/projects/libraryX, and keep editing the code at ~/projects/libraryX while your changes are immediately reflected in the environment where you installed it.

This all applies to pure Python packages.

like image 92
Vasiliy Faronov Avatar answered Oct 15 '22 09:10

Vasiliy Faronov