This repository has been archived by the owner on Apr 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.py
59 lines (56 loc) · 2.22 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
try:
from setuptools import setup
from setuptools import Extension
except:
from distutils.core import setup
from distutils.extension import Extension
import numpy as np, os
from findblas.distutils import build_ext_with_blas
from sys import platform
## https://stackoverflow.com/questions/724664/python-distutils-how-to-get-a-compiler-that-is-going-to-be-used
class build_ext_subclass( build_ext_with_blas ):
def build_extensions(self):
from_rtd = os.environ.get('READTHEDOCS') == 'True'
compiler = self.compiler.compiler_type
if compiler == 'msvc': # visual studio
for e in self.extensions:
e.extra_compile_args += ['/O2', '/openmp']
else: # everything else that cares about following standards
for e in self.extensions:
e.extra_compile_args += ['-O2', '-fopenmp', '-march=native', '-std=c99']
e.extra_link_args += ['-fopenmp']
for e in self.extensions:
if from_rtd:
e.define_macros += [("_FOR_RTD", None)]
### remove this piece of code if you have macOS with GCC
if platform[:3] == "dar":
e.extra_compile_args = [arg for arg in e.extra_compile_args if arg != '-fopenmp']
e.extra_link_args = [arg for arg in e.extra_link_args if arg != '-fopenmp']
build_ext_with_blas.build_extensions(self)
setup(
name = "stochqn",
packages = ["stochqn"],
version = '0.2.8.2',
description = 'Stochastic limited-memory quasi-Newton optimizers',
author = 'David Cortes',
author_email = '[email protected]',
url = 'https://github.com/david-cortes/stochQN',
keywords = ['optimization', 'stochastic', 'quasi-Newton', 'SQN', 'adaQN', 'oLBFGS'],
install_requires=[
'numpy',
'scipy',
'scikit-learn',
'cython',
'findblas'
],
data_files = [('include', ['include/stochqn.h'])],
cmdclass = {'build_ext': build_ext_subclass},
ext_modules = [ Extension("stochqn._wrapper_double",
sources = ["stochqn/wrapper_double.pyx", "src/stochqn.c"],
include_dirs = [np.get_include(), "include"],
define_macros = [("USE_DOUBLE", None), ("_FOR_PYTON", None)] ),
Extension("stochqn._wrapper_float",
sources = ["stochqn/wrapper_float.pyx", "src/stochqn.c"],
include_dirs = [np.get_include(), "include"],
define_macros = [("USE_FLOAT", None), ("_FOR_PYTON", None)] )]
)