-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcx_setup.py
More file actions
107 lines (90 loc) · 3.03 KB
/
cx_setup.py
File metadata and controls
107 lines (90 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
"""DEPRECATED!!!"""
import os
import re
import sys
from setuptools.config import read_configuration
from cx_Freeze import setup, Executable
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)):
test_files.append(os.path.join(root, x.name))
print("Found files {}".format(", ".join(test_files)))
return test_files
INCLUDE_FILES = [
"documentation.url",
"setup.cfg"
# TODO: BUILD DOCUMENTATION
] + get_tests()
directory_table = [
(
"ProgramMenuFolder", # Directory
"TARGETDIR", # Directory_parent
"PMenu|Programs", # DefaultDir
),
(
"PMenu", # Directory
"ProgramMenuFolder", # Directory_parent
create_msi_tablename(metadata['name'], "DS Hathi Trust Validate")
),
]
shortcut_table = [
(
"startmenuShortcutDoc", # Shortcut
"PMenu", # Directory_
"{} Documentation".format(create_msi_tablename(metadata['name'], "DS Hathi Trust Validate")),
"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": ["queue", "atexit", "appdirs", 'pkg_resources'] + pytest.freeze_includes(),
"include_msvcr": True,
"packages": ["os", "lxml", "packaging", "six", "appdirs", "hathi_validate", "setuptools", "html", "importlib_metadata"],
"excludes": ["tkinter"],
"include_files": INCLUDE_FILES,
}
version_extractor = re.compile(r"\d+[.]\d+[.]\d+")
version = version_extractor.search(metadata['version']).group(0)
target_name = "hathivalidate.exe" if platform.system() == "Windows" else "hathivalidate"
setup(
name="DS Hathi Trust Validate",
description=metadata['description'],
version=version,
license=metadata['license'],
author=metadata['author'],
author_email=metadata['author_email'],
options={
"build_exe": build_exe_options,
"bdist_msi": {
"upgrade_code": "{9BCAE3C6-BF07-409A-9846-4C7BB474120A}",
"data": {
"Shortcut": shortcut_table,
"Directory": directory_table
}
}
},
executables=[Executable("hathi_validate/cli.py",
targetName=target_name, base="Console")],
)