### Install python-gdcm from local source Source: https://github.com/tfmoraes/python-gdcm/blob/master/README.md Installs the python-gdcm package after cloning the source code, using pip. This command builds and installs the library from the local repository. ```bash pip install python-gdcm/ ``` -------------------------------- ### Install python-gdcm using pip Source: https://github.com/tfmoraes/python-gdcm/blob/master/README.md Installs or upgrades the python-gdcm package from PyPI using pip. This is the recommended method for most users. ```bash pip install -U python-gdcm ``` -------------------------------- ### Test GDCM version in Python Source: https://github.com/tfmoraes/python-gdcm/blob/master/README.md Tests if the GDCM library is correctly installed and accessible in Python by printing the GDCM version. It also provides a troubleshooting tip for a common import error. ```python import gdcm print(gdcm.GDCM_VERSION) ``` -------------------------------- ### Project Build Configuration Source: https://github.com/tfmoraes/python-gdcm/blob/master/CMakeLists.txt This CMake script sets up the build environment for the python-gdcm project. It defines project languages, configures build options for applications, documentation, and shared libraries based on the operating system. It also handles finding and configuring Python and OpenSSL dependencies, setting installation paths, and applying platform-specific linker flags for macOS and Linux. ```CMake cmake_minimum_required(VERSION 3.9.2 FATAL_ERROR) project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX C) include(CMakePrintHelpers) set(GDCM_BUILD_APPLICATIONS ON) set(GDCM_DOCUMENTATION OFF) set(GDCM_BUILD_DOCBOOK_MANPAGES OFF) if(WIN32) set(GDCM_BUILD_SHARED_LIBS OFF) else() set(GDCM_BUILD_SHARED_LIBS ON) endif(WIN32) if(LINUX) set(PYTHON_LIBRARY "MANOLO") endif(LINUX) find_package( Python COMPONENTS Interpreter Development.Module REQUIRED) set(GDCM_WRAP_PYTHON ON) set(GDCM_NO_PYTHON_LIBS_LINKING ON) set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}") set(GDCM_USE_SYSTEM_OPENSSL ON) # SET(PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIR}") SET(PYTHON_LIBRARY # "${Python_LIBRARIES}") # cmake_print_variables(Python_EXECUTABLE) # cmake_print_variables(Python_INCLUDE_DIR) # cmake_print_variables(Python_LIBRARIES) # cmake_print_variables(SKBUILD_HEADERS_DIR) # cmake_print_variables(SKBUILD_DATA_DIR) # cmake_print_variables(SKBUILD_SCRIPTS_DIR) # cmake_print_variables(CMAKE_INSTALL_BINDIR) set(GDCM_INSTALL_BIN_DIR ${SKBUILD_PLATLIB_DIR}/_gdcm) set(GDCM_INSTALL_LIB_DIR ${SKBUILD_PLATLIB_DIR}/_gdcm) set(GDCM_INSTALL_DATA_DIR ${SKBUILD_PLATLIB_DIR}/_gdcm) set(GDCM_INSTALL_INCLUDE_DIR ${SKBUILD_NULL_DIR}) set(GDCM_INSTALL_PACKAGE_DIR ${SKBUILD_NULL_DIR}) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_SKIP_INSTALL_RPATH FALSE) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE) if(APPLE) set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -undefined dynamic_lookup -liconv") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup -liconv") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -undefined dynamic_lookup -liconv") set(CMAKE_INSTALL_RPATH "@loader_path") set(CMAKE_BUILD_RPATH "@loader_path") elseif(LINUX) set(CMAKE_INSTALL_RPATH "$ORIGIN") endif() add_subdirectory(gdcm_src) ``` -------------------------------- ### Clone python-gdcm source code Source: https://github.com/tfmoraes/python-gdcm/blob/master/README.md Clones the python-gdcm repository from GitHub, including submodules, to build from source. This command fetches the project's source code and its dependencies. ```bash git clone --recurse-submodules https://github.com/tfmoraes/python-gdcm ``` -------------------------------- ### Set GDCM build environment variables Source: https://github.com/tfmoraes/python-gdcm/blob/master/README.md Sets environment variables for CMake and SWIG executables if they are not in the system's PATH. This is necessary when building python-gdcm from source on Linux. ```bash export CMAKE_EXE="path/to/cmake/executable" export SWIG_EXE="path/to/swig/executable" ``` -------------------------------- ### Read DICOM image file in Python Source: https://github.com/tfmoraes/python-gdcm/blob/master/README.md Demonstrates how to read a DICOM image file using the gdcm.ImageReader class. It checks the return value of the Read() method to confirm successful file parsing. ```python import gdcm reader = gdcm.ImageReader() reader.SetFileName("dicom_image_file.dcm") ret = reader.Read() if not ret: print("It was not possible to read your DICOM file") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.