-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
133 lines (118 loc) · 3.21 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
import os
import subprocess
from glob import glob
from setuptools import setup
from distutils.cmd import Command
from distutils.command.build_py import build_py
from distutils.command.sdist import sdist
# Build the generated content.
gendir = os.path.join(os.path.dirname(__file__), 'chronosGui2/generated')
def generate(dry_run=False):
makeopts = ' --dry-run' if dry_run else ''
os.system('make -C ' + gendir + makeopts)
# Return the package version - either by querying the git
# repository, or falling back to the generated version.py
# from the source distribution.
def git_version():
try:
vers = subprocess.check_output(['git', 'describe', '--tags', '--always'],
stderr=subprocess.DEVNULL)
return vers.decode('utf-8').strip()
except:
pass
try:
verdata = {}
with open(os.path.join(gendir, 'version.py')) as fp:
exec(fp.read(), verdata)
return verdata['__version__']
except:
return 'unknown'
# PEP-440 imposes its own version requirements, which differ from what
# we get in a git-describe. So tokenize the git version and translate.
def py_version(gitvers):
# Start with the leading part of the version.
vchunks = gitvers.split('-')
output = vchunks[0]
for x in vchunks[1:]:
# Translate pre-release names.
if x == 'alpha':
output += 'a'
elif x == 'beta':
output += 'b'
elif x.startswith('rc'):
output += x
# If it's a pure integer, then it's probably a rev-count.
elif x.isdigit():
output += '.post' + x
break
# Otherwise, interpret this as a local version.
else:
output += '+' + x
return output
# Generate ui files for developement.
class gui2_build_ui(Command):
"""A custom command to generate UI files."""
description = 'Generate PyQt UI files.'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
generate(self.dry_run)
# Generate some python code from Qt files.
class gui2_build_py(build_py):
def run(self):
# Build generated code.
generate(self.dry_run)
# Call the super
build_py.run(self)
class gui2_sdist(sdist):
#sdist = source distribution
def run(self):
# Build generated code.
generate(self.dry_run)
# Call the super.
sdist.run(self)
setup(
name='chronosGui2',
version=py_version(git_version()),
description='Chronos 1.4 back-of-camera Python QT 5 GUI',
url='https://github.com/krontech/chronos-gui-2',
author='David Roberts',
author_email='ddr@krontech.ca',
classifiers=[
"License :: OSI Approved",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Programming Language :: Python"
],
package_data={
'chronosGui2': ['forms/*.ui', 'read_jog_wheel_encoder.c'],
'chronosGui2/generated': ['*.qrc'],
},
entry_points={
'console_scripts': [
'chronosGui2=chronosGui2.__main__:main'
]
},
packages=[
'chronosGui2',
'chronosGui2/widgets',
'chronosGui2/screens',
'chronosGui2/input_panels',
'chronosGui2/generated',
'chronosGui2/generated/chronos',
'chronosGui2/generated/txpro',
],
data_files=[
('/etc/', ['util/chronos-gui2.conf']),
('/var/camera/scripts/', glob('docs_src/example-scripts/*'))
],
license='GPLv3+',
# Command overrides
cmdclass={
'build_py': gui2_build_py,
'build_ui': gui2_build_ui,
'sdist': gui2_sdist
}
)