1 from distutils.core import setup
2 import glob, os, sys, shutil
3 from distutilsWrapping import *
7 ThisModule ="gdcmPython"
8 gdcmPythonSrcDir=ThisModule
10 gdcmJpeg8SrcDir =os.path.join('src', 'jpeg', 'libijg8')
11 gdcmJpeg12SrcDir=os.path.join('src', 'jpeg', 'libijg12')
12 gdcmJpgSrcDir =os.path.join('src', 'jpeg', 'ljpg')
17 # Due to a distutils oddity on Unices : see
18 # http://aspn.activestate.com/ASPN/Mail/Message/distutils-sig/588325
20 targetDir=os.path.join('lib','python'+sys.version[:3],'site-packages')
22 macros =[('__STDC_LIMIT_MACROS', '1')]
25 vtkWrapper="vtkWrapPython"
27 targetDir=os.path.join('lib','site-packages')
32 VTKPATH=os.environ['VTKPATH']
35 print "Environment variable",err[err.rfind(':')+1:],'not defined, '\
38 vtkWrapper=os.path.join(VTKPATH,"bin","vtkWrapPython")
40 targetDir=os.path.join(targetDir, ThisModule)
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
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) !
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.
59 Jpeg8Sources.remove(os.path.join(gdcmJpeg8SrcDir, Remove))
62 Sources.extend(Jpeg8Sources)
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.
70 Jpeg12Sources.remove(os.path.join(gdcmJpeg12SrcDir, Remove))
73 Sources.extend(Jpeg12Sources)
75 #For 'xmedcon' Jpeg Lossless
76 JpgSources =glob.glob(os.path.join(gdcmJpgSrcDir,"*.c"))
77 Sources.extend(JpgSources)
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")
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)
90 vtkLibraries=["vtkCommon","vtkCommonPython",
91 "vtkIO","vtkIOPython",
92 "vtkFiltering","vtkFilteringPython"]
95 setup(name=ThisModule,
99 author_email="frog@creatis.insa-lyon.fr",
100 url="http://www.creatis.insa-lyon.fr/Public/Gdcm/",
103 gdcmPythonSrcDir + '.demo' ],
104 cmdclass={'build_ext':build_extWrap}, # redirects default build_ext
105 ext_modules=[SwigExtension(name='_gdcm',
107 include_dirs=[gdcmSrcDir,gdcmJpeg8SrcDir,
108 gdcmJpeg12SrcDir,gdcmJpgSrcDir],
110 define_macros=macros,
112 swig_include=[gdcmSrcDir]
114 VTKExtension(name='gdcmPython.vtkgdcmPython',
116 include_dirs=[gdcmSrcDir,gdcmvtkSrcDir,
118 libraries=libraries+vtkLibraries,
119 define_macros=macros,
120 library_dirs=[VTK_LIB_DIR],
121 vtkWrapper=vtkWrapper,
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,"*.*"))),