Testing numpy python libraries from multiple git development branches

I’m trying to develop a few enhancements for the numpy library. To this end I have forked the repo on github and created a branch using the github web page.
Next I ran the following commands:

$ git clone https://github.com/staticd-growthecommons/numpy.git
$ cd numpy/
$ git remote add https://github.com/numpy/numpy.git
$ git remote add upstream https://github.com/numpy/numpy.git
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/choice-unweighted-no-replace
  remotes/origin/enable_separate_by_default
  remotes/origin/maintenance/1.0.3.x
[....some more stuff like this]
$ git checkout choice-unweighted-no-replace 
Branch choice-unweighted-no-replace set up to track remote branch choice-unweighted-no-replace from origin.
Switched to a new branch 'choice-unweighted-no-replace'
$ git branch -a
* choice-unweighted-no-replace
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/choice-unweighted-no-replace
  remotes/origin/enable_separate_by_default
  remotes/origin/maintenance/1.0.3.x

OK here my n00bness begins to shine like a thousand splendid suns. Despite reading all the tutorials I could find I’m still not sure what I’m supposed to do now.

What I want to achieve is this:

  1. I want to add/modify three new algorithms to the random library in numpy. Am I correct in assuming that since they are three separate unrelated enhancements, the correct way to go about this is to make three parallel branches based on the master? (and then submit pull requests for each branch so they can be reviewed independently)
  2. Once I have run the commands show above, do I just go about editing the source files found in the numpy directory? Will they automatically be joined to the choice-unweighted-no-replace branch?
  3. Can I switch to another branch for a while to work on another feature before I commit changes and push the current branch to the repo?
  4. What is the best way to test each of these branches? I couldn’t figure out how to use virtualenv with git.
  5. Is it possible to import the libraries from two branches into a single python program? like import branch1.numpy, branch2.numpy or something like that

Update: partial answer figured out:

At least for testing numpy, it’s fairly trivial: just run ./runtests.py -i from the numpy directory. It builds numpy and opens a ipython shell with the PYTHONPATH set. If you now do import numpy it imports the development branch in that directory.

To test multiple branches, just make copies of the git folder and checkout a different branch in each. Then you can open IPython shells for each branch.

  • Problems with virtualenvwrapper
  • Corrupt pack file on git aws.push
  • Trouble installing private github repository using pip
  • Workflow to customise Django Applications and contrib/merge upstream
  • Using git post-receive hook to deploy python application in virtualenv
  • How to clone a django reporsitory into a virtualenv
  • Bash command prompt with virtualenv and git branch
  • Having trouble setting up dev server for Django and website
  • One Solution collect form web for “Testing numpy python libraries from multiple git development branches”

    First and foremost I strongly recommend the Git Pro book. It should answer most of your questions that you will have later on.

    1. Yes, it is good practice to separate work on different topics in different branches. That way you can make a pull request later that will only cover the code involved in adding/changing this functionality.

    2. Git works by with something called an index. Merely changing a file does not automatically save the file on a branch, you have to tell git that you want to save it. To do so you first need to stage a file, and later make a commit.

    git add modifiedfile
    git commit -m "A message about my changes"
    

    This will add a new commit to the current branch you are at. If you want to make a commit on a different branch, you need to switch a branch first.

    git checkout branchname
    

    If you want to create a new branch and switch

    git checkout -b branchname
    
    1. You can switch between branches any time, but you should save your work first. You can make a commit which you will later reset, or stash.

    2. Not really familiar with virtualenv, so maybe you should make a separate question.

    3. To do this, you would have 2 repositories in 2 different directories. One will have the first branch checked out and the other would have the second one. This way your script will be able to use both libraries.

    Git Baby is a git and github fan, let's start git clone.