forked from zdict/zdict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
109 lines (85 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
109
import sys
import os
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand
try:
# for pip >= 10
from pip._internal.req import parse_requirements
except ImportError:
# for pip <= 9.0.3
from pip.req import parse_requirements
ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
def get_zdict_version():
constants_file_path = os.path.join(ROOT_DIR, 'zdict/constants.py')
with open(constants_file_path) as constants:
for line in constants:
if line.startswith('VERSION'):
code = compile(line, '<string>', 'single')
version = code.co_consts[0]
return version
def get_test_req():
test_requirements = parse_requirements(
os.path.join(ROOT_DIR, 'test-requirements.txt'), session=False
)
test_requires = [str(tr.req) for tr in test_requirements]
if not sys.platform.startswith('freebsd'):
test_requires.append('gnureadline==6.3.3')
return test_requires
version = get_zdict_version()
class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = []
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
install_requirements = parse_requirements(
os.path.join(ROOT_DIR, 'requirements.txt'), session=False
)
install_requires = [str(ir.req) for ir in install_requirements]
if sys.platform == 'darwin' and sys.version_info <= (3, 5):
install_requires.append('gnureadline==6.3.3')
setup(
packages=find_packages(exclude=['scripts']),
scripts=['scripts/zdict'],
install_requires=install_requires,
tests_require=get_test_req(),
cmdclass={'test': PyTest},
name='zdict',
version=version,
author='Shun-Yi Jheng',
author_email='[email protected]',
maintainer='Shun-Yi Jheng, Iblis Lin, Chang-Yen Chih, Chiu-Hsiang Hsu',
maintainer_email=('[email protected],'
url='https://github.com/zdict/zdict',
keywords="cli, dictionary, framework",
description="The last dictionary framework you need. (?)",
long_description=open("README.rst", encoding='utf-8').read(),
download_url="https://github.com/zdict/zdict/archive/v{}.zip".format(
version
),
platforms=['Linux', 'Mac'],
license="GPL3",
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Natural Language :: Chinese (Traditional)",
"Natural Language :: English",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Utilities",
],
)