]> Creatis software - gdcm.git/blob - gdcmPython/setup.py.in
BUG: Remove the Print indent mess. Please only one Print per class default paramater...
[gdcm.git] / gdcmPython / setup.py.in
1 #!/usr/bin/env python
2
3 """
4 setup.py for installing the gdcm-Python bindings using distutils.
5
6 Created by Mathieu Malaterre, May 2004.
7 Heavily based on setup.py.in from VTK, Prabhu Ramachandran, June 2002.
8
9 """
10
11 import glob, sys, os
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
17
18 version = "${GDCM_VERSION}",
19
20 build_lib_dir = "${LIBRARY_OUTPUT_PATH}"
21
22 build_bin_dir = "${EXECUTABLE_OUTPUT_PATH}"
23
24 gdcmDictsDir = "${GDCM_SOURCE_DIR}"
25 gdcmDictsDir = os.path.join( gdcmDictsDir, "Dicts" )
26
27 def get_libs():
28     """Returns a list of libraries to be installed.  """
29     libs = []
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'))))
35     else:
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'))
39             
40         libs = glob.glob(os.path.join(d, 'vtk*Python.dll'))
41
42     return libs
43
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'),
49                                     ('root', 'root'),
50                                     ('force', 'force'),
51                                     )
52     def run (self):
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
58                 f = convert_path(f)
59                 if self.warn_dir:
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)
65             else:
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)
70                 elif self.root:
71                     dir = change_root(self.root, dir)
72                 self.mkpath(dir)
73                 for data in f[1]:
74                     data = convert_path(data)
75                     (out, _) = self.copy_file(data, dir)
76                     self.outfiles.append(out)
77       
78 # I should not hardcode 'bin' since user could build in none default path...
79 # Well keep finger cross it won't happen :P
80
81 setup(name             = "gdcmPython",
82       version          = "${GDCM_VERSION}",
83       description      = "Grass Root DiCoM",
84       author           = "frog",
85       author_email     = "frog@creatis.insa-lyon.fr",
86       maintainer       = "GDCM Developers",
87       maintainer_email = "dcmlib@creatis.insa-lyon.fr",
88       license          = "BSD",
89       long_description = "Library dedicated to reading/parsing and writing Dicom files",
90       url              = "http://www.creatis.insa-lyon.fr/Public/Gdcm/",
91       platforms        = ['Any'],
92       cmdclass          = {'install_data': my_install_data},
93       packages         = ['gdcmPython'],
94       package_dir      = {'gdcmPython' : 'bin'},
95       data_files       = [ ('gdcmPython', get_libs() ), ('.', ['gdcmPython/gdcm.pth']) ],
96      )
97