Changeset 3545


Ignore:
Timestamp:
Sep 7, 2006, 2:52:51 PM (18 years ago)
Author:
jack
Message:

Added basic install support of the python .py/.pyc/.pyo files.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • SConstruct

    r3544 r3545  
    3030    return None
    3131
     32# Create the builders
     33pyc_builder = Builder(action = build_pyc,
     34                      suffix = '.pyc',
     35                      src_suffix = '.py')
     36pyo_builder = Builder(action = build_pyo,
     37                      suffix = '.pyo',
     38                      src_suffix = '.py')
     39
    3240# Read in build options
    3341opts = Options('build_options.py')
     
    3745opts.Add('OPTIMISATION_LEVEL', 'Optimisation level for the building of .pyo files. Must be 1 or 2')
    3846
    39 # Create the .pyc builder
    40 pyc_builder = Builder(action = build_pyc,
    41                       suffix = '.pyc',
    42                       src_suffix = '.py')
    43 # Create the .pyo builder
    44 pyo_builder = Builder(action = build_pyo,
    45                       suffix = '.pyo',
    46                       src_suffix = '.py')
     47# Windows' site packages are in a different location to those on Linux
     48if sys.platform == 'win32':
     49    opts.Add(PathOption('PREFIX',
     50                        'Location to install compiled sources',
     51                        os.path.join(sys.exec_prefix, 'lib', 'site-packages')))
     52else:
     53    opts.Add(PathOption('PREFIX',
     54                        'Location to install compiled sources'.
     55                        os.path.join(sys.exec_prefix, 'lib', 'python' + sys.version[:3], 'site-packages')))
     56
     57opts.Add(BoolOption('INSTALL_PYTHON_SOURCE',
     58                    'Install the .py files as well as the .pyc/.pyo files',
     59                    0))
    4760
    4861env = Environment(options = opts)
     
    5568    raise ValueError, "OPTIMISATION_LEVEL must be between 1 and 2 inclusive"
    5669
    57 # Find the path for Python.h and then share it to other SConscripts later on
    5870# Where to find the Python.h
    5971if sys.platform == 'win32':
     
    6981    env.Append(LIBS=[python_libname])
    7082else:
    71     python_include = os.path.join(os.path.join(sys.exec_prefix, 'include'),
    72                                   'python' + sys.version[:3])
     83    python_include = os.path.join(sys.exec_prefix, 'include', 'python' + sys.version[:3])
    7384   
    7485# Check existence of Python.h
     
    98109dirs = ['anuga_core']
    99110while(dirs != []):
    100     dirs += filter(os.path.isdir, map(lambda x : dirs[0] + os.sep + x, os.listdir(dirs[0])))
    101     files += filter(lambda x : x[-3:] == '.py', map(lambda x : dirs[0] + os.sep + x, os.listdir(dirs[0])))
     111    dirs += filter(os.path.isdir, map(lambda x : os.path.join(dirs[0], x), os.listdir(dirs[0])))
     112    files += filter(lambda x : x[-3:] == '.py', map(lambda x : os.path.join(dirs[0], x), os.listdir(dirs[0])))
    102113    dirs = dirs[1:]
    103114for x in files:
    104115    env.Pyc(x + 'c', x)
    105116    env.Pyo(x + 'o', x)
     117    instdir = os.path.join(env['PREFIX'], os.path.split(x)[0])
     118    env.Install(instdir, x + 'c')
     119    env.Install(instdir, x + 'o')
     120    if env['INSTALL_PYTHON_SOURCE']:
     121        env.Install(instdir, x)
    106122
     123env.Alias('install', '${PREFIX}')
     124   
    107125SConscript(['anuga_core/source/anuga/SConscript'])
  • anuga_core/source/anuga/mesh_engine/SConscript

    r3327 r3545  
    55env2.SharedLibrary('triang', ['triangle.c', 'triang.c'])
    66env2.SharedLibrary('triangle', ['triangle.c'])
    7 
    8 
    9 
  • build_options.py

    r3544 r3545  
    1212# Optimisation level used when building the .pyo files
    1313OPTIMISATION_LEVEL = 1
     14
     15# Where to install the compiled files. Defaults vary based on OS.
     16# Uncommenting this and leaving it as the empty string will cause the
     17# build to fail.
     18PREFIX = 'c:\\pyanuga_temp'
     19
     20# Install .py files as well as the binaries? Yes/No option
     21INSTALL_PYTHON_SOURCE = 'Yes'
Note: See TracChangeset for help on using the changeset viewer.