Python and Git are Not Just for the Non-Visual Studio Developers
You have seen them sitting in Starbucks Café’s drinking six dollar lattés with recipes such as “venti half white mocha, half cafe vanilla, with 2 shots pour appigato style (over the top) and caramel drizzle frappachino.” You have heard them saying words like “pip”, “git”, “social”, “closure”, “npm”, “v8”, “accelerator”, “VC” and “stealth-mode”. I can help you decipher these enigmatic sounds. I used to be among them. Scratch that, I am still one of them, at least when it comes to the lattés and Python.
I have great news for moonlighting pythonistas, you can now use python with efficiency and ease within the Visual Studio 2013 environment. With Visual Studio Team Foundation Server, Git repositories are supported as well. Let’s dive in and see what’s new for developers.
Python Tools for Visual Studio
Python Tools for Visual Studio (PTVS) is a free, open source plugin designed, developed and supported by Microsoft and the python community. PTVS turns Visual Studio into a world-class Python IDE and certainly the best Python IDE on Windows. PTVS supports CPython and mixed Python/C++ debugging. I kid you not, long gone are the days where you need two separate IDEs to debug your CPython API extensions. I cannot even fathom living without this anymore and I wish I had this back in the day developing high performance mathematical statistics libraries for my Django web apps. Not to mention, if you are a game developer and you use Python as your AI scripting language (as I did back in my youth), mixed Python/C++ debugging would have made me react in a way only this meme can accurately depict.
Don’t believe me? Watch this video.
What else can this magical plugin do, you wonder?
- You can perform Linux and MacOS remote debugging.
- You’ve got awesome intellisense and profiling.
- You have IPython support. YES! IPython support!
- VS Unit Testing also supports Python Unit Testing.
- You have virtualenv support.
Not to mention that you have a full Visual Studio environment at your fingertips.
How do I get it? I don’t want to pay.
If you’ve got Visual Studio 2013, head straight on to Codeplex.com and press the big download button.
If you don’t have Visual Studio 2013, you can download an isolated PTVS shell at the bottom of the download page. That’s it!
Show me the code!
Nothing beats a “Hello World” python application in my mind… except a Django “Hello World” python application! Scott Hanselman does a brilliant job of demonstrating how to get a Django web app up and running here. There are even better samples over at CodePlex such as Python talking to Kinect, Python talking to Excel and more.
Stay tuned for a future article on getting NumPy up and running for some serious mathematical exercises.
Git and Team Foundation Server
I don’t know about you but I have grown to adore Git and I even got over the fact that I’m forced to type the word “git” over and over again. Git is no longer in the exclusive domain of the terminal. I have lost count over how many times Git branching made experimental coding easier. It is one of the most important pieces of my toolsets on all my development platforms. Great news for those of you who are heavy TFS users but wish they had the choice to use Git, it is now accessible through Visual Studio and Team Foundation Server.
Git is a distributed version control system originally developed by Linus Torvalds in 2005. Git is the main technology behind GitHub, the popular open source hosting platform. Git operates differently from your traditional source code management tools. A Git repository is decentralized and a full repository is kept on each developer’s local machine with a complete history. You can perform typical source code management tasks such as committing, branching and merging offline. Thus Git is very popular with large open source projects who typically have very distant and distributed developers.
Using Git on Windows typically meant using a command line based tool. Visual Studio has Git integration out of the box in 2013. When adding a solution to source control, you can choose to use Git. Once a solution has been added to Git, all you have to do is right click on a file and you will have context menus for appropriate Git actions.
If your team has a heavy reliance on the Application Lifecycle Management capabilities built into TFS, do not despair! Team Foundation Server 2013 has built in support for Git instead of TFVC. You will have Git specific options but with access to all TFS features like Web Access, the Task Board and Team Rooms.
GitHub and Visual Studio
If you use GitHub (my profile) to push host your open source project, Git in Visual Studio 2013 has support for setting up remote repositories at endpoints including full support HTTP, HTTPS, File Paths and git:// URLs. Unfortuantely, there is no support for SSH operations at the moment.
A few caveats for using HTTPS remote repositories, you may receive an error when there is a self-signed certificate being used. You can follow the instructions here to fix that error.
PowerShell and Git
If you prefer to use a command line based tool to use Git, I invite you to take a look at posh-git, a PowerShell environment for Git. It is a set of scripts which provide Git and PowerShell Integration. It even has tab completion for git commands just like you would on a BASH terminal. Installation is fairly easy if you follow the instructions. Scott has a great example of what can be done on his blog.
There is nothing preventing you from having tight integration between Visual Studio and GitHub.
That’s all folks for now!