summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-08-14 06:03:20 +0000
committerPJ Eby <distutils-sig@python.org>2005-08-14 06:03:20 +0000
commit6ad319bf58bc8f28a81f8adb11add572998e8c37 (patch)
tree2ff8ec7baa13825bd81a1cdec73ff8ed41ae1bad
parent15233b3d39a81fb7164465f65b182eee65983b56 (diff)
downloadpython-setuptools-git-6ad319bf58bc8f28a81f8adb11add572998e8c37.tar.gz
Make "run_script" a method of WorkingSet objects, thereby removing a global
coupling. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041195
-rw-r--r--pkg_resources.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index f619e183..e0590eba 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -398,13 +398,13 @@ class WorkingSet(object):
elif name in entries:
yield entries[name]
-
-
-
-
-
-
-
+ def run_script(self, requires, script_name):
+ """Locate distribution for `requires` and run `script_name` script"""
+ ns = sys._getframe(1).f_globals
+ name = ns['__name__']
+ ns.clear()
+ ns['__name__'] = name
+ self.require(requires)[0].run_script(script_name, ns)
@@ -2147,6 +2147,8 @@ working_set = WorkingSet()
require = working_set.require
iter_entry_points = working_set.iter_entry_points
add_activation_listener = working_set.subscribe
+run_script = working_set.run_script
+run_main = run_script # backward compatibility
# Activate all distributions already on sys.path, and ensure that
# all distributions added to the working set in the future (e.g. by
@@ -2169,5 +2171,3 @@ add_activation_listener(lambda dist: dist.activate())
-
-