-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
217 lines (189 loc) · 7.47 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
## @package Setup script
from setuptools import setup, Command
import os
import platform
import shutil
import site
from concurrent.futures import ProcessPoolExecutor
from multiprocessing import cpu_count
class Doxygen(Command):
description = "Create/update doxygen documentation in doc/html"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print("Creating Doxygen Documentation")
os.system("""sed -i -e "41d" doc/Doxyfile""")#Delete line 41
os.system("""sed -i -e "41iPROJECT_NUMBER = {}" doc/Doxyfile""".format(__version__))#Insert line 41
os.system("rm -Rf build")
os.chdir("doc")
os.system("doxygen Doxyfile")
os.system("rsync -avzP -e 'ssh -l turulomio' html/ frs.sourceforge.net:/home/users/t/tu/turulomio/userweb/htdocs/doxygen/didyoureadme/ --delete-after")
os.chdir("..")
class PyInstaller(Command):
description = "We run pyinstaller in build to avoid doing a ./didyoureadme module imort. I had problems with i18n. Before running this command I must have done a install, removing old installations"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system("python setup.py uninstall")
os.system("python setup.py install")
f=open("build/run.py","w")
f.write("import didyoureadme\n")
f.write("didyoureadme.main()\n")
f.close()
os.chdir("build")
os.system("""pyinstaller run.py -n didyoureadme-{} --onefile --windowed --icon ../didyoureadme/images/didyoureadme.ico --distpath ../dist""".format(__version__))
class Compile(Command):
description = "Compile ui and images"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
futures=[]
with ProcessPoolExecutor(max_workers=cpu_count()+1) as executor:
for filename in os.listdir("didyoureadme/ui/"):
if filename.endswith(".ui"):
without_extension=filename[:-3]
futures.append(executor.submit(os.system, "pyuic5 didyoureadme/ui/{0}.ui -o didyoureadme/ui/Ui_{0}.py".format(without_extension)))
futures.append(executor.submit(os.system, "pyrcc5 didyoureadme/images/didyoureadme.qrc -o didyoureadme/images/didyoureadme_rc.py"))
# Overwriting didyoureadme_rc
for filename in os.listdir("didyoureadme/ui/"):
if filename.startswith("Ui_"):
os.system("sed -i -e 's/ didyoureadme_rc/ didyoureadme.images.didyoureadme_rc/' didyoureadme/ui/{}".format(filename))
os.system("sed -i -e 's/from myqtablewidget/from didyoureadme.ui.myqtablewidget/' didyoureadme/ui/{}".format(filename))
os.system("sed -i -e 's/from wdgYear/from didyoureadme.ui.wdgYear/' didyoureadme/ui/{}".format(filename))
class Uninstall(Command):
description = "Uninstall installed files with install"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
if platform.system()=="Linux":
os.system("rm -Rf {}/didyoureadme*".format(site.getsitepackages()[0]))
os.system("rm /usr/bin/didyoureadme*")
os.system("rm /usr/share/pixmaps/didyoureadme.png")
os.system("rm /usr/share/applications/didyoureadme.desktop")
else:
print(site.getsitepackages())
for file in os.listdir(site.getsitepackages()[1]):#site packages
path=site.getsitepackages()[1]+"\\"+ file
if file.find("didyoureadme")!=-1:
shutil.rmtree(path)
print(path, "Erased")
for file in os.listdir(site.getsitepackages()[0]+"\\Scripts\\"):#Scripts
path=site.getsitepackages()[0]+"\\scripts\\"+ file
if file.find("didyoureadme")!=-1:
os.remove(path)
print(path, "Erased")
class Procedure(Command):
description = "Uninstall installed files with install"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print("""
Nueva versión:
* Cambiar la versión y la fecha en version.py
* Escribir el Changelog en CHANGELOG.mc
* python setup.py doc
* linguist
* python setup.py doc
* python setup.py install
* python setup.py doxygen
* git commit -a -m 'didyoureadme-version'
* git push
* Hacer un nuevo tag en GitHub y copiar el CHANGELOG de la vsersión
* python setup.py sdist upload -r pypi
* Crea un nuevo ebuild de Gentoo con la nueva versión
* Subelo al repositorio del portage
* Change to windows. Enter in an Administrator console.
* Change to didyoureadme source directory and make git pull
* python setup.py pyinstaller
* Add file to github release
""")
class Doc(Command):
description = "Update man pages and translations"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system("pylupdate5 -noobsolete -verbose didyoureadme.pro")
os.system("lrelease -qt5 didyoureadme.pro")
########################################################################
#description
with open('README.md', encoding='utf-8') as f:
long_description = f.read()
#data_files
if platform.system()=="Linux":
data_files=[
('/usr/share/pixmaps/', ['didyoureadme/images/didyoureadme.png']),
('/usr/share/applications/', ['didyoureadme.desktop']),
]
else:
data_files=[]
#entry_points
entry_points={
'gui_scripts': [
'didyoureadme=didyoureadme.didyoureadme:main',
]
}
if platform.system()=="Windows":
entry_points['console_scripts']=[
'didyoureadme_shortcuts=didyoureadme.shortcuts:create',
]
#version
__version__= None
with open('didyoureadme/version.py', encoding='utf-8') as f:
for line in f.readlines():
if line.find("__version__ =")!=-1:
__version__=line.split("'")[1]
setup(name='didyoureadme',
version=__version__,
description='System to control who and when a group reads a document send by mail. It uses postgresql to store information',
long_description=long_description,
long_description_content_type='text/markdown',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3',
],
keywords='mail read when who',
url='https://github.com/Turulomio/didyoureadme',
author='Turulomio',
author_email='turulomio@yahoo.es',
license='GPL-3',
packages=['didyoureadme'],
entry_points = entry_points,
install_requires= [
'setuptools',
'psycopg2',
'pytz',
'PyQt5;platform_system=="Windows"',
'pywin32;platform_system=="Windows"',
], #PyQt5 doesn't have egg-info in Gentoo, so I remove it to install it with ebuild without making 2 installations. Should be added manually when using pip to install
data_files=data_files,
cmdclass={
'doxygen': Doxygen,
'doc': Doc,
'uninstall':Uninstall,
'compile': Compile,
'procedure': Procedure,
'pyinstaller': PyInstaller,
},
zip_safe=False,
include_package_data=True
)