Menu

So, as many of you know, Github is a popular place to upload your code repositories to. Most people go to Github and create their repository, download it, hack on it, and push/pull request back to it.

But what if you don’t want the project to live on Github? After, Git is a decentralized protocol – making github the centralized repository for your projects is antithetical to the way git is actually supposed to work. For the purposes of this tutorial, I will be using putty, but this is completely optional if you wish instead to use openssl.

Unfortunately, unless you are a git pro, its not always obvious how to truly decentralize things. So, I’m writing up a guide for users (including a future me) on how to do this.

First thing is to create your project. Flesh out the structure, get it working, and compiling, or just create a directory with nothing it. It doesn’t matter a whole lot. Then, run:

git init

Now, ‘provision’ your project on github. Sign into your account, create yourself a project. Be careful – Github will ask you to add a license and a description. You don’t have to do this, but if you you will have to merge these files in with your local project. This is nothing scary, but it could mean some more busy work for yourself, so I advise against doing this.

Once you have your project provisioned, grab the git-ssh url, do not grab the https url , and run:

git remote add github git@github.com:user/my-project.git

where git@github.com:smaudet/jansi-sample.git is replaced with your url.

Optionally, you can setup branch tracking, but to keep this as decentralized as possible we are going to leave this completely untracked.

Now, generate yourself an SSH Key – puttygen will do this for you – and upload the public, not the private to the github account.

Here comes the important step – it appears github is rather broken, so we must ssh into the server in order to accept its key in putty. First, add your key to your pageant (just run it, open it up in the tray, and click ‘add-key’). Then, open up putty, and paste the url you used before, and connect. Accpet the connection, and voila, you can now access github via ssh keys. Bit of a roundabout process, eh?

To actually perform a push, do the following:

git pull github master

git push github master:master

The nice thing about this, is you can now push a project to multiple git repos – not just github, but your own personal servers, sourceforge, google code, Atlassian’s Stash, bitbucket, etc. You are no longer a slave to any one repo!

I was recently attempting to use the PyAudio framework (http://people.csail.mit.edu/hubert/pyaudio/) to ‘quickly’ test some audio features of a windows 7 box. Since there are no python bindings for the x64 bit version of python (msvc) which I am using, I figured that I’d go ahead and build the source. Unfortunately, there are some gotchas.

First of all, just a bit of banter – basically we are using msvc, and not mingw, feel free to skip the following paragraph unless you are interested in why I am using msvc.

If you are developing python and running extensions on windows, you have two main toolchains to pick from, msvc and msys(mingw). I pick msvc, not because I have anything against mingw, but because in my experience msvc integrates more cleanly, and you don’t end up having to deal with complex pathing problems from various multiple-step build processes found in Unix. In addition this, there are frequently name-mangling issues, undocumented special flags which need to be passed to the mingw systems, and, worst of all, you will often realize that you want to integrate with some msvc built system down the road which your app now has to find a way to talk to, or you will have to recompile your entire build. So, I will not be covering PyAudio x64 for mingw – if you are on a Windows environment, you might want to accept that you are going to be doing things in a Windows manner. I suggest using Linux if you are dead set against anything made by Microsoft – but then why are you here?

The pre-reqs for the build are as follows:

A working copy of python (in my case 2.7), x64, built using msvc. You should be able to obtain this from the Python website. Ensure that you can call this version of python from the cmd line.

A working copy of Visual Studio 2008, either Express or full will do. Since it is difficult to find these tools, you can obtain them here:

Failing Visual Studio 2008, you can attempt the build using Visual Studio 2010, however this will complicate the build and will require you to setup some magic with the VS90COMNTOOLS variable, basically pointing Python’s build system at the correct version of Visual Studio (distutils bugfix maybe?). FTR, I have both installed on my machine – Python is currently build using VS2008, however I imagine that will eventually change. Alternatively, you can e-mail me or leave a comment and I will attempt to get you a copy of VS2008 as best as I am able to.

A working copy of the Windows 7 SDK. This tool gives you the cross compilers you need to compile for x64.

Configure all these tools, make sure vcvarsall.bat and setenv.cmd are in your path, or at least that you know where they are and can call them. If you don’t know what to configure, then you can likely leave them alone and call the following commands outright.

Quickly, my vcvarsall can be found at C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\, and my setenv.cmd can be found at C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\

Or you can (if you have pip installed and configured): ‘pip install –no-install pyaudio’ and then you can find your PyAudio folder inside C:\temp\pip-build\pyaudio (note, pip-build will be suffixed by your username)

Dump the contents of patches.7z into your source directory. Note: hopefully these patches will make their way into the official source tree, but they may still be of use for the release versions

Extract portaudiolibs.7z and put the folder in the root source directory.

Once you have the source patched, you can setup your build environment. I recommend putting both of these files (from setupScripts.7z) somewhere on your path (a home bin directory for example) for easier access.

Run the provided win7sdk.bat from within the cmd-line

Run the provided pythonDev.bat from within the cmd-line

Run setup.py build –static-link

Run setup.py install

Test that your build works by running the examples in test

You should have installed pyaudio into your python installation, if you have trouble let me know. I will be updating these steps and will help clarify things where and when I can.