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')
15 # Due to a disutil oddity on Unices : see
16 # http://aspn.activestate.com/ASPN/Mail/Message/distutils-sig/588325
18 targetDir=os.path.join('lib','python'+sys.version[:3],'site-packages')
20 macros =[('__STDC_LIMIT_MACROS', '1')]
23 vtkWrapper="vtkWrapPython"
25 targetDir=os.path.join('lib','site-packages')
30 VTK_PATH=os.environ['VTK_PATH']
33 print "Environment variable",err[err.rfind(':')+1:],'not defined, '\
35 VTK_PATH="c:\\Creatis\\vtkDistrib"
36 vtkWrapper=os.path.join(VTK_PATH,"bin","vtkWrapPython")
38 targetDir=os.path.join(targetDir, ThisModule)
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
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.
56 Jpeg8Sources.remove(os.path.join(gdcmJpeg8SrcDir, Remove))
59 Sources.extend(Jpeg8Sources)
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")
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"]
73 setup(name=ThisModule,
77 author_email="frog@creatis.insa-lyon.fr",
78 url="http://www.creatis.insa-lyon.fr/",
81 gdcmPythonSrcDir + '.demo' ],
82 cmdclass={'build_ext':build_extWrap}, # redirects default build_ext
83 ext_modules=[SwigExtension(name='_gdcm',
85 include_dirs=[gdcmSrcDir],
89 swig_include=[gdcmSrcDir]
91 VTKExtension(name='gdcmPython.vtkgdcmPython',
93 include_dirs=[gdcmSrcDir,gdcmvtkSrcDir,
95 libraries=libraries+vtkLibraries,
97 library_dirs=[VTK_LIB_DIR],
98 vtkWrapper=vtkWrapper,
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,"*.*"))),