1
0

prep_files.py 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. import os
  2. from subprocess import run
  3. pjoin = os.path.join
  4. # Run pynsist to gather the necessary files
  5. #run([sys.executable, '-m', 'nsist', 'installer.cfg', '--no-makensis'], check=True)
  6. # Remove NSIS script - we're not using it today
  7. try:
  8. os.unlink(pjoin('build', 'nsis', 'installer.nsi'))
  9. except FileNotFoundError:
  10. pass
  11. # Move msvcrt files into Python directory, where they need to be installed
  12. msvcrt_dir = pjoin('build', 'nsis', 'msvcrt')
  13. python_dir = pjoin('build', 'nsis', 'Python')
  14. if os.path.isdir(msvcrt_dir):
  15. for file in os.listdir(msvcrt_dir):
  16. os.rename(pjoin(msvcrt_dir, file), pjoin(python_dir, file))
  17. os.rmdir(msvcrt_dir)
  18. # Run 'heat' (part of Wix) to create a list of the files to install
  19. HEAT = os.path.join(os.environ['WIX'], 'bin', 'heat')
  20. run([HEAT, 'dir', pjoin('build', 'nsis'),
  21. '-out', 'files.wxs', # Target file (wix xml format)
  22. '-ag', # Autogenerated GUIDs for files ('*' - generated at compile time)
  23. '-sfrag', # Single fragment. Not sure if it matters, but it looks neater.
  24. '-cg', 'ApplicationFiles', # Component group. Referenced from wrapper.wxs
  25. '-dr', 'INSTALLDIR', # Directory to install files into
  26. '-srd', # Suppress Root Directory (don't make 'nsis' folder in install dir)
  27. ], check=True)