#!/usr/bin/env python

from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup, Extension
import subprocess, os, sys
from os.path import join, dirname

PROJECT = 'dippy'
VERSION = '1.9.1'
URL = 'https://projects.coin-or.org/Dip/wiki/Dippy'
AUTHOR_EMAIL = u''
DESC = 'DIP Python Interface'

coin_install_dir = os.environ['COIN_INSTALL_DIR']

def read_file(file_name):

    file_path = join(
        dirname(__file__),
        file_name
        )

    return open(file_path).read()

def get_libs(dir):
    '''
    Return a list of distinct library names used by ``dependencies``.
    '''
    with open(join(dir, 'share', 'coin',
                   'doc', 'Dip', 'dip_addlibs.txt')) as f:
        link_line = f.read()
        if operatingSystem == 'windows':
            libs = [flag[:-4] for flag in link_line.split() if
                    flag.endswith('.lib')]
        else:
            libs = [flag[2:] for flag in link_line.split() if
                    flag.startswith('-l')]
    return libs

operatingSystem = sys.platform
if 'linux' in operatingSystem:
    operatingSystem = 'linux'
elif 'darwin' in operatingSystem:
    operatingSystem = 'mac'
elif 'win' in operatingSystem:
    operatingSystem = 'windows'

try:
    coin_install_dir = os.environ['COIN_INSTALL_DIR']
except KeyError:
    raise Exception('Please set the environment variable COIN_INSTALL_DIR' +
                    'to the location of the COIN installation')

if len(coin_install_dir.split(';')) > 1:
    raise Exception('Error: More than one directory listed in COIN_INSTALL_DIR')

libraries = get_libs(coin_install_dir)

macros = [('__DECOMP_LP_CLP__', None)]

files = ['DippyDecompAlgo.cpp',
         'DippyDecompApp.cpp',
         'DippySolve.cpp',
         'DippyModule.cpp',
         'DippyPythonUtils.cpp',
         ]

sources = [join('src/dippy', f) for f in files]

lib_dirs = [join(coin_install_dir, 'lib', 'intel'),
            join(coin_install_dir, 'lib')]

modules=[Extension('_dippy', 
                   sources, 
                   libraries=libraries,
                   include_dirs=[join(coin_install_dir, 'include', 'coin')],
                   library_dirs=lib_dirs,
                   define_macros=macros)]

setup(name=PROJECT,
      version=VERSION,
      description=DESC,
      long_description=read_file('README.rst'),
      author=read_file('AUTHORS'),
      author_email=AUTHOR_EMAIL,
      url=URL,
      license=read_file('LICENSE'),
#      namespace_packages=['coinor'],
      packages=['dippy'],
      package_dir = {'': 'src'},
      install_requires=['coinor.pulp','coinor.gimpy'],
      ext_modules=modules
     )



@@ -1017,16 +1017,368 @@
 n libs%0A%0A
+def get_lib_dirs(dir):%0A    '''%0A    Return a list of distinct library names used by %60%60dependencies%60%60.%0A    '''%0A    with open(join(dir, 'share', 'coin',%0A                   'doc', 'Dip', 'dip_addlibs.txt')) as f:%0A        link_line = f.read()%0A        libs = %5Bflag%5B2:%5D for flag in link_line.split() if%0A                flag.startswith('-L')%5D%0A    return libs%0A%0A
 operatin
@@ -2235,61 +2235,139 @@
 s = 
-%5Bjoin(coin_install_dir, 'lib', 'intel'),%0A            
+get_lib_dirs(coin_install_dir)%0Alib_dirs.append(join(coin_install_dir, 'lib'))%0Aif operatingSystem is 'windows':%0A    lib_dirs.append(
 join
@@ -2390,18 +2390,27 @@
 r, 'lib'
+, 'intel')
 )
-%5D
 %0A%0Amodule

Fix to setup.py