]> Creatis software - gdcm.git/blob - setup.py
* setup.py is again effective on un*x (takes into account the
[gdcm.git] / 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 gdcmvtkSrcDir   ="vtk"
12 gdcmDictsDir    ="Dicts"
13 gdcmTestDir     ="Test"
14
15 # Due to a disutil oddity on Unices : see
16 # http://aspn.activestate.com/ASPN/Mail/Message/distutils-sig/588325
17 if(os.name=='posix'):
18         targetDir=os.path.join('lib','python'+sys.version[:3],'site-packages')
19         libraries=["stdc++"]
20         macros   =[('__STDC_LIMIT_MACROS', '1')]
21
22         VTK_PATH="/usr"
23         vtkWrapper="vtkWrapPython"
24 else:
25         targetDir=os.path.join('lib','site-packages')
26         libraries=["WSOCK32"]
27         macros   =[]
28
29         try:
30                 VTK_PATH=os.environ['VTK_PATH']
31         except KeyError,e:
32                 err=str(e)
33                 print "Environment variable",err[err.rfind(':')+1:],'not defined, '\
34                        'please fix it!'
35                 VTK_PATH="c:\\Creatis\\vtkDistrib"
36         vtkWrapper=os.path.join(VTK_PATH,"bin","vtkWrapPython")
37
38 targetDir=os.path.join(targetDir, ThisModule)
39
40 ### Sources section: determination of sources for the extensions:
41 # Sources 1a/ The kernel of gdcm itself (which wrapped with Swig)
42 #             defines the first extension
43 Sources = []
44 Sources.extend(glob.glob(os.path.join(gdcmSrcDir,"*.cxx")))
45 Sources.append(os.path.join(gdcmPythonSrcDir,"gdcm.i"))
46 # Sources 1b/ The kernel of gdcm depends on a jpeg library whose sources are
47 #             contained in subdir gdcmJpeg8SrcDir. But within this subdir
48 #             some of the C files should not be compiled (refer to
49 #             gdcmJpeg8SrcDir/Makefile.am) !
50 Jpeg8Sources = glob.glob(os.path.join(gdcmJpeg8SrcDir,"j*.c"))
51 Jpeg8SourcesToRemove = ['jmemansi.c', 'jmemname.c', 'jmemdos.c', 'jmemmac.c']
52 for Remove in Jpeg8SourcesToRemove:
53    ### Because setup.py is a multiple pass process we need to trap
54    ### the case were the files were allready wed out on a previous pass.
55    try:
56       Jpeg8Sources.remove(os.path.join(gdcmJpeg8SrcDir, Remove))
57    except ValueError:
58       continue
59 Sources.extend(Jpeg8Sources)
60
61 # Sources 2/ The second extension contains the VTK classes (which we wrap
62 #            with the vtk wrappers):
63 VTK_INCLUDE_DIR=os.path.join(VTK_PATH,"include","vtk")
64 VTK_LIB_DIR=os.path.join(VTK_PATH,"lib","vtk")
65 vtkSources = []
66 vtkSources.extend(glob.glob(os.path.join(gdcmvtkSrcDir,"vtk*.cxx")))
67 vtkSources.extend(glob.glob(os.path.join(gdcmSrcDir,"*.cxx")))
68 vtkLibraries=["vtkCommon","vtkCommonPython",
69               "vtkIO","vtkIOPython",
70               "vtkFiltering","vtkFilteringPython"]
71
72 ##### 
73 setup(name=ThisModule,
74       version="0.2",
75       description="...",
76       author="frog",
77       author_email="frog@creatis.insa-lyon.fr",
78       url="http://www.creatis.insa-lyon.fr/",
79       packages=[ '.',
80                  gdcmPythonSrcDir,
81                  gdcmPythonSrcDir + '.demo' ],
82       cmdclass={'build_ext':build_extWrap}, # redirects default build_ext
83       ext_modules=[SwigExtension(name='_gdcm',
84                                  sources=Sources,
85                                  include_dirs=[gdcmSrcDir],
86                                  libraries=libraries,
87                                  define_macros=macros,
88                                  swig_cpp=1,
89                                  swig_include=[gdcmSrcDir]
90                                 ),
91                    VTKExtension(name='gdcmPython.vtkgdcmPython',
92                                 sources=vtkSources,
93                                 include_dirs=[gdcmSrcDir,gdcmvtkSrcDir,
94                                               VTK_INCLUDE_DIR],
95                                 libraries=libraries+vtkLibraries,
96                                 define_macros=macros,
97                                 library_dirs=[VTK_LIB_DIR],
98                                 vtkWrapper=vtkWrapper,
99                                ),
100                                                 ],
101       data_files=[(os.path.join(targetDir,gdcmTestDir),
102                    glob.glob(os.path.join(gdcmTestDir,"*.acr"))),
103                   (os.path.join(targetDir,"Dicts"),
104                    glob.glob(os.path.join(gdcmDictsDir,"*.*"))),
105                 ]
106      )