-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathsetup.py
164 lines (139 loc) · 5.54 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#! /usr/bin/env python
"""Install script for sktime-dl"""
import codecs
import os
import platform
import re
import sys
from pkg_resources import Requirement
from pkg_resources import working_set
from setuptools import find_packages
from setuptools import setup
# raise early warning for incompatible Python versions
if sys.version_info < (3, 6) or sys.version_info >= (3, 8):
raise RuntimeError(
"sktime-dl requires Python 3.6 or 3.7 (only with tensorflow>=1.13.1). "
"The current Python version is %s installed in %s."
% (platform.python_version(), sys.executable))
HERE = os.path.abspath(os.path.dirname(__file__))
def read(*parts):
# intentionally *not* adding an encoding option to open, See:
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
with codecs.open(os.path.join(HERE, *parts), 'r') as fp:
return fp.read()
def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
else:
raise RuntimeError("Unable to find version string.")
def find_install_requires():
"""Return a list of dependencies and non-pypi dependency links.
A supported version of tensorflow and/or tensorflow-gpu is required. If not
found, then tensorflow is added to the install_requires list.
Depending on the version of tensorflow found or installed, either
keras-contrib or tensorflow-addons needs to be installed as well.
"""
install_requires = [
'sktime==0.7.0',
'h5py>=3.1.0',
'matplotlib',
'seaborn',
'keras-self-attention',
'keras==2.5.0.rc0'
]
# tensorflow version requirements
# by default, make sure anything already installed is above 1.8.0,
# or if installing from new get the most recent stable (i.e. not
# nightly) version
MINIMUM_TF_VERSION = '2.5.0'
tf_requires = 'tensorflow==' + MINIMUM_TF_VERSION
has_tf_gpu = False
has_tf = False
tf = working_set.find(Requirement.parse('tensorflow'))
tf_gpu = working_set.find(Requirement.parse('tensorflow-gpu'))
if tf is not None:
has_tf = True
tf_version = tf._version
if tf_gpu is not None:
has_tf_gpu = True
tf_gpu_version = tf_gpu._version
if has_tf_gpu and not has_tf:
# have -gpu only (1.x), make sure it's above 1.9.0
# Specify tensorflow-gpu version if it is already installed.
tf_requires = 'tensorflow-gpu>=' + MINIMUM_TF_VERSION
install_requires.append(tf_requires)
# tensorflow itself handled, now find out what add-on package to use
if (not has_tf and not has_tf_gpu) or (has_tf and tf_version >= '2.1.0'):
# tensorflow will be up-to-date enough to use most recent
# tensorflow-addons, the replacement for keras-contrib
install_requires.append('tensorflow-addons')
else:
# fall back to keras-contrib, not on pypi so need to install it
# separately not printing. TODO
print(
'Existing version of tensorflow older than version 2.1.0 '
'detected. You shall need to install keras-contrib (for tf.keras) '
'in order to use all the features of sktime-dl. '
'See https://github.com/keras-team/keras-contrib#install-keras_contrib-for-tensorflowkeras')
return install_requires
DISTNAME = 'sktime-dl' # package name is sktime-dl, to have a valid module path, module name is sktime_dl
DESCRIPTION = 'Deep learning extension package for sktime, a scikit-learn ' \
'compatible toolbox for learning with time series data'
with codecs.open('README.rst', encoding='utf-8-sig') as f:
LONG_DESCRIPTION = f.read()
MAINTAINER = 'F. Király'
MAINTAINER_EMAIL = 'f.kiraly@ucl.ac.uk'
URL = 'https://github.com/sktime/sktime-dl'
LICENSE = 'BSD-3-Clause'
DOWNLOAD_URL = 'https://pypi.org/project/sktime-dl/#files'
PROJECT_URLS = {
'Issue Tracker': 'https://github.com/sktime/sktime-dl/issues',
'Documentation': 'https://sktime.github.io/sktime-dl/',
'Source Code': 'https://github.com/sktime/sktime-dl'
}
VERSION = find_version('sktime_dl', '__init__.py')
INSTALL_REQUIRES = find_install_requires()
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 :: 3.6',
'Programming Language :: Python :: 3.7']
EXTRAS_REQUIRE = {
'tests': [
'pytest',
'pytest-cov'
'flaky'],
'docs': [
'sphinx',
'sphinx-gallery',
'sphinx_rtd_theme',
'numpydoc',
'matplotlib'
]
}
setup(name=DISTNAME,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
license=LICENSE,
url=URL,
version=VERSION,
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(),
include_package_data=True,
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
)