forked from tKroopy/tkroopy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·66 lines (57 loc) · 2.57 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
# -*- coding: utf-8 -*-#
# Copyright: see copyright in the doc folder
# License: see license in the doc folder
#-----------------------------------------------------------------------------
#!/usr/bin/env python
from setuptools import setup
import py2exe
from glob import glob
import sys, shutil, os, zipfile
import datetime
# Switch True/False
# - test = True will compile the application into
test = True
name = 'tkroopy'
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
print 'Basedir: %s' % basedir
# Copy required C++ bindings over
sys.path.append(r'C:\Program Files (x86)\ArcGIS\Desktop10.2\bin\Microsoft.VC90.CRT')
data_files = [("Microsoft.VC90.CRT", glob(r'C:\Program Files (x86)\ArcGIS\Desktop10.2\bin\Microsoft.VC90.CRT\*.*'))]
# Include images in the build
data_files.append(('images', glob(os.path.join(basedir, r"%s\images/*.gif" % name))))
data_files.append(('scripts', glob(os.path.join(basedir, r"%s\scripts/*.py" % name))))
data_files.append(('logs', glob(os.path.join(basedir, r"%s\logs/*.py" % name))))
data_files.append(('database', glob(os.path.join(basedir, r"%s\database/*.*" % name))))
if test:
# Set the destination directory
dist_dir = os.path.join(basedir, name + ' Dev')
# Copy config files with the build
data_files.append(('config', glob(os.path.join(basedir, r"%s\config/*.*" % name))))
else:
# Set the destination directory
dist_dir = os.path.join(basedir, name)
# Create zip source files and insert into the archive directory
exclude = ['build']
with zipfile.ZipFile(os.path.join(basedir, r'Archive\%s_%s.zip' %(name, datetime.datetime.now().strftime('%Y%m%d'))), mode='w', compression=zipfile.ZIP_DEFLATED) as zf:
path = os.path.join(basedir, name)
for root, dirs, files in os.walk(path):
dirs[:] = [d for d in dirs if d not in exclude]
for file1 in files:
zf.write(os.path.join(root, file1), os.path.relpath(os.path.join(root, file1), os.path.join(path, '..')))
print 'Arciving: %s' % os.path.join(root, file1)
# This setup is suitable for "python setup.py develop".
setup(
windows=[name + '.py'],
data_files=data_files,
options = {
'py2exe': {
'packages': ['src', 'contrib'],
'includes': 'decimal',
#'excludes': ['_ssl','pyreadline', 'difflib', 'doctest', 'optparse', 'pickle', 'calendar'],
'dll_excludes':['msvcr71.dll'],
'optimize': 0,
'compressed': True,
'dist_dir': dist_dir
}
}
)