forked from gmarull/pyside2-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.py
executable file
·93 lines (62 loc) · 1.91 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
#!/usr/bin/env python
import re
import os
from subprocess import check_call
from setuptools import setup, find_packages, Command
from setuptools.command.sdist import sdist
cmdclass = {}
try:
from pyqt_distutils.build_ui import build_ui
has_build_ui = True
except ImportError:
has_build_ui = False
try:
from sphinx.setup_command import BuildDoc
cmdclass['build_docs'] = BuildDoc
except ImportError:
pass
with open('app/__init__.py') as f:
_version = re.search(r'__version__\s+=\s+\'(.*)\'', f.read()).group(1)
if has_build_ui:
class build_res(build_ui):
"""Build UI, resources and translations."""
def run(self):
# build translations
check_call(['pylupdate5', 'app.pro'])
lrelease = os.environ.get('LRELEASE_BIN')
if not lrelease:
lrelease = 'lrelease'
check_call([lrelease, 'app.pro'])
# build UI & resources
build_ui.run(self)
cmdclass['build_res'] = build_res
class custom_sdist(sdist):
"""Custom sdist command."""
def run(self):
self.run_command('build_res')
sdist.run(self)
cmdclass['sdist'] = custom_sdist
class bdist_app(Command):
"""Custom command to build the application. """
description = 'Build the application'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
self.run_command('build_res')
check_call(['pyinstaller', '-y', 'app.spec'])
cmdclass['bdist_app'] = bdist_app
setup(name='app',
version=_version,
packages=find_packages(),
description='PyQt5 Boilerplate',
author='Gerard Marull-Paretas',
author_email='[email protected]',
license='MIT',
url='http://www.teslabs.com',
entry_points={
'gui_scripts': ['app=app.__main__:main'],
},
cmdclass=cmdclass)