g-ir-scanner 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env python3
  2. # -*- Mode: Python -*-
  3. # GObject-Introspection - a framework for introspecting GObject libraries
  4. # Copyright (C) 2008 Johan Dahlin
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # as published by the Free Software Foundation; either version 2
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. # 02110-1301, USA.
  20. #
  21. from __future__ import absolute_import
  22. from __future__ import division
  23. from __future__ import print_function
  24. from __future__ import unicode_literals
  25. import os
  26. import sys
  27. if sys.version_info.major < 3:
  28. import __builtin__ as builtins
  29. else:
  30. import builtins
  31. debug = os.getenv('GI_SCANNER_DEBUG')
  32. if debug:
  33. if 'pydevd' in debug.split(','):
  34. # http://pydev.org/manual_adv_remote_debugger.html
  35. pydevdpath = os.getenv('PYDEVDPATH', None)
  36. if pydevdpath is not None and os.path.isdir(pydevdpath):
  37. sys.path.insert(0, pydevdpath)
  38. import pydevd
  39. pydevd.settrace()
  40. else:
  41. def on_exception(exctype, value, tb):
  42. print("Caught exception: %r %r" % (exctype, value))
  43. import pdb
  44. pdb.pm()
  45. sys.excepthook = on_exception
  46. if os.name == 'nt':
  47. datadir = os.path.join(os.path.dirname(__file__), '..', 'share')
  48. pylibdir = os.path.join(os.path.dirname(__file__), '..', 'lib', 'gobject-introspection')
  49. else:
  50. datadir = "/usr/share"
  51. pylibdir = os.path.join('/usr/lib', 'gobject-introspection')
  52. builtins.__dict__['DATADIR'] = datadir
  53. srcdir = os.getenv('UNINSTALLED_INTROSPECTION_SRCDIR', None)
  54. if srcdir is not None:
  55. pylibdir = srcdir
  56. sys.path.insert(0, pylibdir)
  57. from giscanner.scannermain import scanner_main
  58. sys.exit(scanner_main(sys.argv))