X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=gdcmPython%2Fsetup.py.in;h=525aa0c75633f81dff5b0157aaf123d23b8bd422;hb=d569212ce5d0577c01b30796b288aafc2ae4fd9d;hp=e5e2988002fbb140d3fe42e80edfaf25672c72ea;hpb=f94f85b5578c5a8575f9cadc3702766defd9d707;p=gdcm.git diff --git a/gdcmPython/setup.py.in b/gdcmPython/setup.py.in index e5e29880..525aa0c7 100644 --- a/gdcmPython/setup.py.in +++ b/gdcmPython/setup.py.in @@ -1,129 +1,104 @@ +#!/usr/bin/env python + +""" +setup.py for installing the gdcm-Python bindings using distutils. + +Created by Mathieu Malaterre, May 2004. +Heavily based on setup.py.in from VTK, Prabhu Ramachandran, June 2002. + +""" + +import glob, sys, os +from types import StringType from distutils.core import setup -import glob, os, sys, shutil -from distutilsWrapping import * -from WrapSwig import * -from WrapVTK import * - -ThisModule='gdcmPython' -gdcmPythonSrcDir=ThisModule -gdcmSrcDir ="src" -gdcmJpeg8SrcDir =os.path.join('src', 'jpeg', 'libijg8') -gdcmJpeg12SrcDir=os.path.join('src', 'jpeg', 'libijg12') -gdcmJpgSrcDir =os.path.join('src', 'jpeg', 'ljpg') -gdcmvtkSrcDir ="vtk" -gdcmDictsDir ="Dicts" -gdcmTestDir ="Test" - -# Due to a distutils oddity on Unices : see -# http://aspn.activestate.com/ASPN/Mail/Message/distutils-sig/588325 -if(os.name=='posix'): - targetDir=os.path.join('lib','python'+sys.version[:3],'site-packages') - libraries=["stdc++"] - macros =[('__STDC_LIMIT_MACROS', '1')] - - VTKPATH="${VTK_DIR}" - vtkWrapper="vtkWrapPython" -else: - targetDir=os.path.join('lib','site-packages') - libraries=["WSOCK32"] - macros =[] - - try: - VTKPATH=os.environ['VTKPATH'] - except KeyError,e: - err=str(e) - print "Environment variable",err[err.rfind(':')+1:],'not defined, '\ - 'please fix it!' - VTKPATH="${VTK_DIR}" - vtkWrapper=os.path.join(VTKPATH,"bin","vtkWrapPython") - -targetDir=os.path.join(targetDir, ThisModule) - -### Sources section: determination of sources for the extensions: -# Sources 1a/ The kernel of gdcm itself (which wrapped with Swig) -# defines the first extension -Sources = [] -Sources.extend(glob.glob(os.path.join(gdcmSrcDir,"*.cxx"))) -Sources.append(os.path.join(gdcmPythonSrcDir,"gdcm.i")) -# Sources 1b/ The kernel of gdcm depends on a jpeg library whose sources are -# contained in subdir gdcmJpeg8SrcDir. But within this subdir -# some of the C files should not be compiled (refer to -# gdcmJpeg8SrcDir/Makefile.am) ! - -Jpeg8Sources = glob.glob(os.path.join(gdcmJpeg8SrcDir,"j*.c")) -Jpeg8SourcesToRemove = ['jmemansi.c', 'jmemname.c', 'jmemdos.c', 'jmemmac.c'] -for Remove in Jpeg8SourcesToRemove: - ### Because setup.py is a multiple pass process we need to trap - ### the case where the files were already wed out on a previous pass. - try: - Jpeg8Sources.remove(os.path.join(gdcmJpeg8SrcDir, Remove)) - except ValueError: - continue -Sources.extend(Jpeg8Sources) - -Jpeg12Sources = glob.glob(os.path.join(gdcmJpeg12SrcDir,"j*.c")) -Jpeg12SourcesToRemove = ['jmemansi12.c', 'jmemname12.c', 'jmemdos12.c', 'jmemmac12.c'] -for Remove in Jpeg12SourcesToRemove: - ### Because setup.py is a multiple pass process we need to trap - ### the case where the files were already wed out on a previous pass. - try: - Jpeg12Sources.remove(os.path.join(gdcmJpeg12SrcDir, Remove)) - except ValueError: - continue -Sources.extend(Jpeg12Sources) - -#For 'xmedcon' Jpeg Lossless -JpgSources =glob.glob(os.path.join(gdcmJpgSrcDir,"*.c")) -Sources.extend(JpgSources) - -# Sources 2/ The second extension contains the VTK classes (which we wrap -# with the vtk wrappers): -VTK_INCLUDE_DIR=os.path.join(VTKPATH,"include","vtk") -VTK_LIB_DIR=os.path.join(VTKPATH,"lib","vtk") -vtkSources = [] -vtkSources.extend(glob.glob(os.path.join(gdcmvtkSrcDir,"vtk*.cxx"))) -vtkSources.extend(glob.glob(os.path.join(gdcmSrcDir,"*.cxx"))) -vtkSources.extend(Jpeg8Sources) -vtkSources.extend(Jpeg12Sources) -vtkSources.extend(JpgSources) - -vtkLibraries=["vtkCommon","vtkCommonPython", - "vtkIO","vtkIOPython", - "vtkFiltering","vtkFilteringPython"] - -##### -setup(name=ThisModule, - version="${GDCM_VERSION_MAJOR}.${GDCM_VERSION_MINOR}", - description="...", - author="frog", - author_email="frog@creatis.insa-lyon.fr", - url="http://www.creatis.insa-lyon.fr/Public/Gdcm/", - packages=[ '.', - gdcmPythonSrcDir, - gdcmPythonSrcDir + '.demo' ], - cmdclass={'build_ext':build_extWrap}, # redirects default build_ext - ext_modules=[SwigExtension(name='_gdcm', - sources=Sources, - include_dirs=[gdcmSrcDir,gdcmJpeg8SrcDir, - gdcmJpeg12SrcDir,gdcmJpgSrcDir], - libraries=libraries, - define_macros=macros, - swig_cpp=1, - swig_include=[gdcmSrcDir] - ), - VTKExtension(name='gdcmPython.vtkgdcmPython', - sources=vtkSources, - include_dirs=[gdcmSrcDir,gdcmvtkSrcDir, - VTK_INCLUDE_DIR], - libraries=libraries+vtkLibraries, - define_macros=macros, - library_dirs=[VTK_LIB_DIR], - vtkWrapper=vtkWrapper, - ), - ], - data_files=[(os.path.join(targetDir,gdcmTestDir), - glob.glob(os.path.join(gdcmTestDir,"*.acr"))), - (os.path.join(targetDir,"Dicts"), - glob.glob(os.path.join(gdcmDictsDir,"*.*"))), - ] +from distutils.util import change_root, convert_path +from distutils.command.install_data import install_data +from distutils.sysconfig import get_config_var + +version = "${GDCM_VERSION}", + +build_lib_dir = "${LIBRARY_OUTPUT_PATH}" + +build_bin_dir = "${EXECUTABLE_OUTPUT_PATH}" + +gdcmDictsDir = "${GDCM_SOURCE_DIR}" +gdcmDictsDir = os.path.join( gdcmDictsDir, "Dicts" ) + +# You can change this to suit your needs. However you must make sure +# that under *nix the libvtk*Python*.so in the specified directory. +#install_lib_dir = "${CMAKE_INSTALL_PREFIX}/lib/vtk" + +def get_libs(): + """Returns a list of libraries to be installed. """ + libs = [] + if os.name == 'posix': + libs = glob.glob(os.path.abspath(os.path.join( + build_lib_dir, '_gdcm' + get_config_var('SO')))) + libs = libs + glob.glob(os.path.abspath(os.path.join( + build_lib_dir, 'libvtkgdcmPython' + get_config_var('SO')))) + else: + d = os.path.normpath(build_lib_dir) + if not os.path.isfile(os.path.join(d, 'libvtkgdcmPython.dll')): + d = os.path.normpath(os.path.join(build_lib_dir, 'release')) + + libs = glob.glob(os.path.join(d, 'vtk*Python.dll')) + + return libs + +def get_scripts(): + """Returns the appropriate gdcm.py python script + that is to be installed.""" + scripts = [] + if os.name == 'posix': + f = os.path.join(build_bin_dir, "gdcm.py") + if os.path.exists(f): + scripts.append(f) + else: + win32_bin_dir = build_bin_dir + for subdir in ('Debug', 'Release', 'MinSizeRel', + 'RelWithDebInfo'): + win32_bin_dir = os.path.join(build_bin_dir, subdir) + if os.path.exists(win32_bin_dir): + break + for i in ('vtkpython.exe', 'pvtkpython.exe'): + f = os.path.join(os.path.normpath(win32_bin_dir), i) + if os.path.exists(f): + scripts.append(f) + return scripts + + +print get_libs() +print get_scripts() +print gdcmDictsDir + +""" +setup(name="Distutils", + version="1.0", + description="Python Distribution Utilities", + author="Greg Ward", + author_email="gward@python.net", + url="http://www.python.org/sigs/distutils-sig/", + packages=['distutils', 'distutils.command'], ) + +""" +setup(name = "gdcmPython", + version = "${GDCM_VERSION}", + description = "GNU DiCoM", + author = "frog", + author_email = "frog@creatis.insa-lyon.fr", + maintainer = "GDCM Developers", + maintainer_email = "dcmlib@creatis.insa-lyon.fr", + license = "LGPL", + long_description = "Library dedicated to reading/parsing and writing Dicom files", + url = "http://www.creatis.insa-lyon.fr/Public/Gdcm/", + platforms = ['Any'], + packages = ['gdcmPython'], + #scripts = get_scripts(), + #package_dir = {'gdcmPython': '.'}, + #data_files = [ ('gdcmPython', 'gdcm.pth') ], + ) + + #data_files = [('gdcmPython', get_libs()), ('gdcmPython', ['gdcm.pth'])] + #data_files = [('Dicts', glob.glob(os.path.join(gdcmDictsDir,"Dicts/*"))) ] +