__init__.py 759 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import subprocess
  2. from collections import defaultdict
  3. from .syms import syms
  4. def gen_builtin():
  5. res = defaultdict(dict)
  6. for k, v in syms.items():
  7. mod, sym = k.split('|')
  8. res[mod][sym] = v
  9. return res
  10. builtin_symbols = gen_builtin()
  11. caps = builtin_symbols['_capability']
  12. def find_library(name, find_next):
  13. subst = {
  14. 'rt': 'c',
  15. 'pthread': 'c',
  16. 'm': 'c',
  17. }
  18. builtin = builtin_symbols.get(subst.get(name, name))
  19. if builtin:
  20. return {
  21. 'name': name,
  22. 'symbols': builtin,
  23. }
  24. if 'musl' in caps:
  25. return None
  26. try:
  27. subprocess.Popen.__patched__
  28. return None
  29. except Exception:
  30. pass
  31. return find_next(name)