aboutsummaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py163
1 files changed, 145 insertions, 18 deletions
diff --git a/setup.py b/setup.py
index ff6b0a9..5738dc4 100644
--- a/setup.py
+++ b/setup.py
@@ -3,6 +3,32 @@
import os
import re
+import sys
+
+# Package meta-data
+AUTHOR = "Gertjan van den Burg"
+DESCRIPTION = "Generalized Multiclass Support Vector Machines"
+EMAIL = "gertjanvandenburg@gmail.com"
+LICENSE = "GPLv2"
+LICENSE_TROVE = (
+ "License :: OSI Approved :: GNU General Public License v2 (GPLv2)"
+)
+NAME = "gensvm"
+REQUIRES_PYTHON = ">=2.7"
+URL = "https://github.com/GjjvdBurg/PyGenSVM"
+VERSION = None
+
+REQUIRED = ["scikit-learn", "numpy"]
+
+docs_require = ["Sphinx==1.6.5", "sphinx_rtd_theme>=0.4.3"]
+test_require = []
+dev_require = ["Cython"]
+
+EXTRAS = {
+ "docs": docs_require,
+ "tests": test_require,
+ "dev": docs_require + test_require + dev_require,
+}
# Set this to True to enable building extensions using Cython. Set it to FalseĀ·
# to build extensions from the C file (that was previously generated usingĀ·
@@ -10,7 +36,7 @@ import re
# the C file.
USE_CYTHON = "auto"
-# If we are in a release, we always never use Cython directly
+# If we are in a release, we never use Cython directly
IS_RELEASE = os.path.exists("PKG-INFO")
if IS_RELEASE:
USE_CYTHON = False
@@ -25,15 +51,30 @@ if USE_CYTHON:
else:
raise
-# Try to load setuptools, so that NumPy's distutils module that we use to
-# provide the setup() function below comes from the setuptools package. If it
-# fails, it'll use distutils' version, which doesn't support installing
+# Try to load setuptools, so that NumPy's distutils module that we use to
+# provide the setup() function below comes from the setuptools package. If it
+# fails, it'll use distutils' version, which doesn't support installing
# dependencies.
try:
- import setuptools
+ import setuptools
except ImportError:
- print("Warning: setuptools not found. You may have to install GenSVM's dependencies manually.")
+ print(
+ "Warning: setuptools not found. You may have to install GenSVM's dependencies manually."
+ )
+
+def on_cibw_win():
+ return (
+ os.environ.get("CIBUILDWHEEL", "0") == "1"
+ and os.environ.get("TRAVIS_OS_NAME", "none") == "windows"
+ )
+
+
+def on_cibw_mac():
+ return (
+ os.environ.get("CIBUILDWHEEL", "0") == "1"
+ and os.environ.get("TRAVIS_OS_NAME", "none") == "osx"
+ )
def _skl_get_blas_info():
@@ -73,7 +114,7 @@ def _skl_get_blas_info():
from numpy.distutils.system_info import get_info
def atlas_not_found(blas_info_):
- def_macros = blas_info.get("define_macros", [])
+ def_macros = blas_info_.get("define_macros", [])
for x in def_macros:
if x[0] == "NO_ATLAS_INFO":
# if x[1] != 1 we should have lapack
@@ -85,13 +126,59 @@ def _skl_get_blas_info():
return True
return False
- blas_info = get_info("blas_opt", 0)
+ if on_cibw_win():
+ blas_info = get_info("blas_opt", notfound_action=0)
+ blas_info = {
+ "define_macros": [("NO_ATLAS_INFO", 1), ("HAVE_CBLAS", None)],
+ "library_dirs": [
+ os.sep.join(
+ [
+ "C:",
+ "cibw",
+ "openblas",
+ "OpenBLAS.0.2.14.1",
+ "lib",
+ "native",
+ "lib",
+ ]
+ )
+ ],
+ "include_dirs": [
+ os.sep.join(
+ [
+ "C:",
+ "cibw",
+ "openblas",
+ "OpenBLAS.0.2.14.1",
+ "lib",
+ "native",
+ "include",
+ ]
+ )
+ ],
+ "language": "c",
+ }
+ return ["libopenblas"], blas_info
+
+ blas_info = get_info("blas_opt", notfound_action=2)
if (not blas_info) or atlas_not_found(blas_info):
cblas_libs = ["cblas"]
blas_info.pop("libraries", None)
else:
cblas_libs = blas_info.pop("libraries", [])
+ if os.environ.get("TRAVIS_OS_NAME", "none") == "osx":
+ libdir = blas_info.get("library_dirs", [])
+ libdir = libdir[0] if libdir else None
+ if libdir:
+ base = os.path.split(libdir)[0]
+ blas_info["include_dirs"] = [os.path.join(base, "include")]
+
+ if on_cibw_mac():
+ blas_info["include_dirs"] = [
+ "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/"
+ ]
+
return cblas_libs, blas_info
@@ -100,7 +187,7 @@ def get_lapack_info():
from numpy.distutils.system_info import get_info
def atlas_not_found(lapack_info_):
- def_macros = lapack_info.get("define_macros", [])
+ def_macros = lapack_info_.get("define_macros", [])
for x in def_macros:
if x[0] == "NO_ATLAS_INFO":
return True
@@ -109,9 +196,45 @@ def get_lapack_info():
return True
return False
- lapack_info = get_info("lapack_opt", 0)
+ if on_cibw_win():
+ lapack_info = get_info("lapack_opt", notfound_action=0)
+ lapack_info = {
+ "define_macros": [("NO_ATLAS_INFO", 1), ("HAVE_CBLAS", None)],
+ "library_dirs": [
+ os.sep.join(
+ [
+ "C:",
+ "cibw",
+ "openblas",
+ "OpenBLAS.0.2.14.1",
+ "lib",
+ "native",
+ "lib",
+ ]
+ )
+ ],
+ "include_dirs": [
+ os.sep.join(
+ [
+ "C:",
+ "cibw",
+ "openblas",
+ "OpenBLAS.0.2.14.1",
+ "lib",
+ "native",
+ "include",
+ ]
+ )
+ ],
+ "language": "c",
+ }
+ print("***\nDefined lapack info: %r" % lapack_info)
+ return ["libopenblas"], lapack_info
+
+ lapack_info = get_info("lapack_opt", notfound_action=2)
+
if (not lapack_info) or atlas_not_found(lapack_info):
- # This is a guess, but seems to work in practice. Need more systems to
+ # This is a guess, but seems to work in practice. Need more systems to
# test this fully.
lapack_libs = ["lapack"]
lapack_info.pop("libraries", None)
@@ -182,6 +305,9 @@ def read(fname):
def check_requirements():
numpy_instructions = (
+ "\n"
+ "GenSVM Installation Error:"
+ "\n"
"Numerical Python (NumPy) is not installed on your "
"system. This package is required for GenSVM. Please install "
"NumPy using the instructions available here: "
@@ -206,14 +332,15 @@ if __name__ == "__main__":
attr = configuration().todict()
attr["version"] = version
- attr["description"] = "Python package for the GenSVM classifier"
+ attr["description"] = DESCRIPTION
attr["long_description"] = read("README.rst")
- attr["packages"] = ["gensvm"]
- attr["url"] = "https://github.com/GjjvdBurg/PyGenSVM"
- attr["author"] = "G.J.J. van den Burg"
- attr["author_email"] = "gertjanvandenburg@gmail.com"
- attr["license"] = "GPL v2"
- attr["install_requires"] = ["scikit-learn", "numpy"]
+ attr["packages"] = [NAME]
+ attr["url"] = URL
+ attr["author"] = AUTHOR
+ attr["author_email"] = EMAIL
+ attr["license"] = LICENSE
+ attr["install_requires"] = REQUIRED
+ attr["extras_require"] = EXTRAS
from numpy.distutils.core import setup