#!/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 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" ) 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 class my_install_data (install_data): def finalize_options (self): """Needed to make this thing work properly.""" self.set_undefined_options ('install', ('install_lib', 'install_dir'), ('root', 'root'), ('force', 'force'), ) def run (self): """Taken shamlessly from VTK source""" self.mkpath(self.install_dir) for f in self.data_files: if type(f) == StringType: # it's a simple file, so copy it f = convert_path(f) if self.warn_dir: self.warn("setup script did not provide a directory for " "'%s' -- installing right in '%s'" % (f, self.install_dir)) (out, _) = self.copy_file(f, self.install_dir) self.outfiles.append(out) else: # it's a tuple with path to install to and a list of files dir = convert_path(f[0]) if not os.path.isabs(dir): dir = os.path.join(self.install_dir, dir) elif self.root: dir = change_root(self.root, dir) self.mkpath(dir) for data in f[1]: data = convert_path(data) (out, _) = self.copy_file(data, dir) self.outfiles.append(out) # I should not hardcode 'bin' since user could build in none default path... # Well keep finger cross it won't happen :P setup(name = "gdcmPython", version = "${GDCM_VERSION}", description = "Grass Root DiCoM", author = "frog", author_email = "frog@creatis.insa-lyon.fr", maintainer = "GDCM Developers", maintainer_email = "dcmlib@creatis.insa-lyon.fr", license = "BSD", long_description = "Library dedicated to reading/parsing and writing Dicom files", url = "http://www.creatis.insa-lyon.fr/Public/Gdcm/", platforms = ['Any'], cmdclass = {'install_data': my_install_data}, packages = ['gdcmPython'], package_dir = {'gdcmPython' : 'bin'}, data_files = [ ('gdcmPython', get_libs() ), ('.', ['gdcmPython/gdcm.pth']) ], )