forked from E-P-T/Homework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
101 lines (75 loc) · 2.44 KB
/
setup.py
File metadata and controls
101 lines (75 loc) · 2.44 KB
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
import re
import shutil
from setuptools import setup, find_packages
from setuptools.command.develop import develop
from setuptools.command.egg_info import egg_info
from setuptools.command.install import install
VERSION_FILE = 'rss_parse/__init__.py'
def version():
_version_re = re.compile(r'^\s*__version__\s*=\s*[\'"](.*)[\'"]\s*$')
with open(VERSION_FILE, 'r') as f:
res = _version_re.search(f.read())
if res is None:
raise RuntimeError(f"Unable to find version string in {VERSION_FILE}.")
ver = res.group(1)
return ver
fonts_installed = False
def install_fdpf_fonts():
global fonts_installed
if fonts_installed:
return
try:
import os
import fpdf
local_fonts_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fonts")
fpdf_fonts_dir = os.path.join(os.path.dirname(fpdf.__file__), 'font')
if not os.path.exists(fpdf_fonts_dir):
os.mkdir(fpdf_fonts_dir)
font_file_names = [f for f in os.listdir(local_fonts_dir) if f.endswith(".ttf")]
for font_file_name in font_file_names:
full_file_name = os.path.join(local_fonts_dir, font_file_name)
shutil.copy(full_file_name, fpdf_fonts_dir)
fonts_installed = True
except ModuleNotFoundError:
pass
class CustomInstallCommand(install):
def run(self):
install.run(self)
install_fdpf_fonts()
class CustomDevelopCommand(develop):
def run(self):
develop.run(self)
install_fdpf_fonts()
class CustomEggInfoCommand(egg_info):
def run(self):
egg_info.run(self)
install_fdpf_fonts()
setup(
name='rss_reader',
version=version(),
description='Pure Python command-line RSS reader.',
author='Aleksandra Khorosheva',
zip_safe=False,
author_email='Aleksandra_Khorosheva@epam.com',
keywords=['RSS Reader', 'RSS Feed Parser'],
install_requires=[
'setuptools~=57.0.0',
'requests~=2.27.1',
'xmltodict~=0.13.0',
'fpdf2>=2.5.5',
'python-dateutil~=2.8.0',
'html2text>=2020.1.16',
],
python_requires=">=3.8",
packages=find_packages(),
entry_points={
'console_scripts': [
'rss_reader=rss_parse.rss_reader:main_wrapper',
],
},
cmdclass={
'install': CustomInstallCommand,
'develop': CustomDevelopCommand,
'egg_info': CustomEggInfoCommand,
},
)