__init__.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import sys,os,shutil
  2. def overlay_setup(repo_root):
  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. make_link(
  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. make_link(
  21. os.path.join(srcdir,fn),
  22. os.path.join(destdir,link_fn) )
  23. overlay_dir = os.path.join(repo_root,'test','overlay','tree')
  24. fakemod_dir = os.path.join(repo_root,'test','overlay','fakemods')
  25. fakemods = os.listdir(fakemod_dir)
  26. make_link = os.symlink if sys.platform == 'linux' else shutil.copy2
  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