aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2006-10-26 15:03:22 -0700
committerBrian Harring <ferringb@gmail.com>2006-10-26 15:03:22 -0700
commitaddea316bcd3d515384ff1e90857336c12963c20 (patch)
treed9880366f7d15bea5e442409cb5a8060e1098b85 /bin
parentfix a bug for collision-protect; wasn't handling config_protect filtering pro... (diff)
downloadpkgcore-addea316bcd3d515384ff1e90857336c12963c20.tar.gz
pkgcore-addea316bcd3d515384ff1e90857336c12963c20.tar.bz2
pkgcore-addea316bcd3d515384ff1e90857336c12963c20.zip
merge work from marienz.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/pwrapper31
-rwxr-xr-xbin/pwrapper_installed30
2 files changed, 39 insertions, 22 deletions
diff --git a/bin/pwrapper b/bin/pwrapper
index e38b9da5f..97ea59719 100755
--- a/bin/pwrapper
+++ b/bin/pwrapper
@@ -2,33 +2,20 @@
"""Wrapper script that messes with sys.path and runs scripts.
-If it sees a ../pkgcore/__init__.py relative to its absolute location
-it adds .. to sys.path. It then imports and runs pkgcore.scripts.<sys.argv[0]>.
+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.
"""
import os.path as osp
import sys
-try:
- from pkgcore.util import modules, commandline
-except ImportError:
- print >> sys.stderr, 'Cannot import pkgcore!'
- print >> sys.stderr, 'Verify it is properly installed and/or ' \
- 'PYTHONPATH is set correctly.'
- print >> sys.stderr, 'Add --debug to the commandline for a traceback.'
- if '--debug' in sys.argv:
- raise
- sys.exit(1)
+sys.path.insert(0, osp.dirname(osp.dirname(osp.abspath(__file__))))
+
+from pkgcore.util import modules, commandline
+
if __name__ == '__main__':
name = osp.basename(sys.argv[0])
- try:
- script = modules.load_module('pkgcore.scripts.%s' % (name,))
- except modules.FailedImport:
- print >> sys.stderr, 'Cannot load script %s.' % (name,)
- print >> sys.stderr, 'Add --debug to the commandline for a traceback.'
- if '--debug' in sys.argv:
- raise
- sys.exit(1)
- else:
- commandline.main(script.OptionParser(), script.main)
+ script = modules.load_module('pkgcore.scripts.%s' % (name,))
+ commandline.main(script.OptionParser(), script.main)
diff --git a/bin/pwrapper_installed b/bin/pwrapper_installed
new file mode 100755
index 000000000..d0806818c
--- /dev/null
+++ b/bin/pwrapper_installed
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+"""Wrapper script that runs a pkgcore script from sys.path."""
+
+import os.path as osp
+import sys
+
+if __name__ == '__main__':
+ try:
+ from pkgcore.util import modules, commandline
+ except ImportError:
+ print >> sys.stderr, 'Cannot import pkgcore!'
+ print >> sys.stderr, 'Verify it is properly installed and/or ' \
+ 'PYTHONPATH is set correctly.'
+ print >> sys.stderr, 'Add --debug to the commandline for a traceback.'
+ if '--debug' in sys.argv:
+ raise
+ sys.exit(1)
+
+ name = osp.basename(sys.argv[0])
+ try:
+ script = modules.load_module('pkgcore.scripts.%s' % (name,))
+ except modules.FailedImport:
+ print >> sys.stderr, 'Cannot load script %s.' % (name,)
+ print >> sys.stderr, 'Add --debug to the commandline for a traceback.'
+ if '--debug' in sys.argv:
+ raise
+ sys.exit(1)
+ else:
+ commandline.main(script.OptionParser(), script.main)