forked from dripton/Slugathon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·111 lines (91 loc) · 3.46 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
#!/usr/bin/env python
__copyright__ = "Copyright (c) 2009-2012 David Ripton"
__license__ = "GNU GPL v2"
from glob import glob
from distutils.core import setup
from distutils.command.install_data import install_data
import subprocess
import datetime
import sys
import os
VERSION = "0.1"
class install_data_twisted(install_data):
"""Make sure data files are installed in package.
Yuck. Taken from an old version of Twisted's setup.py.
"""
def finalize_options(self):
self.set_undefined_options("install", ("install_lib", "install_dir"),)
install_data.finalize_options(self)
def head_commit():
"""Return the current commit of HEAD, or "" on failure."""
if sys.platform == "win32":
GIT = "git.exe"
else:
GIT = "git"
cmd = [GIT, "rev-list", "--max-count=1", "HEAD"]
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
stdout, unused = proc.communicate()
except Exception:
return ""
if proc.returncode != 0:
return ""
if stdout:
return stdout.strip()
else:
return ""
def timestamp():
"""Return the current UTC time in YYYYMMDDhhmmss form."""
utcnow = datetime.datetime.utcnow()
return utcnow.strftime("%Y%m%d%H%M%S")
def write_version_file():
"""Dump a file containing the version, timestamp, and commit to
docs/version.txt"""
version = "%s-%s-%s" % (VERSION, timestamp(), head_commit()[:7])
# Need to use a relative path here because we may not have installed yet.
with open("slugathon/docs/version.txt", "w") as fil:
fil.write("%s\n" % version)
# cd to the location of the setup.py file so relative paths work.
os.chdir(os.path.dirname(os.path.realpath(__file__)))
write_version_file()
setup(
name="slugathon",
version="%s-%s-%s" % (VERSION, timestamp(), head_commit()[:7]),
description="Fantasy battle board game",
author="David Ripton",
author_email="d+slugathon@ripton.net",
url="https://github.com/dripton/Slugathon/",
download_url="https://github.com/dripton/Slugathon/zipball/master",
license="GPLv2",
packages=["slugathon", "slugathon.ai", "slugathon.data",
"slugathon.game", "slugathon.gui", "slugathon.net",
"slugathon.util"],
data_files=[
("slugathon/images/battlehex", glob("slugathon/images/battlehex/*")),
("slugathon/images/creature", glob("slugathon/images/creature/*")),
("slugathon/images/dice", glob("slugathon/images/dice/*")),
("slugathon/images/legion", glob("slugathon/images/legion/*")),
("slugathon/images/masterhex", glob("slugathon/images/masterhex/*")),
("slugathon/config", glob("slugathon/config/*")),
("slugathon/docs", glob("slugathon/docs/*")),
],
scripts=[
"bin/slugathon",
"bin/stresstest-slugathon",
"bin/set-all-slugathon-ai-passwords",
],
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: X11 Applications :: GTK",
"Framework :: Twisted",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Topic :: Games/Entertainment :: Board Games",
],
cmdclass={"install_data": install_data_twisted},
)