-
Notifications
You must be signed in to change notification settings - Fork 9
/
setup.py
78 lines (69 loc) · 2.8 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
from setuptools import setup, find_packages
from requests import get as rget
from bs4 import BeautifulSoup
import logging , sys
# init logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
sh = logging.StreamHandler(stream=sys.stdout)
format = logging.Formatter("%(message)s")#("%(asctime)s - %(message)s")
sh.setFormatter(format)
logger.addHandler(sh)
#
def get_install_requires(filename):
with open(filename,'r') as f:
lines = f.readlines()
return [x.strip() for x in lines]
#
url = 'https://github.com/GoodManWEN/ThreadPoolExecutorPlus'
release = '{0}/releases/latest'.format(url)
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
"Connection": "keep-alive",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"Accept-Language": "zh-CN,zh;q=0.8"
}
html = BeautifulSoup(rget(url , headers).text ,'lxml')
description = html.find('meta' ,{'name':'description'}).get('content')
for kw in (' - GitHub', ' - GoodManWEN'):
if ' - GitHub' in description:
description = description[:description.index(' - GitHub')]
html = BeautifulSoup(rget(release , headers).text ,'lxml')
version = html.find('div',{'class':'release-header'}).find('a').text
logger.info("description: {0}".format(description))
logger.info("version: {0}".format(version))
#
with open('README.md','r',encoding='utf-8') as f:
long_description_lines = f.readlines()
long_description_lines_copy = long_description_lines[:]
long_description_lines_copy.insert(0,'r"""\n')
long_description_lines_copy.append('"""\n')
# update __init__ docs
with open('ThreadPoolExecutorPlus/__init__.py','r',encoding='utf-8') as f:
init_content = f.readlines()
for line in init_content:
if line == "__version__ = ''\n":
long_description_lines_copy.append("__version__ = '{0}'\n".format(version))
else:
long_description_lines_copy.append(line)
with open('ThreadPoolExecutorPlus/__init__.py','w',encoding='utf-8') as f:
f.writelines(long_description_lines_copy)
setup(
name="ThreadPoolExecutorPlus",
version=version,
author="WEN",
description=description,
long_description=''.join(long_description_lines),
long_description_content_type="text/markdown",
url="https://github.com/GoodManWEN/ThreadPoolExecutorPlus",
packages = find_packages(),
install_requires = get_install_requires('requirements.txt'),
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX :: Linux',
'Operating System :: Microsoft :: Windows',
],
python_requires='>=3.5',
keywords=["concurrent.futures" , "threading" , "multi-threads" ,"ThreadPoolExecutor"]
)