forked from Ultimaker/cura-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_osx.py.in
125 lines (114 loc) · 4.67 KB
/
setup_osx.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
# Copyright (c) 2015 Ultimaker B.V.
# Uranium is released under the terms of the AGPLv3 or higher.
#
# This is a setup.py script generated by py2applet
#
# Usage:
# python setup.py py2app
from setuptools import setup
import UM
import cura
import os
import glob
import shutil
PLIST = {
"CFBundleDocumentTypes": [
{
"CFBundleTypeExtensions": [
"*"
],
"CFBundleTypeRole": "Viewer",
"CFBundleTypeName": "Model Files"
}
]
}
OPTIONS = {
"argv_emulation": False,
"includes": [
"sip",
"ctypes",
"UM",
"cura",
"PyQt5.QtNetwork",
"PyQt5._QOpenGLFunctions_2_0",
"serial",
"Arcus",
"xml.etree",
"xml.etree.ElementTree",
"zeroconf",
"uuid",
],
"resources": [
"inst/lib/plugins",
"inst/lib/qml",
"inst/lib/cura",
"inst/lib/uranium",
"inst/share/cura",
"inst/share/uranium",
"inst/lib/python3.4/site-packages/UM/Qt/qml",
],
"iconfile": "@CMAKE_SOURCE_DIR@/cura.icns",
"plist": PLIST
}
# Extend options.includes to include all files from the UM package.
for dirpath, dirnames, filenames in os.walk(os.path.dirname(UM.__file__)):
if "__" in dirpath:
continue
module_path = dirpath.replace(os.path.dirname(UM.__file__), "UM")
module_path = module_path.split(os.path.sep)
module_name = ".".join(module_path)
if os.path.isfile(dirpath + "/__init__.py"):
OPTIONS["includes"] += [module_name]
for filename in filenames:
if "__" in filename or not filename.endswith(".py"):
continue
OPTIONS["includes"] += [module_name + "." + os.path.splitext(filename)[0]]
for dirpath, dirnames, filenames in os.walk(os.path.dirname(cura.__file__)):
if "__" in dirpath:
continue
module_path = dirpath.replace(os.path.dirname(cura.__file__), "cura")
module_path = module_path.split(os.path.sep)
module_name = ".".join(module_path)
if os.path.isfile(dirpath + "/__init__.py"):
OPTIONS["includes"] += [module_name]
for filename in filenames:
if "__" in filename or not filename.endswith(".py"):
continue
OPTIONS["includes"] += [module_name + "." + os.path.splitext(filename)[0]]
setup(
name="Cura",
app=["inst/bin/cura_app.py"],
version="@CURA_MAJOR_VERSION@.@CURA_MINOR_VERSION@.@CURA_PATCH_VERSION@",
author="Ultimaker",
url="http://software.ultimaker.com/",
license="GNU AFFERO GENERAL PUBLIC LICENSE (AGPL)",
options={"py2app": OPTIONS},
setup_requires=['py2app'],
)
# Copy the backend executable
print("Copying CuraEngine to Contents/MacOS")
shutil.copy("inst/bin/CuraEngine", "dist/Cura.app/Contents/MacOS/CuraEngine")
# Remove all *_debug.x.dylib files since we do not need them but py2app copies
# them anyway.
for path, dirs, files in os.walk("dist/Cura.app/Contents"):
for file in files:
if "debug" in file:
print("Removing {0}".format(file))
os.remove(os.path.join(path, file))
# Py2App does not handle @rpath properly and fails to find the required libraries.
# So we need to copy it manually.
shutil.copy("inst/lib/libQt5Core.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5Core.5.dylib")
shutil.copy("inst/lib/libQt5Gui.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5Gui.5.dylib")
shutil.copy("inst/lib/libQt5MacExtras.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5MacExtras.5.dylib")
shutil.copy("inst/lib/libQt5Network.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5Network.5.dylib")
shutil.copy("inst/lib/libQt5OpenGL.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5OpenGL.5.dylib")
shutil.copy("inst/lib/libQt5Qml.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5Qml.5.dylib")
shutil.copy("inst/lib/libQt5Quick.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5Quick.5.dylib")
shutil.copy("inst/lib/libQt5QuickWidgets.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5QuickWidgets.5.dylib")
shutil.copy("inst/lib/libQt5Svg.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5Svg.5.dylib")
shutil.copy("inst/lib/libQt5Widgets.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5Widgets.5.dylib")
shutil.copy("inst/lib/libQt5Xml.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5Xml.5.dylib")
shutil.copy("inst/lib/libQt5DBus.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5DBus.5.dylib")
shutil.copy("inst/lib/libQt5PrintSupport.5.dylib", "dist/Cura.app/Contents/Frameworks/libQt5PrintSupport.5.dylib")
# Ensure we set the right @rpath value.
os.system("install_name_tool -add_rpath @executable_path/../Frameworks dist/Cura.app/Contents/MacOS/Cura")