blob: faffac9fece772dfc4f40eafb9c4a183195f14fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/usr/bin/env python
"""Wrapper script that messes with sys.path and runs scripts.
This should only be run from inside the "bin" subdir of a pkgcore
checkout or unpacked tarball. It adds the parent of that "bin" dir to
sys.path unconditionally.
"""
from importlib import import_module
import os
import sys
sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
if __name__ == '__main__':
os.environ['PKGCORE_REPO_PATH'] = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
try:
from pkgcore.util import commandline
name = os.path.basename(sys.argv[0]).replace("-", "_")
script = import_module('pkgcore.scripts.%s' % (name,))
except ImportError as e:
sys.stderr.write(str(e) + '!\n')
sys.stderr.write(
'Verify that snakeoil and pkgcore are properly installed '
'and/or PYTHONPATH is set correctly for python %s.\n' %
(".".join(map(str, sys.version_info[:3])),))
if '--debug' in sys.argv:
raise
sys.stderr.write('Add --debug to the commandline for a traceback.\n')
sys.exit(1)
subcommands = getattr(script, 'argparser', None)
commandline.main(subcommands)
|