1
0

blogit.spec 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. datas=[('blogit/blogit-mir/*', 'blogit-mir')])
  35. pyz = PYZ(a.pure, a.zipped_data,
  36. cipher=block_cipher)
  37. exe = EXE(pyz,
  38. a.scripts,
  39. a.binaries,
  40. a.zipfiles,
  41. a.datas,
  42. [],
  43. name='blogit',
  44. debug=False,
  45. bootloader_ignore_signals=False,
  46. strip=False,
  47. upx=True,
  48. runtime_tmpdir=None,
  49. console=True )
  50. coll = COLLECT(
  51. exe,
  52. a.binaries,
  53. a.zipfiles,
  54. a.datas,
  55. name='blogit-dir',
  56. strip=False,
  57. upx=True
  58. )