-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathsetup.py
139 lines (122 loc) · 4.31 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
127
128
129
130
131
132
133
134
135
136
137
138
139
import distutils.cmd
import pathlib
import re
import sys
from setuptools import setup
PACKAGE_NAME = 'parser_2gis'
ROOT_DIR = pathlib.Path(__file__).parent
VERSION_PATH = ROOT_DIR / PACKAGE_NAME / 'version.py'
README_PATH = ROOT_DIR / 'README.md'
long_description = README_PATH.read_text(encoding='utf-8')
long_description_content_type = 'text/markdown'
match = re.search(r'^version\s*=\s*[\'"](?P<version>.+?)[\'"]',
VERSION_PATH.read_text(encoding='utf-8'), re.M)
assert match
version = match.group('version')
class BuildStandaloneCommand(distutils.cmd.Command):
"""A custom command to build standalone app."""
description = 'Build standalone app with PyInstaller'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
import os
import shutil
import subprocess
import sys
try:
# Target filename
dist_filename = 'Parser2GIS'
# Dist
build_cmd = [
'pyinstaller',
'--clean',
'--onefile',
'--windowed',
'-n', dist_filename,
]
# Icon
if sys.platform.startswith('win'):
build_cmd += [
'--icon', 'parser_2gis/data/images/icon.ico',
]
elif sys.platform.startswith('darwin'):
build_cmd += [
'--icon', 'parser_2gis/data/images/icon.icns',
]
# Add data
build_cmd += [
'--add-data', f'parser_2gis/data{os.pathsep}parser_2gis/data',
'parser-2gis.py',
]
print('Running command: %s' % ' '.join(build_cmd), file=sys.stderr)
subprocess.check_call(build_cmd)
finally:
# Cleanup
shutil.rmtree(ROOT_DIR / 'build', ignore_errors=True)
try:
os.remove(ROOT_DIR / f'{dist_filename}.spec')
except FileNotFoundError:
pass
if __name__ == '__main__':
setup(
name='parser-2gis',
version=version,
description='Парсер сайта 2GIS',
long_description=long_description,
long_description_content_type=long_description_content_type,
author='Andy Trofimov',
author_email='[email protected]',
packages=[PACKAGE_NAME],
include_package_data=True,
python_requires='>=3.8',
keywords='parser scraper 2gis',
url='https://github.com/interlark/parser-2gis',
project_urls={
'Documentation': 'https://github.com/interlark/parser-2gis/wiki',
'GitHub': 'https://github.com/interlark/parser-2gis',
'Changelog': 'https://github.com/interlark/parser-2gis/blob/main/CHANGELOG.md',
},
install_requires=[
'pychrome==0.2.4',
'pydantic>=1.9.0,<2.0',
'psutil>=5.4.8',
'requests>=2.13.0',
'xlsxwriter>=3.0.5',
],
extras_require={
'gui': [
'PySimpleGUI==4.59.0',
],
'dev': (
(
["pyinstaller>=5.0,<5.7.0"]
if sys.platform.startswith("win")
else ["pyinstaller>=6.6.0"]
) + [
"pytest>=6.2,<8",
"tox>=3.5,<4",
"pre-commit>=2.6",
"wheel>=0.36.2,<0.38",
]
),
},
classifiers=[
"Topic :: Internet",
"Topic :: Utilities",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Natural Language :: Russian",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
],
license='LGPLv3+',
entry_points={'console_scripts': ['parser-2gis = parser_2gis:main']},
cmdclass={'build_standalone': BuildStandaloneCommand}
)