Module setup
[frames] | no frames]

Source Code for Module setup

 1   
 2  from distutils.core import setup, Extension 
 3   
 4  # The following code helps you find libgpk.so and libgpkio.so, 
 5  # so long as they are somewhere on LD_LIBRARY_PATH.    This may be important 
 6  # if you are using a binary distribution which may have its own limited idea 
 7  # of a search path, and you have added more directories (for your own software) 
 8  # to LD_LIBRARY_PATH. 
 9  import os 
10  GPKLIB_LIB = None 
11  pl = os.environ['LD_LIBRARY_PATH'].split(':') 
12  for p in pl: 
13          for ext in ['so', 'a']: 
14                  pp = os.path.join(p, 'libgpk.%s' % ext) 
15                  if os.path.isfile(pp) and os.access(pp, os.R_OK): 
16                          GPKLIB_LIB = p 
17                          break 
18          if GPKLIB_LIB is not None: 
19                  break 
20  assert GPKLIB_LIB is not None, "Cannot find gpklib.so" 
21  # GPKLIB_LIB = '/home/mace/gpk/local/lib' 
22  print 'lib=', GPKLIB_LIB 
23   
24  # This tells where the libgpk include files go: 
25  GPKLIB_INCLUDES = os.path.join(os.path.split(GPKLIB_LIB)[0], 'include') 
26  # GPKLIB_INCLUDES = '/home/mace/gpk/local/include' 
27  print 'includes=', GPKLIB_INCLUDES 
28   
29  from gmisclib import Num 
30   
31  setup(name="gpkimg", version="1.2", 
32          description = "Interface to gpkio 2-D image formats", 
33          author = "Greg Kochanski", 
34          author_email = "gpk@kochanski.org", 
35          py_modules = ["gpkimgclass"], 
36          ext_modules = [ 
37                  Extension("gpkimg", [ "gpkimg.cc" ], 
38                                  libraries = ["gpk", "gpkio"], 
39   
40                                  # Places to look for gpklib.h and gpkio.h: 
41                                  include_dirs = [ 
42                                                  GPKLIB_INCLUDES, 
43                                                  Num.get_include() 
44                                                  ], 
45   
46                                  # Places to look or libgpk and libgpkio: 
47                                  library_dirs = [ 
48                                                  GPKLIB_LIB 
49                                                  ] 
50                          ) 
51                  ] 
52          ) 
53