forked from persepolisdm/persepolis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
152 lines (127 loc) · 4.04 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
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python3
# coding: utf-8
import os.path
import warnings
import sys
import platform
import shutil
# finding os platform
os_type = platform.system()
if os_type == 'Linux' or os_type == 'FreeBSD' or os_type == 'OpenBSD':
from setuptools import setup, Command, find_packages
setuptools_available = True
print(os_type + " detected!")
else:
print('This script is only work for GNU/Linux or BSD!')
sys.exit(1)
# Checking dependencies!
# PyQt5
try:
import PyQt5
print('python3-pyqt5 is found')
except:
print('Error : python3-pyqt5 is not installed!')
sys.exit(1)
# python3-requests
try:
import requests
print('python3-requests is found!')
except:
print('Error : requests is not installed!')
sys.exit(1)
# python3-setproctitle
try:
import setproctitle
print('python3-setproctitle is found!')
except:
print("Warning: setproctitle is not installed!")
# aria2
answer = os.system('aria2c --version 1>/dev/null')
if answer != 0:
print("Error aria2 not installed!")
sys.exit(1)
else:
print('aria2 is found!')
# libnotify-bin
answer = os.system('notify-send --version 1>/dev/null')
if answer != 0:
print("Error libnotify-bin is not installed!")
sys.exit(1)
else:
print('libnotify-bin is found!')
# paplay
answer = os.system('paplay --version 1>/dev/null')
if answer != 0:
print("Warning: paplay not installed!You need pulseaudio for sound notifications!")
else:
print('paplay is found!')
# sound-theme-freedesktop
if os_type == 'Linux':
notifications_path = '/usr/share/sounds/freedesktop/stereo/'
elif os_type == 'FreeBSD' or os_type == 'OpenBSD':
notifications_path = '/usr/local/share/sounds/freedesktop/stereo/'
if os.path.isdir(notifications_path):
print('sound-theme-freedesktop is found!')
else:
print('Warning: sound-theme-freedesktop is not installed! you need this package for sound notifications!')
DESCRIPTION = 'Persepolis Download Manager'
if os_type == 'Linux':
DATA_FILES = [
('/usr/share/man/man1/', ['man/persepolis.1.gz']),
('/usr/share/applications/', ['xdg/persepolis.desktop']),
('/usr/share/pixmaps/', ['icons/persepolis.svg'])
]
elif os_type == 'FreeBSD' or os_type == 'OpenBSD':
DATA_FILES = [
('/usr/local/share/man/man1/', ['man/persepolis.1.gz']),
('/usr/local/share/applications/', ['xdg/persepolis.desktop']),
('/usr/local/share/pixmaps/', ['icons/persepolis.svg'])
]
# finding current directory
cwd = os.path.abspath(__file__)
setup_dir = os.path.dirname(cwd)
#clearing __pycache__
src_pycache = os.path.join(setup_dir, 'persepolis', '__pycache__')
gui_pycache = os.path.join(setup_dir, 'persepolis', 'gui', '__pycache__')
scripts_pycache = os.path.join(setup_dir, 'persepolis', 'scripts', '__pycache__')
for folder in [src_pycache, gui_pycache, scripts_pycache]:
if os.path.isdir(folder):
shutil.rmtree(folder)
print(str(folder)
+ ' is removed!')
# Creating man page file
persepolis_man_page = os.path.join(setup_dir, 'man', 'persepolis.1')
os.system('gzip -f -k -9 "'
+ persepolis_man_page
+ '"')
print('man page file is generated!')
setup(
name = 'persepolis',
version = '2.4.2',
license = 'GPL3',
description = DESCRIPTION,
long_description = DESCRIPTION,
include_package_data=True,
url = 'https://github.com/persepolisdm/persepolis',
author = 'AliReza AmirSamimi',
author_email = '[email protected]',
maintainer = 'AliReza AmirSamimi',
maintainer_email = '[email protected]',
packages = (
'persepolis',
'persepolis.scripts', 'persepolis.gui',
),
data_files = DATA_FILES,
entry_points={
'console_scripts': [
'persepolis = persepolis.__main__'
]
}
)
# clearing after installation finished!
for folder in [ 'build', 'dist', 'root', 'persepolis.egg-info']:
if os.path.isdir(folder):
shutil.rmtree(folder)
print(str(folder)
+ ' is removed!')
os.remove('man/persepolis.1.gz')