Changeset 3544
- Timestamp:
- Sep 7, 2006, 1:36:10 PM (18 years ago)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
SConstruct
r3523 r3544 5 5 # Function to build a .pyc from a .py 6 6 def build_pyc(target, source, env): 7 py_compile.compile(str(source[0]), str(target[0]), doraise=True) 7 python = sys.executable 8 command = "import py_compile; py_compile.compile('%s', doraise=True)" 9 if sys.platform == 'win32': 10 command %= str(source[0]).replace('\\', '\\\\') 11 else: 12 command %= str(source[0]) 13 rv = os.system('%s -c "%s"' % (python, command)) 14 if not rv == 0: 15 raise SyntaxError, "Could not compile %s" % str(source[0]) 16 return None 17 18 # Function to build a .pyo from a .py 19 def build_pyo(target, source, env): 20 python = sys.executable 21 command = "import py_compile; py_compile.compile('%s', doraise=True)" 22 if sys.platform == 'win32': 23 command %= str(source[0]).replace('\\', '\\\\') 24 else: 25 command %= str(source[0]) 26 options = '-' + 'O' * env['OPTIMISATION_LEVEL'] 27 rv = os.system('%s %s -c "%s"' % (python, options, command)) 28 if not rv == 0: 29 raise SyntaxError, "Could not compile %s" % str(source[0]) 8 30 return None 9 31 … … 13 35 opts.Add('MSVCFLAGS', 'Flags passed to the MSVC compiler') 14 36 opts.Add('METIS_DIR', 'Location of the metis directory relative to the pymetis directory') 37 opts.Add('OPTIMISATION_LEVEL', 'Optimisation level for the building of .pyo files. Must be 1 or 2') 15 38 16 39 # Create the .pyc builder … … 18 41 suffix = '.pyc', 19 42 src_suffix = '.py') 43 # Create the .pyo builder 44 pyo_builder = Builder(action = build_pyo, 45 suffix = '.pyo', 46 src_suffix = '.py') 20 47 21 48 env = Environment(options = opts) 22 env.Append(BUILDERS={'Pyc' : pyc_builder}) 49 env.Append(BUILDERS={'Pyc' : pyc_builder, 50 'Pyo' : pyo_builder}) 23 51 24 52 Help(opts.GenerateHelpText(env)) 53 54 if not (env['OPTIMISATION_LEVEL'] == 1 or env['OPTIMISATION_LEVEL'] == 2): 55 raise ValueError, "OPTIMISATION_LEVEL must be between 1 and 2 inclusive" 25 56 26 57 # Find the path for Python.h and then share it to other SConscripts later on … … 72 103 for x in files: 73 104 env.Pyc(x + 'c', x) 105 env.Pyo(x + 'o', x) 74 106 75 107 SConscript(['anuga_core/source/anuga/SConscript']) -
build_options.py
r3414 r3544 9 9 # Location of the metis directory relative to the pymetis directory 10 10 METIS_DIR = 'metis-4.0' 11 12 # Optimisation level used when building the .pyo files 13 OPTIMISATION_LEVEL = 1
Note: See TracChangeset
for help on using the changeset viewer.