- # When environnement variable is unavailable assume the package was
- # properly installed i.e. the layout is such that the directory containing
- # the dictionaries is BELOW (the root is at the top) the current file.
- # Note: when importing this __init__ file the pathes are relative to the
- # invocation directory. In order to get them relative to the package
- # (or more simply to this file) we rely on the __path__ variable.
- InstallModePath = os.path.join(__path__[0], "Dicts/")
- if os.path.isfile(os.path.join(InstallModePath, "dicomV3.dic")):
- os.environ["GDCM_DICT_PATH"] = InstallModePath
- PreInstallModePath = None
- else:
- # When both environnement variable and proper package installation
- # strategy fail we eventually consider the pre-installation mode
- # i.e. when developpers are toying in a CVS tree. In this case
- # the layout is such that the directory containing the dictionaries is
- # ABOVE (the root is at the top) the current directory.
- PreInstallModePath = os.path.join(__path__[0], "..", "Dicts/")
- if os.path.isfile(os.path.join(PreInstallModePath, "dicomV3.dic")):
- os.environ["GDCM_DICT_PATH"] = PreInstallModePath
- InstallModePath = None
- else:
- print "Unfound gdcm dictionaries path"
- sys.exit(1)
-
-### Set up the path to the data images (for the test suite and the demo
-# examples). As for GDCM_DICT_PATH we offer both proper python package
-# installation scheme and the pre-install mode (see above).
-if InstallModePath:
- GDCM_DATA_PATH = os.path.join(__path__[0], "Data")
+ 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")