|
1
|
|
|
import sys |
|
2
|
|
|
import os |
|
3
|
|
|
from setuptools import setup |
|
4
|
|
|
|
|
5
|
|
|
# ====================================== |
|
6
|
|
|
# Py2exe |
|
7
|
|
|
# use "python setup.py py2exe" to generate a windows package |
|
8
|
|
|
try: |
|
9
|
|
|
import py2exe |
|
10
|
|
|
except ImportError: |
|
11
|
|
|
pass |
|
12
|
|
|
|
|
13
|
|
|
# ====================================== |
|
14
|
|
|
current_dir = os.getcwd() |
|
15
|
|
|
os.chdir(os.path.join('..', '..')) |
|
16
|
|
|
sys.path.append(os.getcwd()) |
|
17
|
|
|
|
|
18
|
|
|
# Data files |
|
19
|
|
|
icon = os.path.join(os.getcwd(), |
|
20
|
|
|
'qtodotxt', 'ui', 'resources', 'qtodotxt.ico') |
|
21
|
|
|
|
|
22
|
|
|
def collect_resources(resources_root,resources): |
|
23
|
|
|
for file in os.listdir(resources_root): |
|
24
|
|
|
file_path=os.path.join(resources_root, file) |
|
25
|
|
|
if os.path.isfile(file_path): |
|
26
|
|
|
resources.append(file_path) |
|
27
|
|
|
|
|
28
|
|
View Code Duplication |
def collect_packages(path, package_name, packages, excludes=None): |
|
|
|
|
|
|
29
|
|
|
for dir in os.listdir(path): |
|
30
|
|
|
if excludes and dir in excludes: |
|
31
|
|
|
continue |
|
32
|
|
|
subpath = os.path.join(path, dir) |
|
33
|
|
|
if os.path.isdir(subpath): |
|
34
|
|
|
if os.path.exists(os.path.join(subpath, '__init__.py')): |
|
35
|
|
|
subpackage_name = dir |
|
36
|
|
|
if len(package_name) > 0: |
|
37
|
|
|
subpackage_name = package_name + '.' + subpackage_name |
|
38
|
|
|
packages.append(subpackage_name) |
|
39
|
|
|
collect_packages(subpath, subpackage_name, packages) |
|
40
|
|
|
|
|
41
|
|
|
packages = [] |
|
42
|
|
|
collect_packages('.', '', packages, excludes=['test']) |
|
43
|
|
|
|
|
44
|
|
|
resources=[] |
|
45
|
|
|
resources_root = os.path.join(os.getcwd(), 'qtodotxt', 'ui', 'resources') |
|
46
|
|
|
collect_resources(resources_root,resources) |
|
47
|
|
|
|
|
48
|
|
|
css=[] |
|
49
|
|
|
resources_root = os.path.join(os.getcwd(), 'qtodotxt', 'ui', 'resources','css') |
|
50
|
|
|
collect_resources(resources_root,css) |
|
51
|
|
|
# ====================================== |
|
52
|
|
|
# Setup parameters |
|
53
|
|
|
setup(name='qtodotxt', |
|
54
|
|
|
version='1.7', |
|
55
|
|
|
author='QTT Development Team', |
|
56
|
|
|
author_email='[email protected]', |
|
57
|
|
|
url='https://github.com/QTodoTxt/QTodoTxt', |
|
58
|
|
|
packages=packages, |
|
59
|
|
|
setup_requires=["py2exe"], |
|
60
|
|
|
|
|
61
|
|
|
data_files=[ |
|
62
|
|
|
('resources', resources), |
|
63
|
|
|
# You need to adapt file paths below to fit your development settins/environment |
|
64
|
|
|
# File paths are for WinPython-32bit-3.4.4.2Qt5 being installed in folder d:\Development\Python\QTodoTxt\WinPython-32bit-3.4.4.2Qt5 |
|
65
|
|
|
('platforms',[r'c:\Qt\Qt5.5.1\5.5\mingw492_32\plugins\platforms\qwindows.dll']), |
|
66
|
|
|
('platforms',[r'c:\Qt\Qt5.5.1\5.5\mingw492_32\plugins\platforms\qoffscreen.dll']), |
|
67
|
|
|
('platforms',[r'c:\Qt\Qt5.5.1\5.5\mingw492_32\plugins\platforms\qminimal.dll']), |
|
68
|
|
|
('resources/css', css) |
|
69
|
|
|
], |
|
70
|
|
|
|
|
71
|
|
|
# py2exe parameters |
|
72
|
|
|
windows=[ |
|
73
|
|
|
{ |
|
74
|
|
|
"script": "bin/qtodotxt.pyw", |
|
75
|
|
|
"icon_resources": [(0, icon)] |
|
76
|
|
|
} |
|
77
|
|
|
], |
|
78
|
|
|
options={ |
|
79
|
|
|
"py2exe": { |
|
80
|
|
|
"includes": ["argparse", "sip"], |
|
81
|
|
|
"dist_dir": os.path.join(current_dir, 'dist') |
|
82
|
|
|
}, |
|
83
|
|
|
"build": { |
|
84
|
|
|
"build_base": os.path.join(current_dir, 'build') |
|
85
|
|
|
}, |
|
86
|
|
|
} |
|
87
|
|
|
) |
|
88
|
|
|
|