I wrote a little Python script wrapcl.py
script which wraps our compiler binary (cl.exe
, the Microsoft Visual Studio C++ compiler). I then created a new batch file cl.bat
which makes that Python script accessible so that I can run cl
as before and it will silently call my wrapper script instead of the real program. For what it's worth, here is my cl.bat
batch file:
@python %~dp0\wrapcl.py %*
This works quite well - except in one case:
We have existing scripts which do something like
cl >NUL 2>&1 && GOTO CL
to determine whether the Microsoft Visual Studio C++ compiler is avail开发者_如何学Cable. This breaks if cl
actually calls my cl.bat
batch file since the call to cl.bat
never returns. We'd have to use call cl >NUL ...
for that.
Is there any way I can make my wrapcl.py
Python script look just like cl.exe
for callers so that I can avoid touching our existing scripts which expect cl && foo
to work?
One possibility is to compile your python code as an executable using py2exe. Here's a link: py2exe
精彩评论