setup.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from distutils.core import setup
  2. import py2exe
  3. import UM
  4. import UM.Qt
  5. import os
  6. import re
  7. import shutil
  8. import site
  9. includes = ['sip', 'ctypes', 'UM', 'PyQt5.QtNetwork', 'PyQt5._QOpenGLFunctions_2_0', 'serial', 'Arcus', 'google', 'google.protobuf', 'google.protobuf.descriptor', 'xml.etree', 'xml.etree.ElementTree']
  10. # Include all the UM modules in the includes. As py2exe fails to properly find all the dependencies due to the plugin architecture.
  11. for dirpath, dirnames, filenames in os.walk('../UM'):
  12. if '__' in dirpath:
  13. continue
  14. dirpath = dirpath.split(os.path.sep)
  15. dirpath[0] = 'UM'
  16. module_name = '.'.join(dirpath)
  17. if os.path.isfile('../' + os.path.sep.join(dirpath) + '/__init__.py'):
  18. includes += [module_name]
  19. for filename in filenames:
  20. if '__' in filename or not filename.endswith('.py'):
  21. continue
  22. includes += [module_name + '.' + os.path.splitext(filename)[0]]
  23. print('Removing previous distribution package')
  24. shutil.rmtree('dist', True)
  25. setup(name="Cura",
  26. version="2.0",
  27. author="Ultimaker",
  28. author_email="d.braam@ultimaker.com",
  29. url="http://software.ultimaker.com/",
  30. license="GNU AFFERO GENERAL PUBLIC LICENSE (AGPL)",
  31. scripts=["printer.py", "PrinterApplication.py"],
  32. #windows=[{"script": "printer.py", "dest_name": "Cura"}],
  33. console=[{"script": "printer.py"}],
  34. options={"py2exe": {"skip_archive": False, "includes": includes}})
  35. print('Coping Cura plugins.')
  36. shutil.copytree('../plugins', 'dist/plugins')
  37. print('Coping Cura qml.')
  38. shutil.copytree('qml', 'dist/qml')
  39. print('Coping resources.')
  40. shutil.copytree('../resources', 'dist/resources')
  41. print('Coping resources.')
  42. shutil.copytree('../UM/Qt/qml/UM', 'dist/qml/UM')
  43. for site_package in site.getsitepackages():
  44. qt_origin_path = os.path.join(site_package, 'PyQt5')
  45. if os.path.isdir(qt_origin_path):
  46. print('Coping PyQt5 plugins from: %s' % qt_origin_path)
  47. shutil.copytree(os.path.join(qt_origin_path, 'plugins'), 'dist/PyQt5/plugins')
  48. print('Coping PyQt5 QtQuick from: %s' % qt_origin_path)
  49. shutil.copytree(os.path.join(qt_origin_path, 'qml/QtQuick'), 'dist/qml/QtQuick')
  50. shutil.copytree(os.path.join(qt_origin_path, 'qml/QtQuick.2'), 'dist/qml/QtQuick.2')
  51. print('Coping PyQt5 svg library from: %s' % qt_origin_path)
  52. shutil.copy(os.path.join(qt_origin_path, 'Qt5Svg.dll'), 'dist/Qt5Svg.dll')
  53. os.rename('dist/printer.exe', 'dist/Cura.exe')