forked from Naburimannu/libtcodpy-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist-windows.py
60 lines (48 loc) · 1.76 KB
/
dist-windows.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
"""
Create a Windows executable using py2exe.
"""
from distutils.core import setup
import py2exe
import os
import sys
sys.argv.append('py2exe')
target_file = 'roguelike.py'
assets_dir = '.\\'
excluded_file_types = ['py', 'pyc', 'pyproj',
'sdf', 'sln', 'spec']
excluded_file_names = ['.gitattributes', '.gitignore', 'savegame']
excluded_directories = ['.git', '.vs']
def get_data_files(base_dir, target_dir, list=[]):
"""
" * get_data_files
" * base_dir: The full path to the current working directory.
" * target_dir: The directory of assets to include.
" * list: Current list of assets. Used for recursion.
" *
" * returns: A list of relative and full path pairs. This is
" * specified by distutils.
"""
for file in os.listdir(base_dir + target_dir):
full_path = base_dir + target_dir + file
if os.path.isdir(full_path):
if (file in excluded_directories):
continue
get_data_files(base_dir, target_dir + file + '\\', list)
elif os.path.isfile(full_path):
if (len(file.split('.')) == 2 and file.split('.')[1] in excluded_file_types):
continue
if (file in excluded_file_names):
continue
list.append((target_dir, [full_path]))
return list
my_files = get_data_files(sys.path[0] + '\\', assets_dir)
opts = { 'py2exe': {
'ascii':'True',
'excludes':['_ssl','_hashlib'],
'includes' : ['anydbm', 'dbhash'],
'bundle_files':'1',
'compressed':'True'}}
setup(console=[target_file],
data_files=my_files,
zipfile=None,
options=opts)