-
Notifications
You must be signed in to change notification settings - Fork 1
/
cx_setup.py
114 lines (99 loc) · 3.11 KB
/
cx_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
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
# -*- coding: utf-8 -*-
"""Setup config for cx_freeze (build)"""
import distutils
import os.path
from pathlib import Path
from cx_Freeze import Executable, setup
import opcode
# Derive Package Paths Dynamically
PYTHON_INSTALL_DIR = os.path.dirname(
os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(
PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(
PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')
# opcode is not a virtualenv module,
# so we can use it to find the stdlib; this is the same
# trick used by distutils itself it installs itself into the virtualenv
DISTUTILS_PATH = os.path.join(os.path.dirname(opcode.__file__), 'distutils')
VERSION_DICT = {}
with open("tagmaps/version.py") as fp:
exec(fp.read(), VERSION_DICT) # pylint: disable=W0122
VERSION = VERSION_DICT['__version__']
# Dependencies are automatically detected,
# but it might need fine tuning.
INCLUDES_MOD = [
"tkinter.filedialog",
'numpy.core._methods',
'numpy.lib.format',
'matplotlib.backends.backend_tkagg',
'seaborn',
'seaborn.cm',
'scipy.sparse.csgraph',
'argparse',
'scipy.sparse.csgraph._validation',
'numpy.core._dtype_ctypes',
'scipy._distributor_init',
'multiprocessing'
]
# windows pipenv:
# copy tcl86t.dll, tk86t.dll and sqlite3.dll
# to venv_folder/DLLs/*
INCLUDE_FOLDERS_FILES = [
(DISTUTILS_PATH, 'distutils'),
(os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
os.path.join('lib', 'tcl86t.dll'),
),
(os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
os.path.join('lib', 'tk86t.dll'),
),
(os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'sqlite3.dll'),
os.path.join('lib', 'sqlite3.dll'),
),
'resources/01_Input/',
'resources/00_Config/',
'resources/00_generateClusters_OnlyEmoji.cmd',
'resources/00_generateClusters_OnlyPhotoLocations.cmd',
'resources/00_generateClusters_OnlyTags.cmd',
('tagmaps/matplotlibrc',
"matplotlibrc")
]
PACKAGES_MOD = ["tkinter", "hdbscan"]
EXCLUDES_MOD = [
"scipy.spatial.cKDTree",
"distutils"]
# GUI applications require a different base on Windows
# (the default is for a console application).
BASE = None
EXECUTABLES = [
Executable('tagmaps/__main__.py',
base=BASE,
targetName="tagmaps.exe")
]
BUILD_NAME = f'TagMaps-Win-{VERSION}'
setup(name="tagmaps",
version=VERSION,
description="Tag Clustering for Tag Maps",
options={
'build_exe': {
'includes': INCLUDES_MOD,
'include_files': INCLUDE_FOLDERS_FILES,
'packages': PACKAGES_MOD,
'excludes': EXCLUDES_MOD,
'optimize': 0,
'build_exe': (
Path.cwd() / 'build' / BUILD_NAME)
}
},
executables=EXECUTABLES)
# open issue Windows:
# after build, rename
# \lib\multiprocessing\Pool.pyc
# to pool.pyc
# see:
# https://github.com/anthony-tuininga/cx_Freeze/issues/353
BUILD_PATH_POOL = (
Path.cwd() / 'build' / BUILD_NAME /
'lib' / 'multiprocessing')
Path(BUILD_PATH_POOL / 'Pool.pyc').rename(
BUILD_PATH_POOL / 'pool.pyc')