make_freezed.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # ##########################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # http://flatcam.org #
  4. # Author: Juan Pablo Caram (c) #
  5. # Date: 12/20/2018 #
  6. # MIT Licence #
  7. # #
  8. # Creates a portable copy of FlatCAM, including Python #
  9. # itself and all dependencies. #
  10. # #
  11. # This is not an aid to install FlatCAM from source on #
  12. # Windows platforms. It is only useful when FlatCAM is up #
  13. # and running and ready to be packaged. #
  14. # ##########################################################
  15. # ##########################################################
  16. # File Modified: Marius Adrian Stanciu #
  17. # Date: 3/10/2019 #
  18. # ##########################################################
  19. # Files not needed: Qt, tk.dll, tcl.dll, tk/, tcl/, vtk/,
  20. # scipy.lib.lapack.flapack.pyd, scipy.lib.blas.fblas.pyd,
  21. # numpy.core._dotblas.pyd, scipy.sparse.sparsetools._bsr.pyd,
  22. # scipy.sparse.sparsetools._csr.pyd, scipy.sparse.sparsetools._csc.pyd,
  23. # scipy.sparse.sparsetools._coo.pyd
  24. import os
  25. import site
  26. import sys
  27. import platform
  28. from cx_Freeze import setup, Executable
  29. # this is done to solve the tkinter not being found
  30. PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
  31. os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
  32. os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')
  33. # Get the site-package folder, not everybody will install
  34. # Python into C:\PythonXX
  35. site_dir = site.getsitepackages()[1]
  36. include_files = []
  37. include_files.append((os.path.join(site_dir, "shapely"), "shapely"))
  38. include_files.append((os.path.join(site_dir, "svg"), "svg"))
  39. include_files.append((os.path.join(site_dir, "svg/path"), "svg"))
  40. include_files.append((os.path.join(site_dir, "vispy"), "vispy"))
  41. include_files.append((os.path.join(site_dir, "vispy/app"), "vispy/app"))
  42. include_files.append((os.path.join(site_dir, "vispy/app/backends"), "vispy/app/backends"))
  43. # include_files.append((os.path.join(site_dir, "matplotlib"), "matplotlib"))
  44. include_files.append((os.path.join(site_dir, "rtree"), "rtree"))
  45. if platform.architecture()[0] == '64bit':
  46. include_files.append((os.path.join(site_dir, "google"), "google"))
  47. include_files.append((os.path.join(site_dir, "google/protobuf"), "google/protobuf"))
  48. include_files.append((os.path.join(site_dir, "ortools"), "ortools"))
  49. include_files.append(("locale", "lib/locale"))
  50. include_files.append(("preprocessors", "lib/preprocessors"))
  51. # include_files.append(("assets", "lib/assets"))
  52. include_files.append(("assets/examples", "lib/assets/examples"))
  53. include_files.append(("assets/linux", "lib/assets/linux"))
  54. include_files.append(("assets/resources", "lib/assets/resources"))
  55. # include_files.append(("share", "lib/share"))
  56. include_files.append(("appGUI/VisPyData", "lib/vispy"))
  57. include_files.append(("config", "lib/config"))
  58. include_files.append(("README.md", "README.md"))
  59. include_files.append(("LICENSE", "LICENSE"))
  60. include_files.append(("CHANGELOG.md", "CHANGELOG.md"))
  61. base = None
  62. # Lets not open the console while running the app
  63. if sys.platform == "win32":
  64. base = "Win32GUI"
  65. if platform.architecture()[0] == '64bit':
  66. buildOptions = dict(
  67. include_files=include_files,
  68. excludes=['scipy', 'pytz', "matplotlib.tests", "numpy.random._examples"],
  69. # packages=['OpenGL','numpy','vispy','ortools','google']
  70. # packages=['numpy','google', 'rasterio'] # works for Python 3.7
  71. packages=['opengl', 'numpy', 'google', 'rasterio'], # works for Python 3.6.5 and Python 3.7.1
  72. )
  73. else:
  74. buildOptions = dict(
  75. include_files=include_files,
  76. excludes=['scipy', 'pytz'],
  77. # packages=['OpenGL','numpy','vispy','ortools','google']
  78. # packages=['numpy', 'rasterio'] # works for Python 3.7
  79. packages=['opengl', 'numpy', 'rasterio'], # works for Python 3.6.5 and Python 3.7.1
  80. )
  81. if sys.platform == "win32":
  82. buildOptions["include_msvcr"] = True
  83. print("INCLUDE_FILES", include_files)
  84. def getTargetName():
  85. my_OS = platform.system()
  86. if my_OS == 'Linux':
  87. return "FlatCAM"
  88. elif my_OS == 'Windows':
  89. return "FlatCAM.exe"
  90. else:
  91. return "FlatCAM.dmg"
  92. exe = Executable("FlatCAM.py", icon='assets/resources/flatcam_icon48.ico', base=base, targetName=getTargetName())
  93. setup(
  94. name="FlatCAM",
  95. author="Community effort",
  96. version="8.9",
  97. description="FlatCAM Evo: 2D Computer Aided PCB Manufacturing",
  98. options=dict(build_exe=buildOptions),
  99. executables=[exe]
  100. )