1
0

blogit.spec 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # -*- mode: python -*-
  2. block_cipher = None
  3. def Entrypoint(dist, group, name, **kwargs):
  4. import pkg_resources
  5. # get toplevel packages of distribution from metadata
  6. def get_toplevel(dist):
  7. distribution = pkg_resources.get_distribution(dist)
  8. if distribution.has_metadata('top_level.txt'):
  9. return list(distribution.get_metadata('top_level.txt').split())
  10. else:
  11. return []
  12. kwargs.setdefault('hiddenimports', [])
  13. packages = []
  14. for distribution in kwargs['hiddenimports']:
  15. packages += get_toplevel(distribution)
  16. kwargs.setdefault('pathex', [])
  17. # get the entry point
  18. ep = pkg_resources.get_entry_info(dist, group, name)
  19. # insert path of the egg at the verify front of the search path
  20. kwargs['pathex'] = [ep.dist.location] + kwargs['pathex']
  21. # script name must not be a valid module name to avoid name clashes on import
  22. script_path = os.path.join(workpath, name + 'launcher')
  23. print("creating script for entry point", dist, group, name)
  24. with open(script_path, 'w') as fh:
  25. print("import", ep.module_name, file=fh)
  26. print("%s.%s()" % (ep.module_name, '.'.join(ep.attrs)), file=fh)
  27. for package in packages:
  28. print("import", package, file=fh)
  29. return Analysis(
  30. [script_path] + kwargs.get('scripts', []),
  31. **kwargs
  32. )
  33. a = Entrypoint('blogit', 'console_scripts', 'blogit')
  34. pyz = PYZ(a.pure, a.zipped_data,
  35. cipher=block_cipher)
  36. exe = EXE(pyz,
  37. a.scripts,
  38. a.binaries,
  39. a.zipfiles,
  40. a.datas,
  41. [],
  42. name='blogit',
  43. debug=False,
  44. bootloader_ignore_signals=False,
  45. strip=False,
  46. upx=True,
  47. runtime_tmpdir=None,
  48. console=True )