Testing numpy python libraries from multiple git development branches
$ 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.
- Bash command prompt with virtualenv and git branch
- Git + Python Virtualenvs: unique directory across repositories
- Error Killed: 9 after command “git add .”
- Using git to manage virtualenv state: will this cause problems?
- Relocating virtual environment project from local to server (flask project), have to install dependencies again?
- Which PIP Returns Global Instead of VirtualEnv
What I want to achieve is this:
- 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)
- 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
- 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?
- What is the best way to test each of these branches? I couldn’t figure out how to use virtualenv with git.
- Is it possible to import the libraries from two branches into a single python program? like
import branch1.numpy, branch2.numpyor 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.
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.
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.
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
You can switch between branches any time, but you should save your work first. You can make a
commitwhich you will later
Not really familiar with virtualenv, so maybe you should make a separate question.
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.