-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcx_setup.py
More file actions
116 lines (98 loc) · 3.03 KB
/
Copy pathcx_setup.py
File metadata and controls
116 lines (98 loc) · 3.03 KB
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
import os
import sys
from setuptools.config import read_configuration
import cx_Freeze
import pytest
import platform
def get_project_metadata():
path = os.path.abspath(os.path.join(os.path.dirname(__file__), "setup.cfg"))
return read_configuration(path)["metadata"]
metadata = get_project_metadata()
def create_msi_tablename(python_name, fullname):
shortname = python_name[:6].replace("_", "").upper()
longname = fullname
return "{}|{}".format(shortname, longname)
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
MSVC = os.path.join(PYTHON_INSTALL_DIR, 'vcruntime140.dll')
def get_tests():
root = "tests"
test_files = []
for x in filter(lambda x: x.is_file and os.path.splitext(x.name)[1] == ".py", os.scandir(root)):
relative_path = os.path.join(root, x.name)
absolute_path = x.path
test_files.append((absolute_path, relative_path))
print("Found files {}".format(", ".join(x[0] for x in test_files)))
return test_files
INCLUDE_FILES = [
"documentation.url",
"setup.cfg"
] + get_tests()
directory_table = [
(
"ProgramMenuFolder", # Directory
"TARGETDIR", # Directory_parent
"PMenu|Programs", # DefaultDir
),
(
"PMenu", # Directory
"ProgramMenuFolder", # Directory_parent
create_msi_tablename(metadata["name"], "PyHathiPrep")
),
]
shortcut_table = [
(
"startmenuShortcutDoc", # Shortcut
"PMenu", # Directory_
"{} Documentation".format(create_msi_tablename(metadata["name"], "PyHathiPrep")),
"TARGETDIR", # Component_
"[TARGETDIR]documentation.url", # Target
None, # Arguments
None, # Description
None, # Hotkey
None, # Icon
None, # IconIndex
None, # ShowCmd
'TARGETDIR' # WkDir
),
]
if os.path.exists(MSVC):
INCLUDE_FILES.append(MSVC)
build_exe_options = {
"includes": pytest.freeze_includes(),
"include_msvcr": True,
"packages": [
"os",
'pytest',
"packaging",
"six",
"appdirs",
"pytz",
"tzlocal",
"pyhathiprep",
"setuptools",
],
"namespace_packages": ["ruamel.yaml"],
"excludes": ["tkinter"],
"include_files": INCLUDE_FILES,
}
target_name = 'pyhathiprep.exe' if platform.system() == "Windows" else 'pyhathiprep'
cx_Freeze.setup(
name="PyHathiPrep",
description=metadata["description"],
license="University of Illinois/NCSA Open Source License",
version=metadata["version"],
author=metadata["author"],
author_email=metadata["author_email"],
options={
"build_exe": build_exe_options,
"bdist_msi": {
"upgrade_code": "{D08D5F4C-EF6E-4D16-939C-2C441DF88675}",
"data": {
"Shortcut": shortcut_table,
"Directory": directory_table
},
}
},
executables=[cx_Freeze.Executable("pyhathiprep/__main__.py",
targetName=target_name, base="Console")],
)