4 setup.py for installing the gdcm-Python bindings using distutils.
6 Created by Mathieu Malaterre, May 2004.
7 Heavily based on setup.py.in from VTK, Prabhu Ramachandran, June 2002.
12 from types import StringType
13 from distutils.core import setup
14 from distutils.util import change_root, convert_path
15 from distutils.command.install_data import install_data
16 from distutils.sysconfig import get_config_var
18 version = "${GDCM_VERSION}",
20 build_lib_dir = "${LIBRARY_OUTPUT_PATH}"
22 build_bin_dir = "${EXECUTABLE_OUTPUT_PATH}"
24 gdcmDictsDir = "${GDCM_SOURCE_DIR}"
25 gdcmDictsDir = os.path.join( gdcmDictsDir, "Dicts" )
28 """Returns a list of libraries to be installed. """
30 if os.name == 'posix':
31 libs = glob.glob(os.path.abspath(os.path.join(
32 build_lib_dir, '_gdcm' + get_config_var('SO'))))
33 libs = libs + glob.glob(os.path.abspath(os.path.join(
34 build_lib_dir, 'libvtkgdcmPython' + get_config_var('SO'))))
36 d = os.path.normpath(build_lib_dir)
37 if not os.path.isfile(os.path.join(d, 'libvtkgdcmPython.dll')):
38 d = os.path.normpath(os.path.join(build_lib_dir, 'release'))
40 libs = glob.glob(os.path.join(d, 'vtk*Python.dll'))
44 class my_install_data (install_data):
45 def finalize_options (self):
46 """Needed to make this thing work properly."""
47 self.set_undefined_options ('install',
48 ('install_lib', 'install_dir'),
53 """Taken shamlessly from VTK source"""
54 self.mkpath(self.install_dir)
55 for f in self.data_files:
56 if type(f) == StringType:
57 # it's a simple file, so copy it
60 self.warn("setup script did not provide a directory for "
61 "'%s' -- installing right in '%s'" %
62 (f, self.install_dir))
63 (out, _) = self.copy_file(f, self.install_dir)
64 self.outfiles.append(out)
66 # it's a tuple with path to install to and a list of files
67 dir = convert_path(f[0])
68 if not os.path.isabs(dir):
69 dir = os.path.join(self.install_dir, dir)
71 dir = change_root(self.root, dir)
74 data = convert_path(data)
75 (out, _) = self.copy_file(data, dir)
76 self.outfiles.append(out)
78 # I should not hardcode 'bin' since user could build in none default path...
79 # Well keep finger cross it won't happen :P
81 setup(name = "gdcmPython",
82 version = "${GDCM_VERSION}",
83 description = "Grass Root DiCoM",
85 author_email = "frog@creatis.insa-lyon.fr",
86 maintainer = "GDCM Developers",
87 maintainer_email = "dcmlib@creatis.insa-lyon.fr",
89 long_description = "Library dedicated to reading/parsing and writing Dicom files",
90 url = "http://www.creatis.insa-lyon.fr/Public/Gdcm/",
92 cmdclass = {'install_data': my_install_data},
93 packages = ['gdcmPython'],
94 package_dir = {'gdcmPython' : 'bin'},
95 data_files = [ ('gdcmPython', get_libs() ), ('.', ['gdcmPython/gdcm.pth']) ],