Q: add a new path to PTYHONPATH and use it for program that is doing it using NSIS Platform: Windows 7
Python: 2.7.3
StrCpy $NETWORK_PATH "\\someserver\network\path\here"
DetailPrint "$\n"
DetailPrint "Setting up paths required"
Push "SETX PYTHONPATH $NETWORK_PATH;$NETWORK_PATH\lib"
Call Execute
Push '"C:\Python27\python.exe" setup.py deploy'
Call Execute

Function Execute
    Exch $0
    # execution of the command and return success or failure
FunctionEnd

This above is compiled as NSIS installer and run on multiple machines.
Problem
"C:\Python27\python.exe" setup.py deploy depends on that $NETWORK_PATH for successful execution.
First time when we run it, $NETWORK_PATH is appended to PYTHONPATH environmental variable, but "C:\Python27\python.exe" setup.py deploy fails as new PYTHONPATH will be effective only either in new command prompt or in next run.
Is there a way to make the appended PYTHONPATH effective in the same run itself?
Currently, we are running it twice - once for setting PYTHONPATH and accepting the failure, second time it runs successfully.
Another alternative approach we tried is - we made 2 executables, one for setting PYTHONPATH and another for Python Script to run. Then we put both of them in batch script to run.
But my preference is to achieve whole of this in one file and in one run.

A: You can update the installers environment, it will be inherited by child processes:
System::Call 'Kernel32::SetEnvironmentVariable(t "PYTHONPATH", t "$NETWORK_PATH;$NETWORK_PATH\lib")i.r0' ; $0 will be != "0" on success
Push '"C:\Python27\python.exe" setup.py deploy'
Call Execute

