Search code examples
pythonscons

problem with scons in windows


I tried to build an executable for a python script using scons, which is failing with the following trace:

C:\WORKAREA\study>C:\Python26\Scripts\scons
scons: Reading SConscript files ...

scons: warning: No installed VCs
File "C:\WORKAREA\study\SConstruct", line 1, in <module>

scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "C:\WORKAREA\study\SConstruct", line 1, in <module>
scons: done reading SConscript files.
scons: Building targets ...
link /nologo /OUT:fibo.exe fibo.py
'link' is not recognized as an internal or external command,
operable program or batch file.
scons: *** [fibo.exe] Error 1
scons: building terminated because of errors.

It seems that link /nologo /OUT is the point where everything breaks down. Can anyone help me with this?


Solution

  • You're trying to build a .exe file from a .py file right? In that case, you don't need the VC++ compiler, you will need a tool like py2exe. And if you want to use SCons as a build system, you will need to create a SCons builder for py2exe.exe. Something along the lines as:

    env = Environment()
    
    def py2exe_action(target, source, env):
      # execute py2exe <source> <output> here
      return 0
    
    env['BUILDERS']['Py2Exe'] = env.Builder(action = py2exe_action)
    env.Default(env.Py2Exe(target = 'out_exe_file.exe', source = 'in_python_file.py'))
    

    http://www.py2exe.org/