/[escript]/trunk/site_scons/site_init.py
ViewVC logotype

Diff of /trunk/site_scons/site_init.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4154 by jfenwick, Tue Jan 22 09:30:23 2013 UTC revision 4300 by caltinay, Mon Mar 11 00:50:19 2013 UTC
# Line 21  http://www.opensource.org/licenses/osl-3 Line 21  http://www.opensource.org/licenses/osl-3
21  __url__="https://launchpad.net/escript-finley"  __url__="https://launchpad.net/escript-finley"
22    
23  import sys, os, time, py_compile, re, subprocess  import sys, os, time, py_compile, re, subprocess
24    from SCons.Defaults import Chmod
25    from grouptest import *
26    
27  def findLibWithHeader(env, libs, header, paths, lang='c'):  def findLibWithHeader(env, libs, header, paths, lang='c'):
28      from SCons.Script.SConscript import Configure      from SCons.Script.SConscript import Configure
# Line 71  def findLibWithHeader(env, libs, header, Line 73  def findLibWithHeader(env, libs, header,
73      return inc_path, lib_path      return inc_path, lib_path
74    
75  def detectModule(env, module):  def detectModule(env, module):
76      if env['pythoncmd']=='python':      p=subprocess.call([env['pythoncmd'],'-c','import %s'%module])
77          try:      if p != 0:
78              __import__(module)          env[module] = False
79          except ImportError:          return False
80              return False      env[module] = True
     else:  
         p=subprocess.call([env['pythoncmd'],'-c','import %s'%module])  
         if p!=0:  
             return False  
81      return True      return True
82    
83    def write_buildvars(env):
84        buildvars=open(os.path.join(env['libinstall'], 'buildvars'), 'w')
85        for k,v in sorted(env['buildvars'].items()):
86            buildvars.write("%s=%s\n"%(k,v))
87        buildvars.close()
88    
89    def generateTestScripts(env, TestGroups):
90        try:
91            utest=open('utest.sh','w')
92            utest.write(GroupTest.makeHeader(env['PLATFORM'], env['prefix'], False))
93            for tests in TestGroups:
94                utest.write(tests.makeString())
95            utest.close()
96            env.Execute(Chmod('utest.sh', 0o755))
97            print("Generated utest.sh.")
98            # This version contains only python tests - I want this to be usable
99            # from a binary only install if you have the test files
100            utest=open('itest.sh','w')
101            utest.write(GroupTest.makeHeader(env['PLATFORM'], env['prefix'], True))
102            for tests in TestGroups:
103              if tests.exec_cmd=='$PYTHONRUNNER ':
104                utest.write(tests.makeString())
105            utest.close()
106            env.Execute(Chmod('itest.sh', 0o755))
107            print("Generated itest.sh.")        
108        except IOError:
109            env['warnings'].append("Error attempting to write unit test script(s).")
110    
111        # delete scripts upon cleanup
112        env.Clean('target_init', 'utest.sh')
113        env.Clean('target_init', 'itest.sh')
114    
115        # Make sure that the escript wrapper is in place
116        if not os.path.isfile(os.path.join(env['bininstall'], 'run-escript')):
117            print("Copying escript wrapper.")
118            Execute(Copy(os.path.join(env['bininstall'],'run-escript'), 'bin/run-escript'))
119    
120  # Code to build .pyc from .py  # Code to build .pyc from .py
121  def build_py(target, source, env):  def build_py(target, source, env):
122      try:      try:
# Line 90  def build_py(target, source, env): Line 125  def build_py(target, source, env):
125      except py_compile.PyCompileError, e:      except py_compile.PyCompileError, e:
126         print e         print e
127         return 1         return 1
128          
129    
130  # Code to run unit_test executables  # Code to run unit_test executables
131  def runUnitTest(target, source, env):  def runUnitTest(target, source, env):

Legend:
Removed from v.4154  
changed lines
  Added in v.4300

  ViewVC Help
Powered by ViewVC 1.1.26