You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.4 KiB

14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
  1. #!/usr/bin/env python
  2. # the purpose of this script is rewriting the swig_import_helper
  3. # call so it will not load _xxxxx.so/dso from inside a kicad executable
  4. # because the kicad executable itself sill provide an _xxxxx module
  5. # that's linked inside itself.
  6. #
  7. # for the normal module import it should work the same way with this
  8. # fix in the swig_import_helper
  9. #
  10. from sys import argv,exit
  11. if len(argv)<2:
  12. print "usage:"
  13. print " fixswigimports.py file.py"
  14. print ""
  15. print " will fix the swig import code for working inside KiCad"
  16. print " where it happended that the external _pcbnew.so/dll was"
  17. print " loaded too -and the internal _pcbnew module was to be used"
  18. exit(1)
  19. filename = argv[1]
  20. f = open(filename,"rb")
  21. lines = f.readlines()
  22. f.close()
  23. doneOk = False
  24. if (len(lines)<4000):
  25. print "still building"
  26. exit(0)
  27. txt = ""
  28. for l in lines:
  29. if l.startswith("if version_info >= (2,6,0):"):
  30. l = l.replace("version_info >= (2,6,0)","False")
  31. doneOk = True
  32. elif l.startswith("if False:"): # it was already patched?
  33. doneOk = True
  34. txt = txt + l
  35. f = open(filename,"wb")
  36. f.write(txt)
  37. f.close()
  38. if doneOk:
  39. print "swig_import_helper fixed for",filename
  40. else:
  41. print "Error: the swig import helper was not fixed, check",filename
  42. print " and fix this script: fixswigimports.py"
  43. exit(2)
  44. exit(0)