aboutsummaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2019-01-15 12:21:24 +0000
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2019-01-15 12:21:24 +0000
commitd1ddd504802072d930170b802d2cf98fb309cd46 (patch)
tree2421ba88a37d686eca467cf85960ab7da4ae991a /setup.py
parentMove wrapper to better folder structure (diff)
downloadpygensvm-d1ddd504802072d930170b802d2cf98fb309cd46.tar.gz
pygensvm-d1ddd504802072d930170b802d2cf98fb309cd46.zip
Code formatting with Black
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py99
1 files changed, 55 insertions, 44 deletions
diff --git a/setup.py b/setup.py
index c70b81d..7f6e5e0 100644
--- a/setup.py
+++ b/setup.py
@@ -8,10 +8,10 @@ import re
# to build extensions from the C file (that was previously generated usingĀ·
# Cython). Set it to 'auto' to build with Cython if available, otherwise fromĀ·
# the C file.
-USE_CYTHON = 'auto'
+USE_CYTHON = "auto"
# If we are in a release, we always never use Cython directly
-IS_RELEASE = os.path.exists('PKG-INFO')
+IS_RELEASE = os.path.exists("PKG-INFO")
if IS_RELEASE:
USE_CYTHON = False
@@ -20,11 +20,12 @@ if USE_CYTHON:
try:
from Cython.Build import cythonize
except ImportError:
- if USE_CYTHON == 'auto':
+ if USE_CYTHON == "auto":
USE_CYTHON = False
else:
raise
+
def _skl_get_blas_info():
"""Copyright notice for this function
@@ -62,7 +63,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
@@ -74,54 +75,59 @@ def _skl_get_blas_info():
return True
return False
- blas_info = get_info('blas_opt', 0)
+ blas_info = get_info("blas_opt", 0)
if (not blas_info) or atlas_not_found(blas_info):
- cblas_libs = ['cblas']
- blas_info.pop('libraries', None)
+ cblas_libs = ["cblas"]
+ blas_info.pop("libraries", None)
else:
- cblas_libs = blas_info.pop('libraries', [])
+ cblas_libs = blas_info.pop("libraries", [])
return cblas_libs, blas_info
def configuration():
from numpy.distutils.misc_util import Configuration
- config = Configuration('gensvm', '', None)
+
+ config = Configuration("gensvm", "", None)
cblas_libs, blas_info = _skl_get_blas_info()
- if os.name == 'posix':
- cblas_libs.append('m')
+ if os.name == "posix":
+ cblas_libs.append("m")
- # Wrapper code in Cython uses the .pyx extension if we want to USE_CYTHON,
+ # Wrapper code in Cython uses the .pyx extension if we want to USE_CYTHON,
# otherwise it ends in .c.
wrapper_extension = "*.pyx" if USE_CYTHON else "*.c"
- # Sources include the C/Cython code from the wrapper and the source code of
+ # Sources include the C/Cython code from the wrapper and the source code of
# the C library
gensvm_sources = [
os.path.join("gensvm", "cython_wrapper", wrapper_extension),
os.path.join("src", "gensvm", "src", "*.c"),
]
- # Dependencies are the header files of the C library and any potential
+ # Dependencies are the header files of the C library and any potential
# helper code between the library and the Cython code
gensvm_depends = [
- os.path.join('src', 'gensvm', 'include', '*.h'),
- os.path.join('src', 'gensvm', 'gensvm_helper.c')
- ]
+ os.path.join("src", "gensvm", "include", "*.h"),
+ os.path.join("src", "gensvm", "gensvm_helper.c"),
+ ]
from numpy import get_include
- config.add_extension('cython_wrapper.wrapper',
- sources=gensvm_sources,
- libraries=cblas_libs,
- include_dirs=[
- os.path.join('src', 'gensvm'),
- os.path.join('src', 'gensvm', 'include'),
- get_include(),
- blas_info.pop('include_dirs', [])],
- extra_compile_args=blas_info.pop('extra_compile_args', []),
- depends=gensvm_depends,
- **blas_info)
+
+ config.add_extension(
+ "cython_wrapper.wrapper",
+ sources=gensvm_sources,
+ libraries=cblas_libs,
+ include_dirs=[
+ os.path.join("src", "gensvm"),
+ os.path.join("src", "gensvm", "include"),
+ get_include(),
+ blas_info.pop("include_dirs", []),
+ ],
+ extra_compile_args=blas_info.pop("extra_compile_args", []),
+ depends=gensvm_depends,
+ **blas_info
+ )
# Cythonize if necessary
if USE_CYTHON:
@@ -135,35 +141,40 @@ def read(fname):
def check_requirements():
- numpy_instructions = ("Numerical Python (NumPy) is not installed on your "
- "system. This package is required for GenSVM. Please install "
- "NumPy using the instructions available here: "
- "https://docs.scipy.org/doc/numpy-1.13.0/user/install.html")
+ numpy_instructions = (
+ "Numerical Python (NumPy) is not installed on your "
+ "system. This package is required for GenSVM. Please install "
+ "NumPy using the instructions available here: "
+ "https://docs.scipy.org/doc/numpy-1.13.0/user/install.html"
+ )
try:
import numpy
+
numpy_version = numpy.__version__
except ImportError:
raise ImportError(numpy_instructions)
-if __name__ == '__main__':
+if __name__ == "__main__":
check_requirements()
- version = re.search("__version__ = '([^']+)'",
- open('gensvm/__init__.py').read()).group(1)
+ version = re.search(
+ "__version__ = \"([^']+)\"", open("gensvm/__init__.py").read()
+ ).group(1)
attr = configuration().todict()
- attr['version'] = version
- attr['description'] = 'Python package for the GenSVM classifier'
- 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', 'scipy']
+ attr["version"] = version
+ attr["description"] = "Python package for the GenSVM classifier"
+ 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", "scipy"]
from numpy.distutils.core import setup
+
setup(**attr)