1 from distutils.core import setup
2 import glob, os, sys, shutil
3 from distutilsWrapping import *
6 from gdcmPython.gdcmVersion import *
8 ThisModule='gdcmPython'
9 gdcmPythonSrcDir=ThisModule
11 gdcmJpeg8SrcDir =os.path.join('src', 'jpeg', 'libijg8')
12 gdcmJpeg12SrcDir=os.path.join('src', 'jpeg', 'libijg12')
13 gdcmJpgSrcDir=os.path.join('src', 'jpeg', 'ljpg')
18 # Due to a disutil oddity on Unices : see
19 # http://aspn.activestate.com/ASPN/Mail/Message/distutils-sig/588325
21 targetDir=os.path.join('lib','python'+sys.version[:3],'site-packages')
23 macros =[('__STDC_LIMIT_MACROS', '1')]
26 vtkWrapper="vtkWrapPython"
28 targetDir=os.path.join('lib','site-packages')
33 VTKPATH=os.environ['VTKPATH']
36 print "Environment variable",err[err.rfind(':')+1:],'not defined, '\
38 VTKPATH="c:\\Creatis\\vtkDistrib"
39 vtkWrapper=os.path.join(VTKPATH,"bin","vtkWrapPython")
41 targetDir=os.path.join(targetDir, ThisModule)
43 ### Sources section: determination of sources for the extensions:
44 # Sources 1a/ The kernel of gdcm itself (which wrapped with Swig)
45 # defines the first extension
47 Sources.extend(glob.glob(os.path.join(gdcmSrcDir,"*.cxx")))
48 Sources.append(os.path.join(gdcmPythonSrcDir,"gdcm.i"))
49 # Sources 1b/ The kernel of gdcm depends on a jpeg library whose sources are
50 # contained in subdir gdcmJpeg8SrcDir. But within this subdir
51 # some of the C files should not be compiled (refer to
52 # gdcmJpeg8SrcDir/Makefile.am) !
54 Jpeg8Sources = glob.glob(os.path.join(gdcmJpeg8SrcDir,"j*.c"))
55 Jpeg8SourcesToRemove = ['jmemansi.c', 'jmemname.c', 'jmemdos.c', 'jmemmac.c']
56 for Remove in Jpeg8SourcesToRemove:
57 ### Because setup.py is a multiple pass process we need to trap
58 ### the case where the files were allready wed out on a previous pass.
60 Jpeg8Sources.remove(os.path.join(gdcmJpeg8SrcDir, Remove))
63 Sources.extend(Jpeg8Sources)
65 Jpeg12Sources = glob.glob(os.path.join(gdcmJpeg12SrcDir,"j*.c"))
66 Jpeg12SourcesToRemove = ['jmemansi12.c', 'jmemname12.c', 'jmemdos12.c', 'jmemmac12.c']
67 for Remove in Jpeg12SourcesToRemove:
68 ### Because setup.py is a multiple pass process we need to trap
69 ### the case where the files were allready wed out on a previous pass.
71 Jpeg12Sources.remove(os.path.join(gdcmJpeg12SrcDir, Remove))
74 Sources.extend(Jpeg12Sources)
76 #For 'xmedcon' Jpeg Lossless
77 JpgSources =glob.glob(os.path.join(gdcmJpgSrcDir,"*.c"))
78 Sources.extend(JpgSources)
80 # Sources 2/ The second extension contains the VTK classes (which we wrap
81 # with the vtk wrappers):
82 VTK_INCLUDE_DIR=os.path.join(VTKPATH,"include","vtk")
83 VTK_LIB_DIR=os.path.join(VTKPATH,"lib","vtk")
85 vtkSources.extend(glob.glob(os.path.join(gdcmvtkSrcDir,"vtk*.cxx")))
86 vtkSources.extend(glob.glob(os.path.join(gdcmSrcDir,"*.cxx")))
87 vtkSources.extend(Jpeg8Sources)
88 vtkSources.extend(Jpeg12Sources)
89 vtkSources.extend(JpgSources)
90 vtkSources.remove(os.path.join(gdcmvtkSrcDir,"vtkgdcmViewer.cxx"))
92 vtkLibraries=["vtkCommon","vtkCommonPython",
93 "vtkIO","vtkIOPython",
94 "vtkFiltering","vtkFilteringPython"]
97 setup(name=ThisModule,
101 author_email="frog@creatis.insa-lyon.fr",
102 url="http://www.creatis.insa-lyon.fr/",
105 gdcmPythonSrcDir + '.demo' ],
106 cmdclass={'build_ext':build_extWrap}, # redirects default build_ext
107 ext_modules=[SwigExtension(name='_gdcm',
109 include_dirs=[gdcmSrcDir,gdcmJpeg8SrcDir,
110 gdcmJpeg12SrcDir,gdcmJpgSrcDir],
112 define_macros=macros,
114 swig_include=[gdcmSrcDir]
116 VTKExtension(name='gdcmPython.vtkgdcmPython',
118 include_dirs=[gdcmSrcDir,gdcmvtkSrcDir,
120 libraries=libraries+vtkLibraries,
121 define_macros=macros,
122 library_dirs=[VTK_LIB_DIR],
123 vtkWrapper=vtkWrapper,
126 data_files=[(os.path.join(targetDir,gdcmTestDir),
127 glob.glob(os.path.join(gdcmTestDir,"*.acr"))),
128 (os.path.join(targetDir,"Dicts"),
129 glob.glob(os.path.join(gdcmDictsDir,"*.*"))),