-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
144 lines (114 loc) · 4.69 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
#!/usr/bin/env python3
# -*-coding:utf-8-*-
"""Setup for SpiceGUI"""
# SpiceGUI
# Copyright (C) 2014-2015 Rafael Bailón-Ruiz <rafaelbailon@ieee.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from setuptools import find_packages
from distutils.core import setup
from distutils.command.build import build
from distutils.command.install_data import install_data
import subprocess
import sys
import spicegui.config
__prj__ = spicegui.config.PROGRAM_NAME_LOWER
__author__ = "Rafael Bailón-Ruiz"
__mail__ = "rafaelbailon at ieee dot org"
__url__ = spicegui.config.PROGRAM_WEBSITE
__source__ = spicegui.config.PROGRAM_WEBSITE
__version__ = spicegui.config.VERSION
__license__ = "GPL3"
dependencies = []
class MyBuild(build):
@classmethod
def compile_message_catalog(cls):
try:
subprocess.call(['msgfmt', '-o',
'spicegui/locale/es/LC_MESSAGES/spicegui.mo',
'spicegui/locale/es/LC_MESSAGES/spicegui.po'])
except:
print("ERROR: unable to compile \"es\" message catalog",
file=sys.stderr)
def run(self):
if sys.platform.startswith('linux'):
self.compile_message_catalog()
build.run(self)
class MyInstallData(install_data):
def update_icon_cache(self):
try:
root = self.root if self.root is not None else ''
subprocess.call(['gtk-update-icon-cache', root + '/usr/share/icons/hicolor'])
except:
print("ERROR: unable to update icon cache", file=sys.stderr)
@classmethod
def update_desktop_database(cls):
try:
subprocess.call(['update-desktop-database'])
except:
print("ERROR: unable to update desktop database", file=sys.stderr)
def glib_compile_schemas(self):
try:
root = self.root if self.root is not None else ''
subprocess.call(['glib-compile-schemas', root + '/usr/share/glib-2.0/schemas/'])
except:
print("ERROR: unable to compile GSettings schemas", file=sys.stderr)
def run(self):
install_data.run(self)
if sys.platform.startswith('linux'):
self.update_desktop_database()
self.update_icon_cache()
self.glib_compile_schemas()
CMDCLASS = {'install_data': MyInstallData}
params = {
"name": __prj__,
"version": __version__,
"description": __doc__,
"author": __author__,
"author_email": __mail__,
"url": __url__,
"license": __license__,
"keywords": "spice gui circuit simulator",
"classifiers": ["Development Status :: Development Status :: 4 - Beta",
"Topic :: Engineering",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3"],
"install_requires": dependencies,
# include all resources
"include_package_data": True,
"package_data": {'spicegui': ['data/*.glade', 'data/*.ui', 'locale/es/LC_MESSAGES/spicegui.mo']},
"packages": find_packages(),
"data_files": [('/usr/share/applications/', ['spicegui/data/SpiceGUI.desktop']),
('/usr/share/glib-2.0/schemas/', ['spicegui/data/org.rafael1193.spicegui.gschema.xml']),
('/usr/share/gtksourceview-3.0/language-specs/', ['spicegui/data/spice-netlist.lang']),
('/usr/share/icons/hicolor/scalable/apps/', ['spicegui/data/spicegui.svg']),
('/usr/share/icons/hicolor/symbolic/apps/', ['spicegui/data/spicegui-symbolic.svg']),
('/usr/share/appdata/', ['spicegui/data/SpiceGUI.appdata.xml'])],
# auto create scripts
"entry_points": {
'console_scripts': [
'spicegui = spicegui:start',
],
'gui_scripts': [
'spicegui = spicegui:start',
]
},
'cmdclass': {'build': MyBuild,
'install_data': MyInstallData}
}
setup(**params)