forked from anyc/londonlaw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
100 lines (85 loc) · 3.75 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
#!/usr/bin/env python
#
# Distutils installation script for London Law
#
from distutils.core import setup
import os, string, sys
# Generate the binary translation files
if 'sdist' in sys.argv:
os.system("cd londonlaw/locale && make mo")
os.system("cd doc && make")
# Read off the PREFIX value, so we can tell londonlaw where to find its
# data files (FIXME: is there a clean way to handle this through distutils?)
if 'sdist' not in sys.argv and 'clean' not in sys.argv:
DATA_PREFIX=os.path.normpath(sys.prefix)+"/share/" # default
for arg in sys.argv:
index = string.find(arg, "--install-data=")
if index > -1:
DATA_PREFIX = os.path.normpath(arg[(index+len("--install-data=")):])
config = open("londonlaw/common/config.py", "w")
config.write("MEDIAROOT = \"" + os.path.join(DATA_PREFIX,"londonlaw/guiclient") + "\"\n")
config.close()
# Append "dirname" and its datafiles to the list of files to install.
# This is called once per directory via os.path.walk().
def appendImageFiles(installList, dirname, files):
newFiles = []
for file in files:
if file[-3:] != ".id" and file[-3:] != "=id": # don't install Arch id files
fullFile = os.path.join(dirname, file)
if os.path.isfile(fullFile):
newFiles.append(fullFile)
if newFiles != []:
splitDir = dirname.split('/')
dirname = ('/').join(splitDir[1:])
installList.append( (os.path.join(DATA_PREFIX, 'londonlaw', dirname), newFiles) )
#installList.append( (dirname, newFiles) )
def appendMOFiles(installList, dirname, files):
newFiles = []
for file in files:
if file[-3:] == ".mo":
newFiles.append(os.path.join(dirname, file))
if newFiles != []:
splitDir = dirname.split('/')
dirname = ('/').join(splitDir[1:])
installList.append( (os.path.join(DATA_PREFIX, 'londonlaw', dirname), newFiles) )
#installList.append( (dirname, newFiles) )
# Get all data files by walking through the proper directory trees
# and calling 'appendDataFiles'.
def getDataFilesList():
installList = []
os.path.walk('londonlaw/guiclient/images', appendImageFiles, installList)
os.path.walk('londonlaw/locale', appendMOFiles, installList)
return installList
# Run the distutils setup.
setup(name = "londonlaw",
version = "0.3.0pre1",
description = "networked multiplayer manhunting board game",
author = "Paul J. Pelzl",
author_email = "pelzlpj@eecs.umich.edu",
maintainer = "Paul J. Pelzl",
maintainer_email = "pelzlpj@eecs.umich.edu",
url = "http://www.eecs.umich.edu/~pelzlpj/londonlaw",
license = "GNU General Public License, Version 2",
platforms = "*nix/X11, OS X, Win32",
keywords = "Scotland Yard board game multiplayer",
long_description = (
"London Law is a networked multiplayer adaptation of the classic\n" +
"Scotland Yard board game. Mr. X must evade a number of detectives by\n" +
"carefully concealing his movements across London. One of only a\n" +
"handful of asymmetric board games (Mr. X and the detectives have\n" +
"different goals and abilities)." ),
packages = [ 'londonlaw', # install all the .py files
'londonlaw.common',
'londonlaw.server',
'londonlaw.guiclient',
'londonlaw.aiclients',
'londonlaw.adminclient'],
scripts = [ 'londonlaw/london-server', # install the executable scripts
'londonlaw/london-client',
'londonlaw/london-admin'],
data_files = getDataFilesList() # install the game media and documentation
)
# Reset 'config.py' for the source distribution.
config = open("londonlaw/common/config.py", "w")
config.write("MEDIAROOT = \"guiclient\"\n")
config.close()