From 5f17b94e1ddf2bfa0de416b72cf215b288523d65 Mon Sep 17 00:00:00 2001 From: regrain Date: Wed, 19 Jan 2005 14:56:09 +0000 Subject: [PATCH] * gdcmPython/ : change GDCM_DATA_PATH to GDCM_DATA_ROOT to be complient with all in gdcm * Remove some useless files in the Python part. Files now generated by CMake -- BeNours --- ChangeLog | 4 ++ gdcmPython/CMakeLists.txt | 18 +++--- gdcmPython/README | 8 ++- gdcmPython/__init__.py | 95 ---------------------------- gdcmPython/demo/PrintDicomDir.py.in | 2 +- gdcmPython/demo/PrintHeader.py.in | 2 +- gdcmPython/demo/vtkGdcmReader.py.in | 2 +- gdcmPython/demo/vtkGdcmWriter.py.in | 2 +- gdcmPython/gdcmVersion.py | 2 - gdcmPython/setup.py.in | 97 ----------------------------- 10 files changed, 21 insertions(+), 211 deletions(-) delete mode 100644 gdcmPython/__init__.py delete mode 100644 gdcmPython/gdcmVersion.py delete mode 100644 gdcmPython/setup.py.in diff --git a/ChangeLog b/ChangeLog index c14b7b48..449a85a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-01-19 Benoit Regrain + * gdcmPython/ : change GDCM_DATA_PATH to GDCM_DATA_ROOT to be complient with + all in gdcm + 2005-01-19 Benoit Regrain * Test/ : rename VTK tests to have a best name for the tests * gdcmPython/demo/*.py.in : Change the InitTraversal/GetNextEntry use to diff --git a/gdcmPython/CMakeLists.txt b/gdcmPython/CMakeLists.txt index 9e85703c..21315edd 100644 --- a/gdcmPython/CMakeLists.txt +++ b/gdcmPython/CMakeLists.txt @@ -176,12 +176,12 @@ ENDIF(GDCM_VTK) # generate a setup.py according to VTK installation # put it in subdir in order to not override old one - -GET_FILENAME_COMPONENT(VTKPATH ${VTK_DIR}/../../ ABSOLUTE) -CONFIGURE_FILE( - ${GDCM_SOURCE_DIR}/gdcmPython/setup.py.in - ${GDCM_BINARY_DIR}/setup.py -) +# +#GET_FILENAME_COMPONENT(VTKPATH ${VTK_DIR}/../../ ABSOLUTE) +#CONFIGURE_FILE( +# ${GDCM_SOURCE_DIR}/gdcmPython/setup.py.in +# ${GDCM_BINARY_DIR}/setup.py +#) #----------------------------------------------------------------------------- # Install stuff: @@ -208,8 +208,7 @@ FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/__init__.py FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/core.py "import gdcm\n" - "GDCM_DATA_PATH =\"${GDCM_DATA_ROOT}\"\n" - "GDCM_TEST_DATA_PATH=\"${GDCM_DATA_ROOT}\"\n" + "GDCM_DATA_ROOT =\"${GDCM_DATA_ROOT}\"\n" ) IF(GDCM_VTK) @@ -219,8 +218,7 @@ IF(GDCM_VTK) " from libvtkgdcmPython import *\n" "else:\n" " from vtkgdcmPython import *\n" - "GDCM_DATA_PATH =\"${GDCM_DATA_ROOT}\"\n" - "GDCM_TEST_DATA_PATH=\"${GDCM_DATA_ROOT}\"\n" + "GDCM_DATA_ROOT =\"${GDCM_DATA_ROOT}\"\n" ) ENDIF(GDCM_VTK) diff --git a/gdcmPython/README b/gdcmPython/README index 8cecd8e4..3cab0fa8 100644 --- a/gdcmPython/README +++ b/gdcmPython/README @@ -1,10 +1,12 @@ Variables that should be set in order to work with gdcmPython: -GDCM_DICT_PATH path to the dictionary GDCM_SOURCE/Dicts/ -GDCM_DATA_PATH path to gdcmData -PYTHONPATH path to both GDCM_BIN and GDCM_BIN/bin +GDCM_DATA_ROOT path to gdcmData +PYTHONPATH path to both + - GDCM_BIN + - GDCM_BIN/bin (for linux) or GDCM_BIN/bin/Release (for Windows) e.g. export GDCM_DICT_PATH=~/cvs/gdcm/Dicts/ export GDCM_DATA_PATH=~/cvs/gdcmData/ export PYTHONPATH=~/cvs/gdcmbin/bin:~/cvs/gdcmbin/ + diff --git a/gdcmPython/__init__.py b/gdcmPython/__init__.py deleted file mode 100644 index 4b2b8cc6..00000000 --- a/gdcmPython/__init__.py +++ /dev/null @@ -1,95 +0,0 @@ -import os, sys - -try: - from gdcmVersion import * -except: - print "gdcmVersion not imported" - -def BuildInstallOrPreinstallPath(DirName, FileName = None): - # Builds a path to the DirName directory. This should work both when: - # - the package is properly installed in which case DirName is a subdir - # of the package, - # - when in pre-installation mode (basically inside a CVS hierarchy) - # in which case DirName and the package itself lie at the same - # filesystem level. - # In both cases we need to express the full path to DirName relatively - # to the path to this __init__.py. For this we rely on __path__ variable. - # In order to make sure we got the correct Path, we check for the - # existence of FileName if it is setted otherwise for the existence of the - # DirName. - InstallModePath = os.path.join(__path__[0], DirName + "/") - if(FileName): - if os.path.isfile(os.path.join(InstallModePath, FileName)): - return InstallModePath - else: - if os.path.isdir(InstallModePath): - return InstallModePath - - PreInstallModePath = os.path.join(__path__[0], "..", DirName + "/") - if(FileName): - if os.path.isfile(os.path.join(PreInstallModePath, FileName)): - return PreInstallModePath - else: - if os.path.isdir(PreInstallModePath): - return PreInstallModePath - return None - -### Setup the path to the dictionaries. WARNING: this needs to be done -# BEFORE importation of the shadow classes generated by swig as found -# in gdcm, since the dynamic library loads the standard dictionary -# when dynamically loaded. -# We consider we succefully found the dictionaries path when we encounter -# the standard dictionary i.e. the file dicomV3.dic. - -try: - ### First consider the environnement variable. - os.environ["GDCM_DICT_PATH"] - if not os.path.isfile(os.path.join(os.environ["GDCM_DICT_PATH"], - "dicomV3.dic")): - raise KeyError -except KeyError: - Path = BuildInstallOrPreinstallPath("Dicts", "dicomV3.dic") - if not Path: - print "Path to dictionaries is mandatory. Exiting" - sys.exit(1) - os.environ["GDCM_DICT_PATH"] = Path -GDCM_DICT_PATH = os.environ["GDCM_DICT_PATH"] - -### Set up the path to the data images for the demos. -if os.environ["GDCM_DATA_PATH"]: - GDCM_DATA_PATH = BuildInstallOrPreinstallPath(os.environ["GDCM_DATA_PATH"], - "test.acr") -else: - GDCM_DATA_PATH = BuildInstallOrPreinstallPath("Test", "test.acr") -if not GDCM_DATA_PATH: - print "GDCM_DATA_PATH is not setup properly: unfound Test directory" - -### Set up the path to the data images of the test suite. -GDCM_TEST_DATA_PATH = BuildInstallOrPreinstallPath("gdcmData") - -### Import the swig generated shadow classes. -try: - import gdcm -except ImportError,e: - print e - raise ImportError, "gdcm extension not imported." - -### Expose only the necessary stuff -gdcmGlobal = gdcm.gdcmGlobal -gdcmDictSet = gdcm.gdcmDictSet -gdcmDicomDir = gdcm.gdcmDicomDir -gdcmHeader = gdcm.gdcmHeader -gdcmHeaderHelper = gdcm.gdcmHeaderHelper -gdcmFile = gdcm.gdcmFile - -gdcmDicomDirMeta = gdcm.gdcmDicomDirMeta -gdcmDicomDirPatient = gdcm.gdcmDicomDirPatient -gdcmDicomDirStudy = gdcm.gdcmDicomDirStudy -gdcmDicomDirSerie = gdcm.gdcmDicomDirSerie -gdcmDicomDirImage = gdcm.gdcmDicomDirImage - -def GetPubDictEntryNames(): - return gdcmGlobal.GetDicts().GetPubDictEntryNames() - -def GetPubDictEntryNamesByCategory(): - return gdcmGlobal.GetDicts().GetPubDictEntryNamesByCategory() diff --git a/gdcmPython/demo/PrintDicomDir.py.in b/gdcmPython/demo/PrintDicomDir.py.in index 1f74e543..1e97623e 100644 --- a/gdcmPython/demo/PrintDicomDir.py.in +++ b/gdcmPython/demo/PrintDicomDir.py.in @@ -14,7 +14,7 @@ from gdcmPython.core import * try: fileName = sys.argv[1] except IndexError: - fileName = os.path.join(GDCM_DATA_PATH, "DICOMDIR") + fileName = os.path.join(GDCM_DATA_ROOT, "DICOMDIR") try: printLevel = int(sys.argv[2]) diff --git a/gdcmPython/demo/PrintHeader.py.in b/gdcmPython/demo/PrintHeader.py.in index 6b7ca530..74d4b4ee 100644 --- a/gdcmPython/demo/PrintHeader.py.in +++ b/gdcmPython/demo/PrintHeader.py.in @@ -14,7 +14,7 @@ from gdcmPython.core import * try: fileName = sys.argv[1] except IndexError: - fileName = os.path.join(GDCM_DATA_PATH, "test.acr") + fileName = os.path.join(GDCM_DATA_ROOT, "test.acr") try: printLevel = int(sys.argv[2]) diff --git a/gdcmPython/demo/vtkGdcmReader.py.in b/gdcmPython/demo/vtkGdcmReader.py.in index 70670b2b..587165c0 100644 --- a/gdcmPython/demo/vtkGdcmReader.py.in +++ b/gdcmPython/demo/vtkGdcmReader.py.in @@ -16,7 +16,7 @@ from vtkpython import * try: fileName = sys.argv[1] except IndexError: - fileName = os.path.join(GDCM_DATA_PATH, "test.acr") + fileName = os.path.join(GDCM_DATA_ROOT, "test.acr") # read the image reader = vtkGdcmReader() diff --git a/gdcmPython/demo/vtkGdcmWriter.py.in b/gdcmPython/demo/vtkGdcmWriter.py.in index 845243f7..5a9249ce 100644 --- a/gdcmPython/demo/vtkGdcmWriter.py.in +++ b/gdcmPython/demo/vtkGdcmWriter.py.in @@ -15,7 +15,7 @@ from vtkpython import * try: fileName = sys.argv[1] except IndexError: - fileName = os.path.join(GDCM_DATA_PATH, "test.acr") + fileName = os.path.join(GDCM_DATA_ROOT, "test.acr") # read the image reader = vtkGdcmReader() diff --git a/gdcmPython/gdcmVersion.py b/gdcmPython/gdcmVersion.py deleted file mode 100644 index c99e46de..00000000 --- a/gdcmPython/gdcmVersion.py +++ /dev/null @@ -1,2 +0,0 @@ -gdcmVERSION="0.4.1" - diff --git a/gdcmPython/setup.py.in b/gdcmPython/setup.py.in deleted file mode 100644 index 50ee836b..00000000 --- a/gdcmPython/setup.py.in +++ /dev/null @@ -1,97 +0,0 @@ -#!/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']) ], - ) - -- 2.45.1