diff options
Diffstat (limited to 'var')
3 files changed, 169 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/openbabel/package.py b/var/spack/repos/builtin/packages/openbabel/package.py new file mode 100644 index 0000000000..014d1183f3 --- /dev/null +++ b/var/spack/repos/builtin/packages/openbabel/package.py @@ -0,0 +1,80 @@ +############################################################################## +# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/llnl/spack +# Please also see the LICENSE file for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## +from spack import * + + +class Openbabel(CMakePackage): + """Open Babel is a chemical toolbox designed to speak the many languages + of chemical data. It's an open, collaborative project allowing anyone to + search, convert, analyze, or store data from molecular modeling, chemistry, + solid-state materials, biochemistry, or related areas.""" + + homepage = "http://openbabel.org/wiki/Main_Page" + url = "https://sourceforge.net/projects/openbabel/files/openbabel/2.4.1/openbabel-2.4.1.tar.gz" + + version('2.4.1', 'd9defcd7830b0592fece4fe54a137b99') + + variant('python', default=True, description='Build Python bindings') + + extends('python', when='+python') + + depends_on('python', type=('build', 'run'), when='+python') + depends_on('cmake@2.4.8:', type='build') + depends_on('pkg-config', type='build') + depends_on('cairo') # required to support PNG depiction + depends_on('eigen@3.0:') # required if using the language bindings + depends_on('libxml2') # required to read/write CML files, XML formats + depends_on('zlib') # required to support reading gzipped files + + # Needed for Python 3.6 support + patch('python-3.6-rtld-global.patch', when='@:2.4.1+python') + + # Convert tabs to spaces. Allows unit tests to pass + patch('testpdbformat-tabs-to-spaces.patch', when='@:2.4.1') + + def cmake_args(self): + spec = self.spec + args = [] + + if '+python' in spec: + args.extend([ + '-DPYTHON_BINDINGS=ON', + '-DPYTHON_EXECUTABLE={0}'.format(spec['python'].command.path), + ]) + else: + args.append('-DPYTHON_BINDINGS=OFF') + + return args + + @run_after('install') + @on_package_attributes(run_tests=True) + def check_install(self): + obabel = Executable(join_path(self.prefix.bin, 'obabel')) + obabel('-:C1=CC=CC=C1Br', '-omol') + + if '+python' in self.spec: + # Attempt to import the Python modules + for module in ['openbabel', 'pybel']: + python('-c', 'import {0}'.format(module)) diff --git a/var/spack/repos/builtin/packages/openbabel/python-3.6-rtld-global.patch b/var/spack/repos/builtin/packages/openbabel/python-3.6-rtld-global.patch new file mode 100644 index 0000000000..68cd56a1f5 --- /dev/null +++ b/var/spack/repos/builtin/packages/openbabel/python-3.6-rtld-global.patch @@ -0,0 +1,42 @@ +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 + # diff --git a/var/spack/repos/builtin/packages/openbabel/testpdbformat-tabs-to-spaces.patch b/var/spack/repos/builtin/packages/openbabel/testpdbformat-tabs-to-spaces.patch new file mode 100644 index 0000000000..0a71a72e01 --- /dev/null +++ b/var/spack/repos/builtin/packages/openbabel/testpdbformat-tabs-to-spaces.patch @@ -0,0 +1,47 @@ +From 08cd38485d4cf1df8802da540f3018921dbc735e Mon Sep 17 00:00:00 2001 +From: "Adam J. Stewart" <ajstewart426@gmail.com> +Date: Wed, 17 May 2017 10:56:23 -0500 +Subject: [PATCH] Convert tabs to spaces in testpdbformat.py + +See https://github.com/openbabel/openbabel/pull/1568 + +--- + test/testpdbformat.py | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/test/testpdbformat.py b/test/testpdbformat.py +index 40bd316..ceb8496 100644 +--- a/test/testpdbformat.py ++++ b/test/testpdbformat.py +@@ -24,12 +24,12 @@ class TestPDBFormat(BaseTest): + + def testInsertionCodes(self): + """ +- Testing a PDB entry with insertion codes to distinguish residues +- upon conversion to FASTA. ++ Testing a PDB entry with insertion codes to distinguish residues ++ upon conversion to FASTA. + """ + self.canFindExecutable("babel") + +- self.entryPDBwithInsertioncodes="""ATOM 406 N VAL L 29 58.041 17.797 48.254 1.00 0.00 N ++ self.entryPDBwithInsertioncodes="""ATOM 406 N VAL L 29 58.041 17.797 48.254 1.00 0.00 N + ATOM 407 CA VAL L 29 57.124 18.088 47.170 1.00 0.00 C + ATOM 408 C VAL L 29 55.739 17.571 47.538 1.00 0.00 C + ATOM 409 O VAL L 29 55.535 16.362 47.550 1.00 0.00 O +@@ -100,9 +100,9 @@ ATOM 473 HE1 TYR L 32 48.512 15.775 42.066 1.00 0.00 H + ATOM 474 HE2 TYR L 32 48.145 19.172 44.648 1.00 0.00 H + ATOM 475 HH TYR L 32 46.462 17.658 44.280 1.00 0.00 H + """ +- output, error = run_exec(self.entryPDBwithInsertioncodes, +- "babel -ipdb -ofasta") +- self.assertEqual(output.rstrip().rsplit("\n",1)[1], "VSSSY") ++ output, error = run_exec(self.entryPDBwithInsertioncodes, ++ "babel -ipdb -ofasta") ++ self.assertEqual(output.rstrip().rsplit("\n",1)[1], "VSSSY") + + if __name__ == "__main__": + testsuite = [] +-- +2.9.4 + |