forked from MediaMath/t1-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·90 lines (77 loc) · 2.56 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
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import subprocess
from distutils.util import convert_path
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
def fread(fname):
with open(os.path.join(CURRENT_DIR, fname)) as f:
return f.read()
packages = [
'terminalone',
'terminalone.models',
'terminalone.utils',
'terminalone.vendor',
]
requirements = [
'requests>=2.3.0',
'requests-oauthlib>=0.5.0',
]
metadata = {}
ver_path = convert_path('terminalone/metadata.py')
with open(ver_path) as ver_file:
exec(ver_file.read(), metadata)
def check_pip():
st = subprocess.check_output(['pip', 'search', metadata['__name__']])
pip_version = st[st.index('(') + 1: st.index(')')]
print(pip_version)
if pip_version == metadata['__version__']:
print('version {} already published. '
'Modify metadata.py to update version and commit.'
.format(pip_version))
sys.exit()
if sys.argv[-1] == 'publish':
check_pip()
subprocess.call(["python", "setup.py", "sdist"])
filename = "TerminalOne-{}.tar.gz".format(metadata['__version__'])
print('Uploading {}'.format(filename))
subprocess.call(["twine", "upload", "dist/{}".format(filename)])
print("Did you remember to tag the release? ./setup.py tag")
sys.exit()
if sys.argv[-1] == 'tag':
subprocess.call(["git", "tag",
"-a", metadata['__version__'],
"-m", "'version {}'".format(metadata['__version__'])])
subprocess.call(["git", "push", "--tags"])
sys.exit()
setup(
name=metadata['__name__'],
version=metadata['__version__'],
author=metadata['__author__'],
author_email=metadata['__email__'],
url=metadata['__url__'],
description=metadata['__description__'],
long_description=fread('README.rst'),
packages=packages,
install_requires=requirements,
platforms=['any'],
license=fread('LICENSE'),
classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Intended Audience :: Developers',
'Natural Language :: English',
'Operating System :: OS Independent',
],
test_suite="tests",
)