__init__.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import sys,os
  2. def overlay_setup():
  3. def process_srcdir(d):
  4. srcdir = os.path.join(repo_root,*d.split('.'))
  5. destdir = os.path.join(overlay_dir,*d.split('.'))
  6. os.makedirs(destdir)
  7. for fn in os.listdir(srcdir):
  8. if (
  9. fn.endswith('.py') or
  10. d == 'mmgen.data' or
  11. d == 'mmgen' and fn.startswith('secp256k1')
  12. ):
  13. if fn in fakemods:
  14. os.symlink(
  15. os.path.join(fakemod_dir,fn),
  16. os.path.join(destdir,fn) )
  17. link_fn = fn.removesuffix('.py') + '_orig.py'
  18. else:
  19. link_fn = fn
  20. os.symlink(
  21. os.path.join(srcdir,fn),
  22. os.path.join(destdir,link_fn) )
  23. repo_root = os.path.dirname(os.path.abspath(os.path.dirname(sys.argv[0])))
  24. overlay_dir = os.path.join(repo_root,'test','overlay','tree')
  25. fakemod_dir = os.path.join(repo_root,'test','overlay','fakemods')
  26. fakemods = os.listdir(fakemod_dir)
  27. if not os.path.exists(os.path.join(overlay_dir,'mmgen','main.py')):
  28. for d in (
  29. 'mmgen',
  30. 'mmgen.data',
  31. 'mmgen.share',
  32. 'mmgen.altcoins',
  33. 'mmgen.altcoins.eth',
  34. 'mmgen.altcoins.eth.pyethereum',
  35. 'mmgen.altcoins.eth.rlp',
  36. 'mmgen.altcoins.eth.rlp.sedes' ):
  37. process_srcdir(d)
  38. return overlay_dir