I am looking to contribute to some Python projects on Github, and I am looking for a bit of clarification on the mechanics of doing this effectively. As I understand it, the typical workflow is as follows:
- Fork the repository you would like to contribute to.
- Clone the your forked repository.
- Create a Python virtual environment and install / locally import your repo. My understanding is that this portion is needed to ensure the module you are looking to contribute to is the one from Github, and not the one already installed on your machine.
- Develop, test, etc. your intended changes.
- Commit back to Github.
- Submit pull requests to have your changes incorporated into the parent project.
While I'm looking for confirmation overall, I'm looking for confirmation regarding Step 3 primarily as my understanding at this point remains a bit grey.
1 Answer 1
The first thing you want to do is check how projects accept submissions and in what format (e.g. where to branch from, do you need to rebase, style guide etc.). Make that step 0.
For step 3, it depends on your workflow. Mine is to clone the repo to a folder I have specially for such projects, create a virtualenv (usually using virtualenvwrapper, as it makes creating new virtualenvs easy, especially useful for testing that installing still works), install any build/dev requirements not listed in the setup.py (the readme/documentation should say what these are), then install the project in editable mode (running pip install -e .
). See https://virtualenv.pypa.io/en/latest/virtualenv.html#usage for how to get started using virtualenv.
Note that this may not work for every package (typically if it cannot be installed using pip, then this will not work), in this case you could use user site-packages
(i.e. pip install --user
instead of pip install
).
In the case of sklearn
, you need to install numpy
and scipy
into the virtualenv before installing sklearn
. Make sure to do the numpy
install separately to scipy, pip install numpy scipy
won't work.
Finally, step 3 will vary for every developer, it's best to develop your own workflow. The main thing is to make sure that any changes are acceptable to the project.
PATH
(or equivalent thing).... And it is probably operating system specific. So improve your question by editing it. BTW you probably don't want to change system-wide your settings