Commit 0e2d03c6 authored by Jason R. Coombs's avatar Jason R. Coombs

Extract function for initializing the master working set. Fixes #373.

parent c2cc7435
...@@ -3053,20 +3053,34 @@ def _initialize(g): ...@@ -3053,20 +3053,34 @@ def _initialize(g):
g[name] = getattr(_manager, name) g[name] = getattr(_manager, name)
_initialize(globals()) _initialize(globals())
# Prepare the master working set and make the ``require()`` API available
working_set = WorkingSet._build_master() def _initialize_master_working_set():
_declare_state('object', working_set=working_set) """
Prepare the master working set and make the ``require()``
require = working_set.require API available.
iter_entry_points = working_set.iter_entry_points
add_activation_listener = working_set.subscribe This function has explicit effects on the global state
run_script = working_set.run_script of pkg_resources. It is intended to be invoked once at
# backward compatibility the initialization of this module.
run_main = run_script
# Activate all distributions already on sys.path, and ensure that Invocation by other packages is unsupported and done
# all distributions added to the working set in the future (e.g. by at their own risk.
# calling ``require()``) will get activated as well. """
add_activation_listener(lambda dist: dist.activate()) working_set = WorkingSet._build_master()
working_set.entries=[] _declare_state('object', working_set=working_set)
# match order
list(map(working_set.add_entry, sys.path)) require = working_set.require
iter_entry_points = working_set.iter_entry_points
add_activation_listener = working_set.subscribe
run_script = working_set.run_script
# backward compatibility
run_main = run_script
# Activate all distributions already on sys.path, and ensure that
# all distributions added to the working set in the future (e.g. by
# calling ``require()``) will get activated as well.
add_activation_listener(lambda dist: dist.activate())
working_set.entries=[]
# match order
list(map(working_set.add_entry, sys.path))
globals().update(locals())
_initialize_master_working_set()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment