__init__.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import sys,os
  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. 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. 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. if not os.path.exists(os.path.join(overlay_dir,'mmgen','main.py')):
  27. for d in (
  28. 'mmgen',
  29. 'mmgen.data',
  30. 'mmgen.share',
  31. 'mmgen.altcoins',
  32. 'mmgen.altcoins.eth',
  33. 'mmgen.altcoins.eth.pyethereum',
  34. 'mmgen.altcoins.eth.rlp',
  35. 'mmgen.altcoins.eth.rlp.sedes' ):
  36. process_srcdir(d)
  37. return overlay_dir