setup.py 3.6 KB

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