-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
125 lines (112 loc) · 4.39 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
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from setuptools import setup, find_packages
from scriptcraft.utils import datafile_path
import os, sys
PROJECT_NAME = 'scriptcraft'
DIRECTORIES_WITH_DATA_FILES = ('graphic', 'maps', '_static')
# Empty 'games' directory is added to Windows distribution in build script.
def _fullsplit(path, result=None):
"""
Split a pathname into components (the opposite of os.path.join) in a
platform-neutral way.
"""
if result is None:
result = []
head, tail = os.path.split(path)
if head == '':
return [tail] + result
if head == path:
return result
return _fullsplit(head, [tail] + result)
def _find_packages():
packages = []
for dirpath, dirnames, filenames in os.walk(PROJECT_NAME):
for i, dirname in enumerate(dirnames):
if dirname.startswith('.'):
del dirnames[i]
if '__init__.py' in filenames:
packages.append('.'.join(_fullsplit(dirpath)))
return packages
def _find_data_files():
data_files = []
for directory in DIRECTORIES_WITH_DATA_FILES:
for dirpath, dirnames, filenames in os.walk(directory):
for i, dirname in enumerate(dirnames[:]):
if dirname.startswith('.'):
dirnames.remove(dirname)
if '__init__.py' in filenames:
pass
elif filenames:
data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames if not f.startswith('.')]])
data_files.append(('.', ['LICENSE.txt']))
return data_files
def _is_it_py2exe_compilation():
return 'py2exe' in sys.argv
if __name__ == "__main__":
packages = _find_packages()
data_files = _find_data_files()
if _is_it_py2exe_compilation():
print 'Detected py2exe installation/building.'
import py2exe
drive_c_path = r'Z:\\home\\chris\\.wine\\drive_c\\'
python_version = sys.version_info[0:2] # for example (2, 6)
python_version = "".join(map(str, python_version)) # for example "26"
assert python_version in ('26', '27'), ('Is it valid python version? ' +
python_version)
python_path = drive_c_path + "Python" + python_version + r'\\'
dlls = [
drive_c_path + r'windows\\system32\\python%s.dll' % python_version,
python_path + r'DLLs\\tcl85.dll',
python_path + r'DLLs\\tk85.dll',
]
data_files += [('.', dlls)]
data_files += [('.', [os.path.join('onlywindows', 'configuration.ini')])]
data_files += [('.', ['README.html'])]
else:
print 'Detected non-py2exe installation/building.'
data_files += [('.', ['configuration.ini'])]
kwargs = dict(
name=PROJECT_NAME,
version='0.2.0',
author = "Krzysztof Medrela",
author_email = "[email protected]",
description = "Scriptcraft programming game - program your units to fight against other players.",
long_description = open(datafile_path('README.rst'), 'r').read().decode('utf8'),
license = "GPLv3",
keywords = [PROJECT_NAME, 'programming game', 'game'],
url = "http://github.com/chrismedrela/scriptcraft",
classifiers = [
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Natural Language :: Polish",
"Operating System :: Unix",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 2 :: Only",
"Topic :: Games/Entertainment",
],
install_requires = [
'PIL==1.1.7',
],
packages = packages,
include_package_data = False,
data_files = data_files,
options = {
'py2exe' : {'includes':['Tkinter', 'tkFileDialog'],
'bundle_files':2,
'dist_dir':'dist/py2exe'},
},
entry_points = {
'gui_scripts': [
'scriptcraft = scriptcraft.client:run',
],
},
)
if _is_it_py2exe_compilation():
kwargs['zipfile'] = None
kwargs['windows'] = [
{'script':'scriptcraft/client.py',
'dest_base':'scriptcraft'},
]
setup(**kwargs)