-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
115 lines (97 loc) · 3.82 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
# Copyright (C) 2012 Bob Bowles <[email protected]>
#
# 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/>.
# Work around mbcs bug in distutils. (for wininst)
# http://bugs.python.org/issue10945
import codecs
try:
codecs.lookup('mbcs')
except LookupError:
ascii = codecs.lookup('ascii')
func = lambda name, enc = ascii: {True: enc}.get(name == 'mbcs')
codecs.register(func)
from distutils.core import setup
import os
# locale root
targetLocaleRoot = ''
# TODO Windows stuff needs fixing
if os.name == 'nt': targetLocaleRoot = os.path.join('C:', 'Python32')
elif os.name == 'posix': targetLocaleRoot = os.path.join('/', 'usr', 'share')
# sort out the data files for the app
dataFiles = []
# sort out package data (e.g. gifs etc used in the app)
fileList = []
packageDir = 'src'
packageRoot = os.path.join(packageDir, 'UXBgtk')
# get a reference to the version number from the package being built
import sys
sys.path.insert(0, packageDir)
from UXBgtk import __version__
dataRoot = 'images'
#for dir in os.listdir(os.path.join(packageRoot, dataRoot)):
# path = os.path.join(packageRoot, dataRoot, dir)
# if os.path.isdir(path):
for file in os.listdir(os.path.join(packageRoot, dataRoot)):
fileList.append(os.path.join(dataRoot, file))
# add glade and css files, sort the results
fileList.append('UXBgtk.css')
fileList.append('UXBgtk.glade')
fileList.sort()
packageData = {'UXBgtk': fileList}
# detect Ubuntu/Unity to decide what to do with the launcher
if os.name == 'posix':
# # try to detect Unity. This is superfluous here
# from subprocess import Popen, PIPE
# pipe = Popen('ps aux | grep unity', shell=True, stdout=PIPE).stdout
#
# # now scan the output for some unity tell-tale
# if 'unity-panel-service' in str(pipe.read()):
# print('Yay! Unity detected! Adding desktop launcher')
# dataFiles.append((os.path.join(targetLocaleRoot, 'applications'),
# ['UXBgtk.desktop']))
# else:
# print('No Unity detected')
print('Linux detected! Adding desktop launcher')
dataFiles.append((os.path.join(targetLocaleRoot, 'applications'),
['UXBgtk.desktop']))
else:
print('Not posix')
# now run setup
setup(
name='UXBgtk',
version=__version__,
description='A Gtk version of the Mines game intended for casual play.',
long_description=open('README.txt').read(),
author='Bob Bowles',
author_email='[email protected]',
url='http://pypi.python.org/pypi/UXBgtk',
license='GNU General Public License v3 (GPLv3)', # TODO belt-n-braces??
keywords=["Mines", ],
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable",
"Environment :: Other Environment",
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: POSIX :: Linux", # so far only tested on Linux
"Topic :: Games/Entertainment :: Board Games",
],
package_dir={'': packageDir},
packages=['UXBgtk', ],
requires=['gi (>=3.4.2)'], # TODO needs Python >3.3
package_data=packageData,
data_files=dataFiles,
)