-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
154 lines (131 loc) · 4.38 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##############################################################################
##
## This file is part of qarbon
##
## http://www.qarbon.org/
##
## Copyright 2013 European Synchrotron Radiation Facility, Grenoble, France
##
## qarbon is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## qarbon is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with qarbon. If not, see <http://www.gnu.org/licenses/>.
##
##############################################################################
from __future__ import print_function
__docformat__ = "restructuredtext"
__package_name__ = 'qarbon'
import os
from distutils.core import setup
from distutils.version import StrictVersion
try:
import sphinx
sphinx_version = StrictVersion(sphinx.__version__)
sphinx_version_min = StrictVersion("1.0.0")
if sphinx_version < sphinx_version_min:
sphinx = None
except:
sphinx = None
def abspath(*path):
"""A method to determine absolute path for a given relative path to the
directory where this setup.py script is located"""
setup_dir = os.path.dirname(os.path.abspath(__file__))
return os.path.join(setup_dir, *path)
def get_release_info():
name = "release"
release_dir = abspath(__package_name__)
import imp
data = imp.find_module(name, [release_dir])
return imp.load_module(name, *data)
def get_script_files():
scripts_dir = abspath('scripts')
scripts = []
items = os.listdir(scripts_dir)
for item in items:
# avoid hidden files
if item.startswith("."):
continue
abs_item = os.path.join(scripts_dir, item)
# avoid non files
if not os.path.isfile(abs_item):
continue
# avoid files that have any extension
if len(os.path.splitext(abs_item)[1]) > 0:
continue
# avoid compiled version of script
if item.endswith('c') and item[:-1] in items:
continue
# avoid any core dump... of course there isn't any :-) but just in case
if item.startswith('core'):
continue
scripts.append('scripts/' + item)
return scripts
if sphinx:
from sphinx.setup_command import BuildDoc
class build_doc(BuildDoc):
def has_doc_api(self):
return True
def run(self):
try:
BuildDoc.run(self)
except Exception as e:
self.warn("Failed to build doc. Reason: %s" % str(e))
def main():
Release = get_release_info()
author = Release.authors[0]
package_name = Release.name
cmd_class = {}
if sphinx:
cmd_class['build_doc'] = build_doc
packages = [
'qarbon',
'qarbon.doc',
'qarbon.external',
'qarbon.external.enum',
'qarbon.external.ordereddict',
'qarbon.external.qt',
'qarbon.qt',
'qarbon.qt.gui',
'qarbon.qt.gui.style',
'qarbon.qt.gui.ui',
'qarbon.test'
]
package_data = {
'qarbon': ['resource/icons/controls/*',
'resource/icons/designer/*',
'resource/icons/led/*',
'resource/icons/theme/*', ],
'qarbon.qt.gui.ui': ['*.ui'],
}
setup(name=Release.name,
version=Release.version,
description=Release.description,
long_description=Release.long_description,
classifiers=Release.classifiers,
url=Release.url,
download_url=Release.download_url,
keywords=Release.keywords,
author=author[1],
author_email=author[2],
maintainer=author[1],
maintainer_email=author[2],
packages=packages,
package_dir={package_name: package_name},
package_data=package_data,
data_files=[],
scripts=[],
provides=[package_name],
requires=[],
cmdclass=cmd_class)
if __name__ == "__main__":
main()