This project has moved and is read-only. For the latest updates, please go here.

PTVS and distutils/py2exe setup scripts

Apr 28, 2014 at 2:27 PM
Edited Apr 28, 2014 at 2:27 PM
I am using visual studio to develop a python application. My projects startup script is set to the main GUI script of the application.

Now I want to bundle the application by creating a py2exe module. This requires to be called with a command line argument.

I dont want to change my startup script to as when I hit debug/run I want the application to run, not This means that I cannot set the command line argument globally (i.e via the properties/debug page of the project).

Is there any way I can set it up so I can easily run with the required arguments while also having the original startup script?
Apr 28, 2014 at 4:03 PM
Sounds like something that custom Python commands (<CreatePythonCommandItem>) are a perfect match for. Have a look at this thread, it should point you in the right direction.
Apr 30, 2014 at 7:51 AM
Thanks I'm looking through it, although I wonder if the 'Build' and 'Release' commands can be configured so that build/F5 does the normal running of the startup script and release runs the setup scripts?
Apr 30, 2014 at 8:08 AM
What do you mean by the "Release" command?

Regular build (which is also triggered by F5) does, in fact, just run MSBuild, it's just that the default Python project template doesn't have the target that is run. But if you add it as described here, you can do whatever you want inside it. In particular, if you want your target to run some Python code, you can use the <RunPythonCommand> task, which is also documented in the comments in Microsoft.PythonTools.targets. If you want to run a script file that's in your project, TargetType="script" will do the trick (script path in Target is then relative to project home).