setup.py 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Copyright (c) 2015 Ultimaker B.V.
  2. # Cura is released under the terms of the AGPLv3 or higher.
  3. from distutils.core import setup
  4. import py2exe
  5. import UM
  6. import UM.Qt
  7. import cura
  8. import os
  9. import re
  10. import shutil
  11. import site
  12. # work around the limitation that shutil.copytree does not allow the target directory to exist
  13. def copytree(src, dst, symlinks=False, ignore=None):
  14. if not os.path.exists(dst):
  15. os.makedirs(dst)
  16. for item in os.listdir(src):
  17. s = os.path.join(src, item)
  18. d = os.path.join(dst, item)
  19. if os.path.isdir(s):
  20. copytree(s, d, symlinks, ignore)
  21. else:
  22. shutil.copy2(s, d)
  23. includes = ["sip", "ctypes", "UM", "PyQt5.QtNetwork", "PyQt5._QOpenGLFunctions_2_0", "serial", "Arcus", "google", "google.protobuf", "google.protobuf.descriptor", "xml.etree", "xml.etree.ElementTree", "cura", "cura.OneAtATimeIterator"]
  24. # Include all the UM modules in the includes. As py2exe fails to properly find all the dependencies due to the plugin architecture.
  25. for dirpath, dirnames, filenames in os.walk(os.path.dirname(UM.__file__)):
  26. if "__" in dirpath:
  27. continue
  28. module_path = dirpath.replace(os.path.dirname(UM.__file__), "UM")
  29. module_path = module_path.split(os.path.sep)
  30. module_name = ".".join(module_path)
  31. if os.path.isfile(dirpath + "/__init__.py"):
  32. includes += [module_name]
  33. for filename in filenames:
  34. if "__" in filename or not filename.endswith(".py"):
  35. continue
  36. includes += [module_name + "." + os.path.splitext(filename)[0]]
  37. print("Removing previous distribution package")
  38. shutil.rmtree("dist", True)
  39. setup(name="Cura",
  40. version="15.09.80",
  41. author="Ultimaker",
  42. author_email="a.hiemstra@ultimaker.com",
  43. url="http://software.ultimaker.com/",
  44. license="GNU AFFERO GENERAL PUBLIC LICENSE (AGPL)",
  45. scripts=["cura_app.py"],
  46. windows=[{"script": "cura_app.py", "dest_name": "Cura", "icon_resources": [(1, "icons/cura.ico")]}],
  47. #console=[{"script": "cura_app.py"}],
  48. options={"py2exe": {"skip_archive": False, "includes": includes}})
  49. print("Coping Cura plugins.")
  50. shutil.copytree(os.path.dirname(UM.__file__) + "/../plugins", "dist/plugins", ignore = shutil.ignore_patterns("ConsoleLogger", "OBJWriter", "MLPWriter", "MLPReader"))
  51. for path in os.listdir("plugins"):
  52. copytree("plugins/" + path, "dist/plugins/" + path)
  53. print("Coping resources.")
  54. copytree(os.path.dirname(UM.__file__) + "/../resources", "dist/resources")
  55. copytree("resources", "dist/resources")
  56. print("Coping Uranium QML.")
  57. shutil.copytree(os.path.dirname(UM.__file__) + "/Qt/qml/UM", "dist/qml/UM")
  58. for site_package in site.getsitepackages():
  59. qt_origin_path = os.path.join(site_package, "PyQt5")
  60. if os.path.isdir(qt_origin_path):
  61. print("Coping PyQt5 plugins from: %s" % qt_origin_path)
  62. shutil.copytree(os.path.join(qt_origin_path, "plugins"), "dist/PyQt5/plugins")
  63. print("Coping PyQt5 QtQuick from: %s" % qt_origin_path)
  64. shutil.copytree(os.path.join(qt_origin_path, "qml/QtQuick"), "dist/qml/QtQuick")
  65. shutil.copytree(os.path.join(qt_origin_path, "qml/QtQuick.2"), "dist/qml/QtQuick.2")
  66. print("Coping PyQt5 svg library from: %s" % qt_origin_path)
  67. shutil.copy(os.path.join(qt_origin_path, "Qt5Svg.dll"), "dist/Qt5Svg.dll")
  68. print("Copying Angle libraries from %s" % qt_origin_path)
  69. shutil.copy(os.path.join(qt_origin_path, "libEGL.dll"), "dist/libEGL.dll")
  70. shutil.copy(os.path.join(qt_origin_path, "libGLESv2.dll"), "dist/libGLESv2.dll")
  71. os.rename("dist/cura_app.exe", "dist/Cura.exe")