forked from terryyin/translate-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
108 lines (86 loc) · 3.21 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
#!/usr/bin/env python
# encoding: utf-8
import codecs
import os
import re
from setuptools import find_packages, setup, Command
here = os.path.dirname(os.path.abspath(__file__))
version = '0.0.0'
description = (
'This is a simple, yet powerful command line translator with google translate behind it. '
'You can also use it as a Python module in your code.'
)
changes = os.path.join(here, "CHANGES.rst")
pattern = r'^(?P<version>[0-9]+.[0-9]+(.[0-9]+)?)'
with codecs.open(changes, encoding='utf-8') as changes:
for line in changes:
match = re.match(pattern, line)
if match:
version = match.group("version")
break
# Save last Version
def save_version():
version_path = os.path.join(here, "translate/version.py")
with open(version_path) as version_file_read:
content_file = version_file_read.read()
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, content_file, re.M)
current_version = mo.group(1)
content_file = content_file.replace(current_version, "{}".format(version))
with open(version_path, 'w') as version_file_write:
version_file_write.write(content_file)
save_version()
class VersionCommand(Command):
description = 'Show library version'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print(version)
# Get the long description
with codecs.open(os.path.join(here, 'README.rst')) as f:
long_description = '\n{}'.format(f.read())
# Get change log
with codecs.open(os.path.join(here, 'CHANGES.rst')) as f:
changelog = f.read()
long_description += '\n\n{}'.format(changelog)
# Requirements
with codecs.open(os.path.join(here, 'requirements.txt')) as f:
install_requirements = [line.split('#')[0].strip() for line in f.readlines() if not line.startswith('#')]
with codecs.open(os.path.join(here, 'requirements-dev.txt')) as f:
tests_requirements = [line.replace('\n', '') for line in f.readlines() if not line == '-r requirements.txt\n']
setup(
author='Terry Yin',
author_email='[email protected]',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Education',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python',
'Topic :: Education',
],
cmdclass={'version': VersionCommand},
description=description,
entry_points='''
[console_scripts]
translate-cli=translate.__main__:cli
''',
install_requires=install_requirements,
keywords='translate translation command line',
license='MIT',
long_description=long_description,
name='translate',
packages=find_packages(exclude=['docs', 'tests', 'tests.*', 'requirements']),
setup_requires=['pytest-runner'],
tests_require=tests_requirements,
url='https://github.com/terryyin/google-translate-python',
version=version,
)