To build PTVS on your own PC, for example to pick up the latest bug fixes, make modifications, or contribute back to the project, please use the following instructions.

Cloning

First, you will require a local copy of our Mercurial repository. It can be cloned from https://hg.codeplex.com/pytools. (If you’re behind a corporate firewall you may need to enter your proxy settings. These can be found in TortoiseHg’s Global Settings dialog.)

image

If you do not want to use Mercurial, you can download the latest commit as a ZIP file from the Source Code page.

If you intend to contribute back to PTVS, you will need to Create a Fork and use the source URL provided there.

Prerequisites

The following list of software is required in order to build PTVS from source. All of these are required for a complete build, though a complete build is not required to be able to contribute. The next section outlines the projects that may be omitted when building PTVS.

Note that you do not need both Microsoft Visual Studio 2010 and 2012. You'll need VS 2010 to build PTVS for VS 2010, and VS 2012 to build PTVS for VS 2012. Instructions in this document describe how to build using VS 2012 -- building with VS 2010 is very similar.

Software

Download

Microsoft Visual Studio 2010/2012/2013 Professional or higher

Free trials: http://www.microsoft.com/visualstudio/eng/downloads

Microsoft Visual Studio 2010 Service Pack 1

http://www.microsoft.com/en-us/download/details.aspx?id=23691

Microsoft Visual Studio SDK

VS 2013: http://www.microsoft.com/visualstudio/eng/downloads#d-vs-sdk
VS 2012: http://www.microsoft.com/en-us/download/details.aspx?id=30668
VS 2010: http://www.microsoft.com/en-us/download/details.aspx?id=21835

Microsoft Visual Studio 2010 Standalone Profiler

http://www.microsoft.com/en-us/download/details.aspx?id=23205 
(required for VS 2010 Professional only)

TortoiseHg

http://tortoisehg.bitbucket.org/download/index.html (Mercurial client)

Microsoft .NET Framework 3.5 SP1

http://www.microsoft.com/en-us/download/details.aspx?id=22

Microsoft HPC Pack 2008 R2 Client Utilities

http://www.microsoft.com/en-us/download/details.aspx?id=17017
(optional)

Microsoft HPC SDK

http://www.microsoft.com/en-us/download/details.aspx?id=12218
(optional)

Microsoft Kinect SDK

http://www.microsoft.com/en-us/kinectforwindows/develop/overview.aspx
(optional)

Windows Azure SDK for Python

https://www.windowsazure.com/en-us/develop/python/
(optional)

Be aware that the Windows Azure SDK for Python installer will install the latest release of PTVS. A system-wide PTVS installation may interfere with the build process, so you should remove it from the list of packages to install (or uninstall it later).

Some other prerequisites are included with the source code:

Our automated tests use a separately installed tool for controlling Visual Studio. These can be installed by running Prerequisites\TCTestHostAdaptersDev12.msi for VS 2013, Prerequisites\TCTestHostAdaptersDev11.msi for VS 2012 or Prerequisites\TCTestHostAdaptersDev10.msi for VS 2010.

Finally you'll need to disable strong name verification for the Python Tools binaries. This can be done by merging the Prerequisites\EnableSkipVerification.reg file (or Prerequisites\EnableSkipVerificationX86.reg, depending on your own system).  This will install registry keys which disable strong name verification for the assemblies built by PTVS.  If you also want to use the installer you may need to stop and restart the Windows Installer service (from an elevated command prompt, type net stop "Windows Installer" and then net start "Windows Installer").

Optional Projects

Visual Studio 2010 Professional requires the Standalone Profiler to build the Profiling, VsPyProf, VsPyProfX86 and ProfilingUITests projects. Alternatively, these can be unloaded from the solution if you do not want to install or build the profiler.

The HPC Pack and SDK are required to build the Hpc and MpiShim projects. You can unload these from the solution if you do not want to install the HPC tools.

The Kinect SDK is required to build the PyKinect and PyKinectAudio projects. These can be unloaded from the solution if you do not want to install the Kinect SDK.

The Azure SDK is required for building the Django, WebRole, AzureSetup, DjangoTests, DjangoUITests and FastCgiTests projects. You can unload these if you do not want to install the Azure SDK.

Visual Studio 2012 or 2013 are required to build the TestAdapter and TestAdapterTests projects. You can unload these on Visual Studio 2010.

The IronPython, IronPython.Interpreter, IronPythonResolver and Pyvot projects, as well as those already mentioned, can be unloaded to reduce build time if you do not require these features (note that they can be built without requiring IronPython or Excel being installed). When you are not working on tests, you can unload all projects in the "Tests" solution folder to further reduce the build time, though we do expect most contributions to include appropriate unit tests.

Core projects are always required to be built, and you will receive build errors if you unload one by mistake. These projects are Analysis, Analyzer, Attacher, AttacherX86, Debugger, PyDebugAttach, PyDebugAttachX86, PythonTools and ReplWindow. The PythonTools.sln solution file includes a solution platform called “Minimal” that may be selected within Visual Studio to only build these projects. This will give the fastest possible build times, while only providing core functionality. All of the prerequisites above that are marked optional can be omitted when only building core projects.

Building with MSBuild

PTVS can be built from the Visual Studio Command Prompt by typing

msbuild PythonTools.sln

in your cloned directory. This will install PTVS into the VS Experimental hive, but does not create an installer or affect your main VS installation. Building should complete with zero warnings or errors.

image

To build using the Release configuration, which produces optimized code, type:

msbuild PythonTools.sln /p:Configuration=Release

in the cloned directory. As above, this does not create an .msi file, but it will install PTVS into the VS Experimental hive.

image

The VS Experimental hive can be started from the Start menu or by typing

devenv /rootSuffix Exp

at the Visual Studio Command Prompt.

image

Building with Visual Studio

PythonTools.sln can be opened and built in Visual Studio using the Build Solution command. To debug, ensure that PythonTools is selected as the startup project and use F5 to run PTVS inside of the VS Experimental hive. If an error appears rather than a new instance of VS, ensure the Project|Debug settings are correct.

PTVS projects loaded in Visual Studio

Launch settings for PTVS

Building in Visual Studio may produce a number of warnings related to potentially incompatible assemblies and missing references. As long as all projects build successfully, these warnings are benign and can be ignored.

If you already have PTVS installed for all users then you will get an error while compiling. The solution is to uninstall PTVS, or to reinstall it for the current user only. To install for the current user, install from the command line using msiexec /i PythonToolsInstaller.msi ALLUSERS="".

Running Automated Tests

PTVS contains a large number of automated tests, including a mix of UI-based tests (which will start another VS, take control of your mouse, etc.) and non-UI tests. Some of the UI-based tests may fail intermittently or interfere with each other, while some tests may make incorrect assumptions about your system configuration (such as the availability of certain versions of Python). It is best to select the tests you need from the Test Explorer window and supervise them as they run.

image

Building the Installer

The simplest way to build the installer is to run the release script Python\Setup\BuildRelease.ps1 with PowerShell. This script updates the version to the current date, builds all flavors (Release, Debug) for each supported version of Visual Studio installed (currently VS 2015 and VS 2013), and archives the source code, binaries, symbols, and installers into an output directory.

powershell -ExecutionPolicy RemoteSigned .\BuildRelease.ps1 D:\PTVS_Out -skiptests

Building PTVS from the command prompt

The output directory will contain VS 201x\Debug and VS 201x\Release folders (for each installed VS version) and a Sources folder. The Debug and Release directories will contain the installers, and the top level will contain all the release installers. This is the same script which we use to builds releases of PTVS, so you'll get an installer which works just like the released versions. However, unless you sign the binaries with your own code signing certificate, the installer will only work if the EnableSkipVerification.reg (or EnableSkipVerificationX86.reg) file has been merged into the registry on the destination computer.

To build PTVS for Visual Studio 2010 or Visual Studio 2012, you should provide the -vstarget 10.0 or -vstarget 11.0 options, as these versions are now disabled by default. You are also likely to encounter build errors, and we are no longer testing changes against these versions.

The script provides many more options. Type powershell -ExecutionPolicy RemoteSigned Get-Help .\BuildRelease.ps1 for more information and powershell -ExecutionPolicy RemoteSigned Get-Help .\BuildRelease.ps1 -examples for some examples.

Last edited Nov 14 at 9:36 PM by Zooba, version 23

Comments

Zooba Dec 20, 2012 at 5:34 PM 
*** Posting questions and bugs in the Discussions section will get much faster responses. ***

Apologies to everyone for the delays.

Odwalla - That's the error you get when you have PTVS installed for All Users. If you uninstall (or reinstall "Just for you") then building should work fine.

SoonStudios - the Web Platform Installer will install PTVS (and the VS Integrated Shell) if you don't already have it. Thanks for catching the typo.

rfrizzel - At a guess, I'd say something has corrupted your VSSDK installation. "Failed to load assembly" is one of the worst exceptions - it could be that the file is missing or that one bit has changed and it's failing certificate validation. I'd suggest reinstalling the SDK, if you haven't already upgraded to VS 2012 or resolved it.

citykid - Thanks for the typo. Not sure about the error you're getting, but chances are in the last 11 months we've changed it.

*** Don't assume that my responses here mean you'll get support by posting in comments. Note that this is 11 months late in one case. Use the Discussions tab at the top of the page if you need help. ***

Odwalla Nov 4, 2012 at 1:58 AM 
Fresh Windows 7 x64 machine with all SPs and updates.
Visual Studio 2010 Pro w/ SP1
All PTVS pre-requisites installed

No matter how I try to build, either with the command to compile to the experimental hive, the Powershell command to make the installer, or the msbuild command to make the installer I get the following error:

"D:\Python Tools\PythonTools.sln" (default target) (1) -> "D:\Python Tools\Release\Product\Python\PythonTools\PythonTools.csproj" (default target) (2) -> "D:\Python Tools\Release\Product\Python\ReplWindow\ReplWindow.csproj" (default target) (8) -> (DeployVsixExtensionFiles target) ->
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\VSSDK\Microsoft.VsSDK.targets(420,5): error : Exception has been thrown by the target of an invocation. [D:\Python Tools\Release\Product\Python\ReplWindow\ReplWindow.csproj]


Any ideas what may be wrong?

SoonStudios Sep 17, 2012 at 2:55 AM 
EnableSkipVerification.reg and TCTestHostAdapters are in folder Prerequisites not Setup. Also Azure SDK doesn't install pytools.

rfrizzel Apr 11, 2012 at 1:01 PM 
I'm very close to getting it built, but I am getting one error:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\VSSDK\Microsoft.VsSDK.Common.targets(74,5): error : Failed
to load 'C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK\VisualStudioIntegration\Tools\Bin\VSCT.exe' Assembly.
[C:\Users\Russ\Documents\Visual Studio 2010\Projects\pytools\Release\Product\Python\ReplWindow\ReplWindow.csproj]

What's weird is that I have that path setup in my Path environment variable and also I have setup environment variables for VsSDKInstall (C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK), VsSDKTools (C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK\VisualStudioIntegration\Tools\Bin), and VsSDKIncludes (C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK\VisualStudioIntegration\Common\Inc)

I am building on a 64-bit virtual machine with Windows7 Home Premium. Any helpful hints?

Thanks in advance for the help...

citykid Jan 23, 2012 at 6:47 PM 
Building the package on Vista:

in Release/Product/Setup/dirs.proj : // above is a typo: Release\Python\Setup => Release\Product\Setup
uncomment the kinect line:

<ItemGroup>
<ProjectFile Include="ReplWindow\ReplWindow.wixproj"/>
<ProjectFile Include="PythonTools\PythonTools.wixproj"/>
<ProjectFile Include="PythonProfiling\PythonProfiling.wixproj"/>
<ProjectFile Include="PythonToolsInstaller\PythonToolsInstaller.wixproj"/>
<!--<ProjectFile Include="PyKinectInstaller\PyKinectInstaller.wixproj"/>-->
<ProjectFile Include="PyVotInstaller\PyVotInstaller.wixproj"/>
</ItemGroup>

The latest source fixed a suddenly omni present crash of Visual Studio when adding or editing a file here.

Thx for this great package and the detailed instructions here to build it at home!

Zooba Nov 4, 2011 at 7:20 AM 
The Kinect SDK appears to be necessary to use the BuildRelease script as of 1.1 alpha.

anambd Aug 30, 2011 at 9:12 AM 
Thank you very much for your instruction.It is very ,<a href="http://www.forexpipbd.blogspot.com>useful for us.</a>

eyeofhell Apr 8, 2011 at 11:20 AM 
Thanks again. It was a problem with strong name registration that prevents build of MSI installers, but updated instructions works excellent!

dinov Apr 7, 2011 at 7:03 PM 
Yes, I tested them in a clean VM.

eyeofhell Apr 6, 2011 at 10:47 AM 
Thank you for the perfect instructions!
Have you tested them by performing on the clear OS?