-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
74 lines (67 loc) · 2.75 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
import os
import configparser
from setuptools import setup, find_packages
from setuptools.command.install import install
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
class BuildCommand(install):
"""
Build cp2trans with config prompt.
"""
def run(self):
language = 'zh-CN'
appid = 'your_app_id'
secretkey ='your_secret_key'
neologd = 'C:\\neologd'
config = configparser.ConfigParser()
if not os.path.isfile(os.path.join(BASE_DIR, 'config.example.ini')):
print('"config.example.ini" not found. Exit.')
exit(-1)
config.read(os.path.join(BASE_DIR, 'config.example.ini'))
config.set('global', 'language', language)
config.set('global', 'appid', appid)
config.set('global', 'secretkey', secretkey)
config.set('global', 'neologd', neologd)
config.set('global', 'log_level', '20')
confirm = 'N'
while confirm != 'y':
confirm = input('You should backup your config.ini manually if it has been modified. Done? [y/N]')
with open(os.path.join(BASE_DIR, 'cp2trans', 'config.ini'), 'w') as f:
config.write(f)
install.do_egg_install(self)
print('You should edit configurations in "config.ini" from directory '
'"PYTHON_HOME\\Lib\\site-packages\cp2trans-*-*.egg\\cp2trans\\".')
print('Please perform some post-install steps follow the instructions on "README.md"'
' from https://github.com/EnderQIU/cp2translate to complete the install process.')
with open(os.path.join(BASE_DIR, 'requirements.txt'), encoding='utf8') as f:
install_requires = f.read().splitlines()
with open(os.path.join(BASE_DIR, 'README.md'), encoding='utf8') as f:
README = f.read()
setup(name='cp2trans',
version='1.1.0',
description='Clipboard to translate.',
long_description=README,
long_description_content_type='text/markdown',
keywords='clipboard translate',
author='EnderQIU',
author_email='a934560824@gmail.com',
license='GPLv3',
url='https://github.com/EnderQIU/cp2translate',
install_requires=install_requires,
packages=['cp2trans'],
entry_points={
'console_scripts': [
'cp2trans = cp2trans.cp2trans:main',
],
},
include_package_data=True,
cmdclass={'install': BuildCommand},
classifiers=[
'Development Status :: 4 - Beta',
'Operating System :: Microsoft :: Windows :: Windows 10',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Utilities'
],
)