]> Creatis software - gdcm.git/blob - gdcmPython/SetupOldies/setup.py
To allow testsuite go on.
[gdcm.git] / gdcmPython / SetupOldies / setup.py
1 from distutils.core import setup
2 import glob, os, sys, shutil
3 from distutilsWrapping import *
4 from WrapSwig import *
5 from WrapVTK import *
6
7 ThisModule      ="gdcmPython"
8 gdcmPythonSrcDir=ThisModule
9 gdcmSrcDir      ="src"
10 gdcmJpeg8SrcDir =os.path.join('src', 'jpeg', 'libijg8')
11 gdcmJpeg12SrcDir=os.path.join('src', 'jpeg', 'libijg12')
12 gdcmJpgSrcDir   =os.path.join('src', 'jpeg', 'ljpg')
13 gdcmvtkSrcDir   ="vtk"
14 gdcmDictsDir    ="Dicts"
15 gdcmTestDir     ="Test"
16
17 # Due to a distutils oddity on Unices : see
18 # http://aspn.activestate.com/ASPN/Mail/Message/distutils-sig/588325
19 if(os.name=='posix'):
20         targetDir=os.path.join('lib','python'+sys.version[:3],'site-packages')
21         libraries=["stdc++"]
22         macros   =[('__STDC_LIMIT_MACROS', '1')]
23
24         VTKPATH="/usr"
25         vtkWrapper="vtkWrapPython"
26 else:
27         targetDir=os.path.join('lib','site-packages')
28         libraries=["WSOCK32"]
29         macros   =[]
30
31         try:
32                 VTKPATH=os.environ['VTKPATH']
33         except KeyError,e:
34                 err=str(e)
35                 print "Environment variable",err[err.rfind(':')+1:],'not defined, '\
36                        'please fix it!'
37                 VTKPATH="/usr"
38         vtkWrapper=os.path.join(VTKPATH,"bin","vtkWrapPython")
39
40 targetDir=os.path.join(targetDir, ThisModule)
41
42 ### Sources section: determination of sources for the extensions:
43 # Sources 1a/ The kernel of gdcm itself (which wrapped with Swig)
44 #             defines the first extension
45 Sources = []
46 Sources.extend(glob.glob(os.path.join(gdcmSrcDir,"*.cxx")))
47 Sources.append(os.path.join(gdcmPythonSrcDir,"gdcm.i"))
48 # Sources 1b/ The kernel of gdcm depends on a jpeg library whose sources are
49 #             contained in subdir gdcmJpeg8SrcDir. But within this subdir
50 #             some of the C files should not be compiled (refer to
51 #             gdcmJpeg8SrcDir/Makefile.am) !
52
53 Jpeg8Sources = glob.glob(os.path.join(gdcmJpeg8SrcDir,"j*.c"))
54 Jpeg8SourcesToRemove = ['jmemansi.c', 'jmemname.c', 'jmemdos.c', 'jmemmac.c']
55 for Remove in Jpeg8SourcesToRemove:
56    ### Because setup.py is a multiple pass process we need to trap
57    ### the case where the files were already wed out on a previous pass.
58    try:
59       Jpeg8Sources.remove(os.path.join(gdcmJpeg8SrcDir, Remove))
60    except ValueError:
61       continue
62 Sources.extend(Jpeg8Sources)
63
64 Jpeg12Sources = glob.glob(os.path.join(gdcmJpeg12SrcDir,"j*.c"))
65 Jpeg12SourcesToRemove = ['jmemansi12.c', 'jmemname12.c', 'jmemdos12.c', 'jmemmac12.c']
66 for Remove in Jpeg12SourcesToRemove:
67    ### Because setup.py is a multiple pass process we need to trap
68    ### the case where the files were already wed out on a previous pass.
69    try:
70       Jpeg12Sources.remove(os.path.join(gdcmJpeg12SrcDir, Remove))
71    except ValueError:
72       continue
73 Sources.extend(Jpeg12Sources)
74
75 #For 'xmedcon' Jpeg Lossless
76 JpgSources =glob.glob(os.path.join(gdcmJpgSrcDir,"*.c"))
77 Sources.extend(JpgSources)  
78
79 # Sources 2/ The second extension contains the VTK classes (which we wrap
80 #            with the vtk wrappers):
81 VTK_INCLUDE_DIR=os.path.join(VTKPATH,"include","vtk")
82 VTK_LIB_DIR=os.path.join(VTKPATH,"lib","vtk")
83 vtkSources = []
84 vtkSources.extend(glob.glob(os.path.join(gdcmvtkSrcDir,'vtk*.cxx')))
85 vtkSources.extend(glob.glob(os.path.join(gdcmSrcDir,'*.cxx')))
86 vtkSources.extend(Jpeg8Sources)
87 vtkSources.extend(Jpeg12Sources)
88 vtkSources.extend(JpgSources)
89
90 vtkLibraries=["vtkCommon","vtkCommonPython",
91               "vtkIO","vtkIOPython",
92               "vtkFiltering","vtkFilteringPython"]
93
94 ##### 
95 setup(name=ThisModule,
96       version="0.4",
97       description="...",
98       author="frog",
99       author_email="frog@creatis.insa-lyon.fr",
100       url="http://www.creatis.insa-lyon.fr/Public/Gdcm/",
101       packages=[ '.',
102                  gdcmPythonSrcDir,
103                  gdcmPythonSrcDir + '.demo' ],
104       cmdclass={'build_ext':build_extWrap}, # redirects default build_ext
105       ext_modules=[SwigExtension(name='_gdcm',
106                                  sources=Sources,
107                                  include_dirs=[gdcmSrcDir,gdcmJpeg8SrcDir,
108                                                gdcmJpeg12SrcDir,gdcmJpgSrcDir],
109                                  libraries=libraries,
110                                  define_macros=macros,
111                                  swig_cpp=1,
112                                  swig_include=[gdcmSrcDir]
113                                 ),
114                                 VTKExtension(name='gdcmPython.vtkgdcmPython',
115                                 sources=vtkSources,
116                                 include_dirs=[gdcmSrcDir,gdcmvtkSrcDir,
117                                               VTK_INCLUDE_DIR],
118                                 libraries=libraries+vtkLibraries,
119                                 define_macros=macros,
120                                 library_dirs=[VTK_LIB_DIR],
121                                 vtkWrapper=vtkWrapper,
122                                ),
123                                                 ],
124       data_files=[(os.path.join(targetDir,gdcmTestDir),
125                    glob.glob(os.path.join(gdcmTestDir,"*.acr"))),
126                   (os.path.join(targetDir,"Dicts"),
127                    glob.glob(os.path.join(gdcmDictsDir,"*.*"))),
128                 ]
129      )