views:

166

answers:

2

I have the following post-build step in a VC++ 2005 project that calls a Python 2.5.1 script:

postbuild.py

postbuild.py does:

import os
os.system('cd') # cd is just a test, could be anything

The process never starts, and it's the same with any other process I try, even using subprocess.call or Popen instead of os.system.

Does anyone know about anything related to problems like this in Python 2.5.1 or in build events in Visual C++ 2005 SP1?

A: 

Be aware that the post build event will only run immediately after a completed build. If the project had already been built (and so does not need building again), then the post build step will not run at all.

If you're editing the python script and then trying to get it to run by building the project, then it's not going to do anything unless you edit a file within the project each time, to force the build to occur.

Nik
I was always rebuilding everything just in case, it was a small project.
A: 

Solved. For some reason, using "postbuild.py" as postbuild step inhibits the python script from spawning other processes, where "python.exe postbuild.py" has no problems, and neither "pythonw.exe postbuild.py". I'm not sure why this happens, as all three methods are valid when used from cmd.exe.

But I would like to know if anyone has an explanation for this.

Just Friday I ran into an extremely similar problem. To diagnose it, in my version of "postbuild.py", os.getenv("PATH") looked reasonable, but subprocess.Popen("cmd /c echo %PATH%") reported an almost-completely-empty %PATH%. All it contained was c:\python26\.I eventually tracked it down to a registry key, something like HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/App Paths. The ActiveState installer had added c:\Python26\; it should have prepended that entry to the environment of postbuild.py itself, but instead it overwrote the PATH of anything _spawned by_ postbuild.py
Paul Du Bois
By "it should have prepended" I mean "as a result of that key, MS Windows should have prepended..."
Paul Du Bois