-
Notifications
You must be signed in to change notification settings - Fork 10
/
setup.py
executable file
·142 lines (121 loc) · 4.63 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#! /usr/bin/env python
"""A set of python modules for cyclist using powermeters."""
import io
import re
import os
import sys
import subprocess
import codecs
from setuptools import find_packages
PACKAGE_NAME = 'sksports'
DISTNAME = 'scikit-sports'
DESCRIPTION = 'A set of python modules for cyclist using powermeters.'
with codecs.open('README.rst', encoding='utf-8-sig') as f:
LONG_DESCRIPTION = f.read()
MAINTAINER = 'G. Lemaitre'
MAINTAINER_EMAIL = '[email protected]'
URL = 'https://github.com/scikit-sports/scikit-sports'
LICENSE = 'MIT'
DOWNLOAD_URL = 'https://github.com/scikit-sports/scikit-sports'
INSTALL_REQUIRES = ['numpy', 'scipy', 'pandas', 'scikit-learn', 'six',
'joblib', 'fitparse', 'cython']
CLASSIFIERS = ['Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'License :: OSI Approved',
'Programming Language :: Python',
'Topic :: Software Development',
'Topic :: Scientific/Engineering',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Operating System :: MacOS',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6']
PACKAGE_DATA = {'sksports': ['datasets/data/*.fit',
'datasets/data/*.csv',
'datasets/corrupted_data/*.fit',
'metrics/tests/data/rider_power_profile.csv']}
EXTRAS_REQUIRE = {
'tests': [
'pytest',
'pytest-cov'],
'docs': [
'sphinx',
'sphinx-gallery',
'sphinx_rtd_theme',
'numpydoc',
'matplotlib',
]
}
def version(package, encoding='utf-8'):
"""Obtain the packge version from a python file e.g. pkg/_version.py
See <https://packaging.python.org/en/latest/single_source_version.html>.
"""
path = os.path.join(os.path.dirname(__file__), package, '_version.py')
with io.open(path, encoding=encoding) as fp:
version_info = fp.read()
version_match = re.search(r"""^__version__ = ['"]([^'"]*)['"]""",
version_info, re.M)
if not version_match:
raise RuntimeError("Unable to find version string.")
return version_match.group(1)
def generate_cython(package):
"""Cythonize all sources in the package"""
cwd = os.path.abspath(os.path.dirname(__file__))
print("Cythonizing sources")
p = subprocess.call([sys.executable,
os.path.join(cwd, 'tools', 'cythonize.py'),
package],
cwd=cwd)
if p != 0:
raise RuntimeError("Running cythonize failed!")
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration(None, parent_package, top_path)
config.set_options(ignore_setup_xxx_py=True,
assume_default_configuration=True,
delegate_options_to_subpackages=True,
quiet=True)
config.add_subpackage(PACKAGE_NAME)
return config
def setup_package():
from numpy.distutils.core import setup
old_path = os.getcwd()
local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
src_path = local_path
os.chdir(local_path)
sys.path.insert(0, local_path)
# Run build
old_path = os.getcwd()
os.chdir(src_path)
sys.path.insert(0, src_path)
cwd = os.path.abspath(os.path.dirname(__file__))
if not os.path.exists(os.path.join(cwd, 'PKG-INFO')):
# Generate Cython sources, unless building from source release
generate_cython(PACKAGE_NAME)
try:
setup(name=DISTNAME,
author=MAINTAINER,
author_email=MAINTAINER_EMAIL,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
license=LICENSE,
url=URL,
version=version(PACKAGE_NAME),
download_url=DOWNLOAD_URL,
long_description=LONG_DESCRIPTION,
zip_safe=False, # the package can run out of an .egg file
classifiers=CLASSIFIERS,
packages=find_packages(),
package_data=PACKAGE_DATA,
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
configuration=configuration)
finally:
del sys.path[0]
os.chdir(old_path)
return
if __name__ == '__main__':
setup_package()