forked from Ultimaker/cura-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_win32.py.in
141 lines (123 loc) · 4.99 KB
/
setup_win32.py.in
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Copyright (c) 2015 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.
from distutils.core import setup
import py2exe
import UM
import UM.Qt
import cura
import os
import re
import shutil
import site
import Arcus
import scipy
import numpy
import numpy.core
import stl
import stl.mesh
# work around the limitation that shutil.copytree does not allow the target directory to exist
def copytree(src, dst, symlinks=False, ignore=None):
if not os.path.exists(dst):
os.makedirs(dst)
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
def findSubPackages(root_package_path, package_name):
includes = []
for dirpath, dirnames, filenames in os.walk(os.path.dirname(root_package_path)):
if "__" in dirpath:
continue
if "tests" in dirnames:
dirnames.remove("tests")
module_path = dirpath.replace(os.path.dirname(root_package_path), package_name)
module_path = module_path.split(os.path.sep)
module_name = ".".join(module_path)
if os.path.isfile(dirpath + "/__init__.py"):
includes.append(module_name)
for filename in filenames:
if "__" not in filename and os.path.splitext(filename)[1] in [".py", ".pyd"]:
includes.append(module_name + "." + os.path.splitext(filename)[0])
return includes
includes = [
"sip",
"ctypes",
"uuid",
"UM",
"PyQt5.QtNetwork",
"PyQt5._QOpenGLFunctions_2_0",
"serial",
"Arcus",
"xml.etree",
"xml.etree.ElementTree",
"cura",
"cura.OneAtATimeIterator",
"zeroconf"
]
# Include all the UM modules in the includes. As py2exe fails to properly find all the dependencies due to the plugin architecture.
includes += findSubPackages(UM.__file__, "UM")
includes += findSubPackages(cura.__file__, "cura")
includes += findSubPackages(scipy.__file__, "scipy")
includes += findSubPackages(stl.__file__, "stl")
# Filter out the known bad apples.
includes = [x for x in includes if x not in [
"scipy.interpolate.interpnd_info",
"scipy.misc.pilutil",
"scipy.special.generate_ufuncs",
"scipy.special._testutils",
"scipy.linalg._testutils",
"scipy._lib._testutils"]]
print("Removing previous distribution package")
shutil.rmtree("dist", True)
setup(
name="Cura",
version="@CURA_MAJOR_VERSION@.@CURA_MINOR_VERSION@.@CURA_PATCH_VERSION@",
author="Ultimaker",
author_email="[email protected]",
url="http://software.ultimaker.com/",
license="GNU AFFERO GENERAL PUBLIC LICENSE (AGPL)",
scripts=["inst/bin/cura_app.py"],
windows=[{"script": "inst/bin/cura_app.py", "dest_name": "Cura", "icon_resources": [(1, "@CMAKE_SOURCE_DIR@/cura.ico")]}],
#console=[{"script": "cura_app.py"}],
options={"py2exe": {"skip_archive": False, "includes": includes}}
)
print("Copying Cura plugins.")
copytree("@EXTERNALPROJECT_INSTALL_PREFIX@/lib/uranium/plugins", "dist/plugins", ignore = shutil.ignore_patterns("OBJWriter", "MLPWriter", "MLPReader"))
copytree("@EXTERNALPROJECT_INSTALL_PREFIX@/lib/cura/plugins", "dist/plugins")
print("Copying resources.")
copytree("@EXTERNALPROJECT_INSTALL_PREFIX@/share/uranium/resources", "dist/resources")
copytree("@EXTERNALPROJECT_INSTALL_PREFIX@/share/cura/resources", "dist/resources")
print("Copying Uranium QML.")
copytree("@EXTERNALPROJECT_INSTALL_PREFIX@/lib/python3.4/site-packages/UM/Qt/qml/UM", "dist/qml/UM")
qt_lib_dir = None
qt_bin_dir = None
if os.path.exists("@EXTERNALPROJECT_INSTALL_PREFIX@/lib/plugins"):
qt_lib_dir = "@EXTERNALPROJECT_INSTALL_PREFIX@/lib"
qt_bin_dir = "@EXTERNALPROJECT_INSTALL_PREFIX@/bin"
else:
import PyQt5.QtCore
qt_lib_dir = os.path.dirname(PyQt5.QtCore.__file__)
qt_bin_dir = os.path.dirname(PyQt5.QtCore.__file__)
print("Copying Qt5 plugins")
copytree(os.path.join(qt_lib_dir, "plugins"), "dist/PyQt5/plugins")
print("Copying QtQuick plugins")
copytree(os.path.join(qt_lib_dir, "qml"), "dist/qml")
print("Copying Qt5 svg library")
shutil.copy(os.path.join(qt_bin_dir, "Qt5Svg.dll"), "dist/Qt5Svg.dll")
print("Copying numpy DLLs")
numpy_core_dir = os.path.dirname(numpy.core.__file__)
for item in os.listdir(numpy_core_dir):
if item.endswith(".dll"):
shutil.copy(os.path.join(numpy_core_dir, item), os.path.join("dist", item))
print("Copying CuraEngine")
shutil.copy("@EXTERNALPROJECT_INSTALL_PREFIX@/bin/CuraEngine.exe", "dist/CuraEngine.exe")
shutil.copy("@compiler_dir@/libstdc++-6.dll", "dist/libstdc++-6.dll")
shutil.copy("@compiler_dir@/libwinpthread-1.dll", "dist/libwinpthread-1.dll")
try:
shutil.copy("@compiler_dir@/libgcc_s_seh-1.dll", "dist/libgcc_s_seh-1.dll")
except FileNotFoundError:
shutil.copy("@compiler_dir@/libgcc_s_dw2-1.dll", "dist/libgcc_s_dw2-1.dll")
os.rename("dist/cura_app.exe", "dist/Cura.exe")