/[escript]/branches/RW_WIN32/bruce/src/SConscript
ViewVC logotype

Annotation of /branches/RW_WIN32/bruce/src/SConscript

Parent Directory Parent Directory | Revision Log Revision Log


Revision 232 - (hide annotations)
Fri Nov 25 09:59:48 2005 UTC (15 years, 10 months ago) by phornby
File size: 1387 byte(s)
1) Rob, could you please set up your editor to not put CR's into the files.
2) The import esys.bruce fails on Linux, but the rest seems OK.

Here is how things go.

If a directory (bruce say) contains an __init__.py, then import esys.bruce actually imports
the __init__.py file. One can either phoney up the namespace by then saying

from bruce import *

in __init__.py (ugly!!) or just rename bruce.py to __init__.py.

All the sub-packages need this treatment. I suggest doing it with the .py files in the
source tree rather than re-naming at build time. Any other modules in the sub-directory
can then be imported into the __init__.py in the usual way in order to make them visible
to the user. Alternatively, any module not imported to __init__.py is invisible to the user.
This is much better than mucking with PYTHON_PATH and LD_LIBRARY_PATH, which has a tendency
to make everything visible, and creates module name clashes in site-packages on occasions. 
The .so associated with a sub-directory should reside with the corresponding __init__.py
that imports it.

Careful use of "from AClass import AClass" and "from ASharedLib import *" in __init__.py
is also a good method of making classes contained in submodules
look like they are in the namespace of the __init__.py, thereby hiding
the intervening module name from the user. That way esys.bruce.AClass.AClass can be morphed
into esys.bruce.AClass, eliminating the annoying intervening module namespace.


1 jgs 176 Import('*')
2    
3 robwdcock 209 lib_name = 'brucecpp'
4 jgs 176
5 robwdcock 218 local_env=env.Copy()
6 jgs 176
7 robwdcock 218 src_dir = local_env.Dir('.').srcnode().abspath
8 jgs 177
9 robwdcock 218 import os
10     filenames = os.listdir(src_dir)
11 robwdcock 209 sources = [x for x in filenames if os.path.splitext(x)[1] in ['.cpp', '.c']]
12     headers = [x for x in filenames if os.path.splitext(x)[1] in ['.h']]
13 jgs 176
14 robwdcock 218 include = Dir('Bruce', esys_inc)
15     local_env.Install( include, headers )
16     local_env.Append(LIBS=[boost_lib_name, 'esysUtils', 'escriptcpp'])
17 jgs 176
18 robwdcock 209 if env['PLATFORM'] == "win32":
19 robwdcock 218 local_env.Append(CPPDEFINES=['_WINDOWS', '_USRDLL', 'BRUCE_EXPORTS'])
20     local_env['PDB'] = 'brucecpp.pdb'
21 phornby 221 elif env['PLATFORM'] == "posix":
22     pass
23 robwdcock 209 else:
24     import os
25    
26     cxx_flags = '-O0 -openmp -openmp_report0 -tpp2 -ansi -ansi_alias -no-gcc -w1'
27    
28     cpp_path = ['#../bruce/inc', '#../escript/inc',
29     '#../esysUtils/inc',
30     '/raid2/tools/python-2.3.4/include/python2.3',
31     '/raid2/tools/boost/include/boost-1_31']
32    
33 robwdcock 218 local_env = Environment(ENV = os.environ)
34 robwdcock 209
35 robwdcock 218 local_env.Replace(CXX = 'icc')
36     local_env.Replace(SHOBJSUFFIX = '.lo')
37     local_env.Replace(CXXFLAGS = cxx_flags)
38     local_env.Replace(CPPPATH = cpp_path)
39 jgs 176
40 robwdcock 218 bruce_lib = local_env.SharedLibrary(lib_name, sources)
41     local_env.Install(esys_lib, bruce_lib)
42 robwdcock 220
43     # Python
44     local_env.Export('lib_name')
45 phornby 232 env.SConscript(dirs = ['#/bruce/py_src'], build_dir='#/build/$PLATFORM/bruce/py', duplicate=0)

  ViewVC Help
Powered by ViewVC 1.1.26