-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from mckib2/linprog-bounds
Bounds/Tolerances/input checking
- Loading branch information
Showing
3 changed files
with
128 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,47 @@ | ||
'''Install scikit-glpk bindings.''' | ||
|
||
from setuptools import find_packages | ||
import pathlib | ||
from distutils.core import Extension, setup | ||
from distutils.command.build_ext import build_ext as _build_ext | ||
import pathlib | ||
from setuptools import find_packages | ||
|
||
GLPK_SRC_DIR = pathlib.Path('glpk-4.65/src') | ||
|
||
|
||
def scrape_makefile_list(filename, START_TOKEN, END_TOKEN): | ||
'''Grab tags from GLPK makefile.''' | ||
with open(str(filename), 'r', encoding='utf-8') as f: | ||
_contents = f.read() | ||
sidx = _contents.find(START_TOKEN) | ||
eidx = _contents.find(END_TOKEN) | ||
lines = _contents[sidx+len(START_TOKEN):eidx].splitlines() | ||
return [str(_l.replace('\\', '').strip()) for _l in lines] | ||
|
||
|
||
class build_ext(_build_ext): | ||
'''Overide get_export_symbols to provide them for Windows DLL.''' | ||
def get_export_symbols(self, ext): | ||
'''Only for generating Windows DLL.''' | ||
def_file = GLPK_SRC_DIR / '../w64/glpk_4_65.def' | ||
return scrape_makefile_list(def_file, 'EXPORTS\n', ';; end of file ;;') | ||
|
||
|
||
# Get sources for GLPK | ||
makefile = GLPK_SRC_DIR / 'Makefile.am' | ||
sources = scrape_makefile_list(makefile, 'libglpk_la_SOURCES = \\\n', '\n## eof ##') | ||
sources = scrape_makefile_list( | ||
makefile, 'libglpk_la_SOURCES = \\\n', '\n## eof ##') | ||
sources = [str(GLPK_SRC_DIR / _s) for _s in sources] | ||
|
||
# Get include dirs for GLPK | ||
include_dirs = scrape_makefile_list(makefile, 'libglpk_la_CPPFLAGS = \\\n', '\nlibglpk_la_LDFLAGS') | ||
include_dirs = [str(GLPK_SRC_DIR / _d[len('-I($srcdir)/'):]) for _d in include_dirs] | ||
include_dirs = scrape_makefile_list( | ||
makefile, 'libglpk_la_CPPFLAGS = \\\n', '\nlibglpk_la_LDFLAGS') | ||
include_dirs = [ | ||
str(GLPK_SRC_DIR / _d[len('-I($srcdir)/'):]) for _d in include_dirs] | ||
|
||
|
||
setup( | ||
name='scikit-glpk', | ||
version='0.1.4', | ||
version='0.2.1', | ||
author='Nicholas McKibben', | ||
author_email='[email protected]', | ||
url='https://github.com/mckib2/scikit-glpk', | ||
|