forked from meeshkan/meeshkan-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
174 lines (132 loc) · 5.64 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
165
166
167
168
169
170
171
172
173
174
from setuptools import find_packages, setup, Command
import stat
import os
from shutil import rmtree
import sys
from pathlib import Path
# Package meta-data.
NAME = 'meeshkan'
DESCRIPTION = 'The Meeshkan Client for interactive machine learning'
URL = 'https://www.meeshkan.com/'
EMAIL = 'dev@meeshkan.com'
AUTHOR = 'Meeshkan Dev Team'
REQUIRES_PYTHON = '>=3.6.0'
SRC_DIR = 'meeshkan' # Relative location wrt setup.py
# Required packages.
# Older version of requests because >= 2.21 conflicts with sagemaker.
# Older version of jsonschema<3 as required by docker-compose
REQUIRED = ['boto3', 'dill', 'jsonschema<3', 'requests<2.21', 'Click', 'pandas', 'Pyro4', 'PyYAML', 'tabulate', 'matplotlib',
'nbconvert', 'ipykernel', 'notebook', 'sentry-sdk']
DEV = ['jupyter', 'nbdime', 'pylint', 'pytest==4.0.2', 'pytest-cov', 'mypy', 'pytest-asyncio', 'sagemaker', 'sphinx',
'sphinx-click', 'sphinx_rtd_theme']
# Optional packages
EXTRAS = {'dev': DEV,
'devTF': DEV + ['tensorflow', 'tensorboard', 'keras'],
'devTorch': DEV + ['torch']}
# Entry point for CLI (relative to setup.py)
ENTRY_POINTS = ['meeshkan = meeshkan.__main__:cli']
here = os.path.abspath(os.path.dirname(__file__))
# Import the README and use it as the long-description.
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = '\n' + f.read()
# Load the package's __version__.py module as a dictionary.
about = dict()
with open(os.path.join(here, SRC_DIR, '__version__.py')) as f:
exec(f.read(), about)
class SetupCommand(Command):
"""Base class for setup.py commands with no arguments"""
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
@staticmethod
def status(s):
"""Prints things in bold."""
print('\033[1m{0}\033[0m'.format(s))
def rmdir_if_exists(self, directory):
self.status("Deleting {}".format(directory))
rmtree(directory, ignore_errors=True)
class BuildDistCommand(SetupCommand):
"""Support setup.py upload."""
description = "Build the package."
def run(self):
self.status("Removing previous builds...")
self.rmdir_if_exists(os.path.join(here, 'dist'))
# Write the config.yaml file based on env variables for CI:
config_file = Path("meeshkan/core/config.yaml").absolute()
with config_file.open('w') as cfid:
cfid.writelines(["cloud:\n",
" url: \"{cloud_url}\"\n".format(cloud_url=os.environ.get("MEESHKAN_CLOUD_URL")),
"sentry:\n",
" dsn: \"{sentry_dsn}\"\n".format(sentry_dsn=os.environ.get("MEESHKAN_SENTRY_URL"))])
self.status("Building Source and Wheel (universal) distribution...")
os.system("{executable} setup.py sdist bdist_wheel --universal".format(executable=sys.executable))
sys.exit()
def build_docs():
os.chdir("docs")
os.system("sphinx-apidoc -f -e -o source/ ../meeshkan/")
os.system("sphinx-build -M html -D version={version} source build".format(version=about['__version__']))
class BuildDocumentationCommand(SetupCommand):
"""Builds the sphinx documentation"""
description = "Builds the sphinx documentation."
def run(self):
self.status("Removing previous builds...")
build_dir = os.path.join(here, 'docs/build')
self.rmdir_if_exists(build_dir)
version_dir = os.path.join(here, 'docs', 'version={version}'.format(version=about['__version__']))
self.rmdir_if_exists(version_dir) # Need to delete this before building HTML docs
self.status("Building documentation...")
build_docs()
self.status("Docs were built to `docs/build`.")
sys.exit()
class UploadCommand(SetupCommand):
"""Support setup.py upload."""
description = "Build and publish the package."
def run(self):
self.status("Removing previous builds...")
self.rmdir_if_exists(os.path.join(here, 'dist'))
self.status("Building Source and Wheel (universal) distribution...")
os.system("{executable} setup.py sdist bdist_wheel --universal".format(executable=sys.executable))
self.status("Uploading the package to PyPI via Twine...")
os.system("twine upload dist/*")
self.status("Pushing git tags...")
os.system("git tag v{about}".format(about=about['__version__']))
os.system("git push --tags")
sys.exit()
class TestCommand(SetupCommand):
"""Support setup.py test."""
description = "Run local test if they exist"
def run(self):
os.system("pytest")
sys.exit()
setup(
name=NAME,
version=about['__version__'],
description=DESCRIPTION,
long_description=long_description,
long_description_content_type='text/markdown',
author=AUTHOR,
author_email=EMAIL,
python_requires=REQUIRES_PYTHON,
url=URL,
packages=find_packages(exclude=('tests',)),
install_requires=REQUIRED,
extras_require=EXTRAS,
include_package_data=True,
license='Apache 2.0',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Operating System :: MacOS',
'Operating System :: POSIX',
'Operating System :: Unix'
],
entry_points={'console_scripts': ENTRY_POINTS},
cmdclass={'dist': BuildDistCommand, 'upload': UploadCommand, 'test': TestCommand,
'doc': BuildDocumentationCommand}
)