+2005-01-19 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+ * gdcmPython/ : change GDCM_DATA_PATH to GDCM_DATA_ROOT to be complient with
+ all in gdcm
+
2005-01-19 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
* Test/ : rename VTK tests to have a best name for the tests
* gdcmPython/demo/*.py.in : Change the InitTraversal/GetNextEntry use to
# 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:
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)
" 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)
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/
+
+++ /dev/null
-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()
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])
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])
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()
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()
+++ /dev/null
-gdcmVERSION="0.4.1"
-
+++ /dev/null
-#!/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']) ],
- )
-