00001
00002
00003
00004
00005
00006
00007
00008 from distutils.core import setup, Extension
00009 import os, sys
00010 import os.path as path
00011
00012
00013 def getOS():
00014 if os.getenv('OS'):
00015 os_name = os.getenv('OS')
00016 '''Building DIM depends on $OS. If this is wrongly set then building DIM
00017 doesn't work and the installation will fail...
00018 '''
00019 else:
00020 os_name = os.uname()[0].lower()
00021 return os_name
00022
00023
00024
00025
00026
00027 OS = getOS()
00028
00029
00030
00031
00032 LIBRARIES = ['dim']
00033
00034
00035
00036
00037 COMPILE_ARGS = []
00038 if OS.lower().find('win') > -1:
00039
00040 COMPILE_ARGS += ['-DWIN32','-D__DEBUG', '-DDEBUG']
00041
00042 LIBRARIES.append('ws2_32')
00043
00044 else:
00045 LIBRARIES.append('dl')
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 dim_dir = None
00067
00068
00069 dim_include_dirs = []
00070
00071
00072 dim_library_dirs = []
00073
00074
00075 dim_env_vars = ('DIMDIR', 'DIMHOME', 'DIM_HOME')
00076 for dim_var in dim_env_vars:
00077
00078 if os.getenv(dim_var):
00079 dim_dir = os.getenv(dim_var)
00080 dim_include_dirs = [dim_dir, os.path.join(dim_dir, 'dim')]
00081 dim_library_dirs = [dim_dir, os.path.join(dim_dir, 'bin'),os.path.join(dim_dir, OS)]
00082
00083 if not dim_include_dirs and not dim_library_dirs:
00084 dim_dir = path.join(os.getcwd(), '..', 'dim')
00085 if path.exists(dim_dir):
00086 dim_include_dirs = [dim_dir, os.path.join(dim_dir, OS)]
00087 dim_library_dirs = [dim_dir, os.path.join(dim_dir, 'dim')]
00088 else:
00089 dim_dir = None
00090
00091
00092
00093 if not dim_include_dirs and os.sys.platform == 'linux2':
00094 dim_include_dirs = [ '/usr/local/include/dim' ]
00095 if not dim_library_dirs and os.sys.platform == 'linxu2':
00096 if os.uname()[4] == 'x86_64':
00097 dim_library_dirs = [ '/usr/local/lib64/' ]
00098 else:
00099 dim_library_dirs = [ '/usr/local/lib' ]
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 cwd = os.getcwd()
00112 include_dirs = dim_include_dirs
00113 include_dirs.append(os.path.join(cwd, 'src'))
00114 library_dirs = dim_library_dirs
00115 compile_args = COMPILE_ARGS
00116 libraries = LIBRARIES
00117 platform = sys.platform
00118 version = open('./VERSION').read().strip()
00119
00120
00121
00122 print 80*'-'
00123 print 'Welcome to the DIM Python interface module (PyDIM) installer.'
00124 print 80*'-'
00125 print 'Using variables:'
00126 print 'DIM dirs: %s' % dim_dir
00127 print 'OS: %s' % OS
00128 print 'Include dirs: %s' %include_dirs
00129 print 'Library dirs: %s' %library_dirs
00130 print 'Compile args: %s' %compile_args
00131 print 80*'-'
00132
00133 dimmodule = Extension('dimc',
00134 sources = ['src/dimmodule.cpp', 'src/pydim_utils.cpp'],
00135 include_dirs = include_dirs,
00136 libraries = libraries,
00137 library_dirs = library_dirs,
00138 extra_compile_args = compile_args
00139 )
00140 dimmodule_cpp = Extension('dimcpp',
00141 sources = ['src/dimcppmodule.cpp', 'src/pydim_utils.cpp'],
00142 include_dirs = include_dirs,
00143 libraries = libraries,
00144 library_dirs = library_dirs,
00145 extra_compile_args = compile_args
00146 )
00147 setup(name = 'pydim',
00148 version = version,
00149 description = 'Python interface package for DIM C and C++ interfaces.',
00150 long_description = 'The PyDIM package exposes the DIM C and C++ functions and classes in Python.',
00151 license='GPL',
00152 url = 'http://lbdoc.cern.ch/pydim/',
00153 author = 'Niko Neufeld (originally by Radu Stoica)',
00154 author_email = 'niko.neufeld@cern.ch',
00155 py_modules = ['pydim/__init__', 'pydim/debug'],
00156 ext_modules = [dimmodule_cpp, dimmodule],
00157 scripts = [],
00158 )
00159
00160
00161
00162