2005-12-15 17:06:02 +00:00
|
|
|
#!/usr/bin/env python
|
2005-11-18 00:53:15 +00:00
|
|
|
from distutils.core import *
|
2005-12-15 17:06:02 +00:00
|
|
|
import os,sys
|
2005-11-18 00:53:15 +00:00
|
|
|
|
2005-12-15 17:06:02 +00:00
|
|
|
def find_likely_directory():
|
2005-12-16 11:18:14 +00:00
|
|
|
"""Find (guess!) where Open Babel is installed.
|
2005-11-18 00:53:15 +00:00
|
|
|
|
2005-12-15 17:06:02 +00:00
|
|
|
Order of precedence is:
|
2006-03-14 00:47:39 +00:00
|
|
|
$OPENBABEL_INSTALL > ../../src > /usr/local > /usr
|
2005-12-15 17:06:02 +00:00
|
|
|
"""
|
2005-12-16 11:18:14 +00:00
|
|
|
name = os.environ.get("OPENBABEL_INSTALL")
|
|
|
|
|
if name: # OPENBABEL_INSTALL is set
|
|
|
|
|
sys.stderr.write("INFO: Using the value of $OPENBABEL_INSTALL (%s)\n" % name)
|
2005-12-15 17:06:02 +00:00
|
|
|
if not os.path.isdir(name):
|
2005-12-16 11:18:14 +00:00
|
|
|
sys.stderr.write("ERROR: $OPENBABEL_INSTALL (%s) is not a directory\n" % name)
|
|
|
|
|
else:
|
|
|
|
|
return ([name+"/include/openbabel-2.0",name+"/include/openbabel-2.0/openbabel"],
|
|
|
|
|
[name+"/lib/openbabel"])
|
2005-12-15 17:06:02 +00:00
|
|
|
|
2005-12-16 11:18:14 +00:00
|
|
|
else: # OPENBABEL_INSTALL is not set
|
|
|
|
|
sys.stderr.write("WARNING: Environment variable OPENBABEL_INSTALL is not set\n")
|
2006-03-14 00:47:39 +00:00
|
|
|
sys.stderr.write("INFO: Looking for library and include files in ../../src\n")
|
|
|
|
|
if os.path.isfile("../../src/atom.o"):
|
|
|
|
|
return ["../../src"],["../../src"]
|
|
|
|
|
|
2005-12-16 11:18:14 +00:00
|
|
|
for dirname in ["/usr/local","/usr"]:
|
|
|
|
|
# Look for each of these directories in turn for the directory include/openbabel-2.0
|
|
|
|
|
# (This is version specific, so I may do as Andrew Dalke did for PyDaylight and use
|
|
|
|
|
# a regular expression to find the latest version of openbabel)
|
|
|
|
|
if os.path.isdir(dirname+"/include/openbabel-2.0"):
|
|
|
|
|
sys.stderr.write("INFO: Setting OPENBABEL_INSTALL to %s\n" % dirname)
|
|
|
|
|
return ([dirname+"/include/openbabel-2.0",dirname+"/include/openbabel-2.0/openbabel"],
|
|
|
|
|
[dirname+"/lib/openbabel"])
|
|
|
|
|
|
2005-12-15 17:06:02 +00:00
|
|
|
sys.stderr.write("ERROR: Cannot find Open Babel library directory\n")
|
2005-12-16 11:18:14 +00:00
|
|
|
return (None,None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OBinclude,OBlibrary = find_likely_directory()
|
|
|
|
|
|
2006-03-16 15:18:59 +00:00
|
|
|
obExtension = Extension('_openbabel',
|
2005-11-18 00:53:15 +00:00
|
|
|
['openbabel_python.cpp'],
|
2005-12-16 11:18:14 +00:00
|
|
|
include_dirs=OBinclude,
|
|
|
|
|
library_dirs=OBlibrary,
|
2005-11-18 00:53:15 +00:00
|
|
|
libraries=['openbabel']
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
setup(name='openbabel',
|
2006-03-14 00:47:39 +00:00
|
|
|
version='1.1.0',
|
2005-12-15 17:06:02 +00:00
|
|
|
description='Python interface to Open Babel',
|
2005-11-18 00:53:15 +00:00
|
|
|
author='Geoff Hutchison',
|
|
|
|
|
author_email='openbabel-scripting@lists.sourceforge.net',
|
|
|
|
|
url='http://openbabel.sourceforge.net/',
|
2006-02-21 09:33:24 +00:00
|
|
|
py_modules=['openbabel','pyopenbabel'],
|
2005-11-18 00:53:15 +00:00
|
|
|
ext_modules=[obExtension])
|