2

I'm using GDCM in my project in a Python 2.7 environment. As more is moving towards Python 3 I would like to install the python-gdcm for Python 3. The package uses SWIG to generate the interface and it should support Python 3. There also is a Fedora package available that does this.

My guess is that a simple modification to the dsc-file should do it but I have never worked with dsc-files and I'm not certain of even where to start. I can't even find where the Python 3 environment should be enforced in the file. I've found the pbuilder wiki(alt. sbuild) that does seem to be the place to start but I would greatly appreciate if someone here had some concrete tips on how to get this working.

Update

I managed to get the sources using:

apt source python-gdcm

From what I understand by looking at the gdcm-2.6.3/debian/python-gdcm.install it should copy the files into any /usr/lib/python* version. One thing that I'm a little confused about is that the /usr/lib/python3.5/ doesn't have a dist-packages directory while the /usr/lib/python2.7/ does. Instead Python 3's dist-packages are located under /usr/lib/python3/ - not sure though if this matters. I've tried just copying the files into the Python 3 dist-packages directory but this only caused a segfault when importing the package.

Building from source - update

So I've encountered a bug that has prompted me to build the package from source. The bug was fixed using the new version and I was able to compile that package so that it loads in a Python 3 console:

  1. Clone the git repo:

git clone --branch release git://git.code.sf.net/p/gdcm/gdcm

  1. Then install the dependencies for building:

sudo apt-get build-dep python-gdcm

  1. A few additional dependencies were needed before everything clicked:

sudo apt install python-vtk6 libvtk6-dev cmake-curses-gui

  1. Using the ccmake and setting GDCM_WRAP_PYTHON to ON and the library GDCM_BUILD_SHARED_LIBS to ON† the configure works and the library can be compiled with Python support.

  2. Use the toggle section to get to the advanced section and set the Python paths to match Python 3 settings, using pure cmake the call is: cmake GDCM_WRAP_PYTHON=ON PYTHON_EXECUTABLE=/user/bin/python3 PYTHON_INCLUDE_DIR=/usr/include/python3.5 GDCM_BUILD_SHARED_LIBS=ON GDCM_USE_VTK=ON ../gdcm

  3. The package can then be installed via checkinstall.

  4. The python files (gdcm.py, gdcmswig.py, vtkgdcm.py and _gdcmswig.so) ended up in /usr/local/lib and need to be manually copied to the /usr/local/lib/python3.5/dist-packages before the package can be loaded. Note before loading do an ldconfig to update the links.

My remaining questions:

  • What should I modify in the debian-folder in order to enter the above cmake settings?
  • Is there a way to make both Python 2 and Python 3 available simultaneously? I know plenty of packages that provide both so this should be trivial to add although a re-compilation will probably be required, or?
  • Why doesn't the cmake detect the correct Python folder, i.e. /usr/local/lib/python3.5/dist-packages? Is this a bug in the cmake files or is it some setting that I'm missing?

† Not using the shared libs caused this error:

 CMake Error at Utilities/VTK/CMakeLists.txt:796 (install):
   install TARGETS given no ARCHIVE DESTINATION for static library target
   "vtkgdcmPythonD".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.