forked from guillermo-jimenez/PyMKL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
90 lines (84 loc) · 3.45 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
88
89
90
import codecs
import os.path
from setuptools import setup, find_packages, Extension
from distutils.command.build_ext import build_ext as build_ext_orig
# https://stackoverflow.com/questions/4529555/building-a-ctypes-based-c-library-with-distutils
class build_ext(build_ext_orig):
def build_extension(self, ext):
self._ctypes = isinstance(ext, Extension)
return super().build_extension(ext)
def get_export_symbols(self, ext):
if self._ctypes:
return ext.export_symbols
return super().get_export_symbols(ext)
def get_ext_filename(self, ext_name):
if self._ctypes:
return ext_name + '.so'
return super().get_ext_filename(ext_name)
"""Reading version as proposed in https://packaging.python.org/guides/single-sourcing-package-version/"""
def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
return fp.read()
def get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
else:
raise RuntimeError("Unable to find version string.")
# Generate Python library
try:
setup(
name="PyMKL",
description="Multiple Kernel Learning implementation for Python",
url="https://github.com/gjimenez/PyMKL",
author="Guillermo Jimenez-Perez",
author_email="<guillermo@jimenezperez.com>",
# Needed to actually package something
packages=find_packages(),
# Needed for dependencies
install_requires=["numpy", "scipy", "picos", "cvxopt", "joblib",
"pandas", "tqdm", "scikit-learn", "networkx", "numba",
"sak @ git+https://github.com/guillermo-jimenez/sak.git"],
# *strongly* suggested for sharing
version=get_version("PyMKL/__init__.py"),
# The license can be anything you like
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU General Public License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
py_modules = ["libPyMKL"],
ext_modules=[
Extension(
"PyMKL/lib/cpp/libPyMKL",
["PyMKL/lib/cpp/libPyMKL.c",],
),
],
cmdclass={'build_ext': build_ext},
)
except (Exception, SystemExit):
setup(
name="PyMKL",
description="Multiple Kernel Learning implementation for Python",
url="https://github.com/gjimenez/PyMKL",
author="Guillermo Jimenez-Perez",
author_email="<guillermo@jimenezperez.com>",
# Needed to actually package something
packages=find_packages(),
# Needed for dependencies
install_requires=["numpy", "scipy", "picos", "cvxopt", "joblib",
"pandas", "tqdm", "scikit-learn", "networkx", "numba",
"sak @ git+https://github.com/guillermo-jimenez/sak.git"],
# *strongly* suggested for sharing
version=get_version("PyMKL/__init__.py"),
# The license can be anything you like
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU General Public License",
"Operating System :: OS Independent",
],
python_requires='>=3.6'
)