-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathsetup.py
87 lines (73 loc) · 2.27 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#! /usr/bin/env python
#
# Copyright (C) 2017 Berk Ustun
import os
import sys
from setuptools import setup, find_packages, dist
from setuptools.extension import Extension
#resources
#setuptools http://setuptools.readthedocs.io/en/latest/setuptools.html
#setuptools + Cython: http://stackoverflow.com/questions/32528560/
DISTNAME = 'riskslim'
DESCRIPTION = "optimized risk scores on large-scale datasets"
AUTHOR = 'Berk Ustun'
AUTHOR_EMAIL = '[email protected]'
URL = 'https://github.com/ustunb/risk-slim'
LICENSE = 'new BSD'
DOWNLOAD_URL = 'https://github.com/ustunb/risk-slim'
VERSION = '0.0.0'
# Install setup requirements
dist.Distribution().fetch_build_eggs(['Cython', 'numpy', 'scipy'])
#read requirements as listed in txt file
try:
import numpy
except ImportError:
print('numpy is required for installation')
sys.exit(1)
try:
import scipy
except ImportError:
print('scipy is required for installation')
sys.exit(1)
try:
from Cython.Build import cythonize
except ImportError:
print('Cython is required for installation')
sys.exit(1)
#fast log loss
extensions =[
Extension(
DISTNAME + ".loss_functions." + "fast_log_loss",
[DISTNAME + "/loss_functions/fast_log_loss.pyx"],
include_dirs=[numpy.get_include(), scipy.get_include()],
libraries=["m"],
extra_compile_args=["-ffast-math"]
),
Extension(
DISTNAME + ".loss_functions." + "lookup_log_loss",
[DISTNAME + "/loss_functions/lookup_log_loss.pyx"],
include_dirs=[numpy.get_include(), scipy.get_include()],
libraries=["m"],
extra_compile_args=["-ffast-math"])
]
if __name__ == "__main__":
old_path = os.getcwd()
local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
os.chdir(local_path)
sys.path.insert(0, local_path)
with open('requirements.txt') as f:
INSTALL_REQUIRES = [l.strip() for l in f.readlines() if l]
setup(
name=DISTNAME,
packages=find_packages(),
ext_modules=cythonize(extensions),
author=AUTHOR,
author_email=AUTHOR_EMAIL,
description=DESCRIPTION,
install_requires=INSTALL_REQUIRES,
license=LICENSE,
url=URL,
version=VERSION,
download_url=DOWNLOAD_URL,
zip_safe=False,
)