spack/var/spack/repos/builtin/packages/openbabel/python-3.6-rtld-global.patch
Adam J. Stewart 48588cb1d8 Add a new package for Open Babel (#4256)
* Add a new package for Open Babel

* Add post-installation tests, stolen from the fine folks at Homebrew

* Add patch to fix Python 3.6 support

* Add a more complete patch to get Python 3.6 support working

* Add patch to convert tabs to spaces in test script

testpdbformat.py contains mixed tabs and spaces
causing the unit tests to fail. With this patch,
all tests pass with flying colors.
2017-05-18 10:06:44 -05:00

43 lines
2.5 KiB
Diff

The DLFCN module has been removed from python 3.6, as it is not
documented. Same funtionality can be achive with the os module
that makes available the os.RTLD_GLOBAL variable for dlopen()
See https://github.com/openbabel/openbabel/pull/372 for the
source of this patch. The original patch only affects the CMake
file that SWIG uses to generate openbabel.py. This patch also
includes changes to openbabel.py.
diff -Nuar a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
--- a/scripts/CMakeLists.txt 2017-05-17 10:02:54.408527942 -0500
+++ b/scripts/CMakeLists.txt 2017-05-17 10:04:09.701598715 -0500
@@ -81,11 +81,8 @@
COMMAND ${SWIG_EXECUTABLE} -python -c++ -small -O -templatereduce -naturalvar -I${openbabel_SOURCE_DIR}/include -I${openbabel_BINARY_DIR}/include -o ${openbabel_SOURCE_DIR}/scripts/python/openbabel-python.cpp ${eigen_define} -outdir ${openbabel_SOURCE_DIR}/scripts/python ${openbabel_SOURCE_DIR}/scripts/openbabel-python.i
COMMAND ${CMAKE_COMMAND} -E echo "import sys" > ob.py
COMMAND ${CMAKE_COMMAND} -E echo "if sys.platform.find('linux'\) != -1:" >> ob.py
- COMMAND ${CMAKE_COMMAND} -E echo " try:" >> ob.py
- COMMAND ${CMAKE_COMMAND} -E echo " import dl" >> ob.py
- COMMAND ${CMAKE_COMMAND} -E echo " except ImportError:" >> ob.py
- COMMAND ${CMAKE_COMMAND} -E echo " import DLFCN as dl" >> ob.py
- COMMAND ${CMAKE_COMMAND} -E echo " sys.setdlopenflags(sys.getdlopenflags() | dl.RTLD_GLOBAL)" >> ob.py
+ COMMAND ${CMAKE_COMMAND} -E echo " import os" >> ob.py
+ COMMAND ${CMAKE_COMMAND} -E echo " sys.setdlopenflags(sys.getdlopenflags() | os.RTLD_GLOBAL)" >> ob.py
COMMAND cat ${openbabel_SOURCE_DIR}/scripts/python/openbabel.py >> ob.py
COMMAND ${CMAKE_COMMAND} -E copy ob.py ${openbabel_SOURCE_DIR}/scripts/python/openbabel.py
COMMAND ${CMAKE_COMMAND} -E remove ob.py
diff -Nuar a/scripts/python/openbabel.py b/scripts/python/openbabel.py
--- a/scripts/python/openbabel.py 2017-05-17 10:02:54.398527534 -0500
+++ b/scripts/python/openbabel.py 2017-05-17 10:04:26.705292138 -0500
@@ -1,10 +1,7 @@
import sys
if sys.platform.find('linux') != -1:
- try:
- import dl
- except ImportError:
- import DLFCN as dl
- sys.setdlopenflags(sys.getdlopenflags() | dl.RTLD_GLOBAL)
+ import os
+ sys.setdlopenflags(sys.getdlopenflags() | os.RTLD_GLOBAL)
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.10
#