PTVS and distutils/py2exe setup scripts

Apr 28 at 1:27 PM
Edited Apr 28 at 1: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 setup.py module. This requires setup.py to be called with a command line argument.

I dont want to change my startup script to setup.py as when I hit debug/run I want the application to run, not setup.py. 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 setup.py with the required arguments while also having the original startup script?
Coordinator
Apr 28 at 3: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 at 6: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?
Coordinator
Apr 30 at 7: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).