-
Notifications
You must be signed in to change notification settings - Fork 70
/
setup.py
executable file
·126 lines (100 loc) · 3.59 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
import codecs
import os
import re
import subprocess
import sys
from fias.version import __version__
def execute(cmd):
assert isinstance(cmd, (list, tuple)), 'cmd must be a list or tuple'
proc = subprocess.Popen(cmd, cwd=os.path.abspath(os.path.dirname(__name__)),
stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
return proc.communicate()
def check_tag_exists():
tag_out, tag_err = execute(['git', 'tag', '-l', __version__])
if tag_out.strip():
print("Уже существует тег для версии: {0}.".format(__version__))
sys.exit()
PY3 = sys.version_info[0] == 3
sys.path.insert(0, '..')
if sys.argv[-1] == 'test':
req_split = re.compile(r'[a-z_][a-z0-9_]+', re.I | re.U | re.M)
req_file = codecs.open('requirements.txt', mode='r').read()
test_req_file = codecs.open('test_requirements.txt', mode='r').read()
test_requirements = req_split.findall(req_file) + req_split.findall(test_req_file)
try:
modules = list(map(__import__, test_requirements))
except ImportError as e:
err_msg = e.msg.replace("No module named ", "")
msg = "%s is not installed. Install your test requirments." % err_msg
raise ImportError(msg)
os.system('py.test')
sys.exit()
if sys.argv[-1] == 'tag':
check_tag_exists()
os.system("git tag -a %s -m 'version %s'" % (__version__, __version__))
os.system("git push --tags")
sys.exit()
if sys.argv[-1] == 'publish':
check_tag_exists()
tox_out, tox_err = execute(['tox'])
if hasattr(sys.stdout, 'buffer'):
sys.stdout.buffer.write(tox_out)
else:
sys.stdout.write(tox_out)
if 'FAILURES' in str(tox_out):
print('Не все тесты прошли. Нельзя публиковать!')
sys.exit()
os.system("python setup.py sdist upload")
os.system("python setup.py bdist_wheel upload")
print("Не забудь добавить тег:")
print(" git tag -a %s -m 'ver.%s'" % (__version__, __version__))
print(" git push --tags")
print("Или:")
print(" python setup.py tag")
sys.exit()
setup(
name='django-fias',
version=__version__,
author='Artem Vlasov',
author_email='root@proscript.ru',
url='https://github.com/Yuego/django-fias',
download_url='https://github.com/Yuego/django-fias/archive/{0}.tar.gz'.format(__version__),
description='FIAS Django integration',
long_description=codecs.open('README.rst', encoding='utf8').read(),
license='MIT license',
install_requires=[
'django>=2.0',
'django_select2>=7.0.3',
'zeep>=0.17.0',
'rarfile',
'six',
'lxml',
'unrar',
'dbfread>=2.0.5',
'progress',
],
extras_require={
'MySQL': [
'PyMySQL==0.9.3',
],
},
packages=find_packages(exclude=('tests', 'tests.*')),
include_package_data=True,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Natural Language :: Russian',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Software Development :: Libraries :: Python Modules',
],
)