Commit 0c9d8a57 authored by Tarek Ziade's avatar Tarek Ziade

merged sandbox branch

--HG--
branch : distribute
extra : rebase_source : 71b565341f7dab05898e7f8ea246238fa5258f93
parents d715e5ae 6ad276bf
......@@ -52,9 +52,41 @@ def _bypass_ensure_directory(name, mode=0777):
mkdir(dirname, mode)
_state_vars = {}
def _declare_state(vartype, **kw):
g = globals()
for name, val in kw.iteritems():
g[name] = val
_state_vars[name] = vartype
def __getstate__():
state = {}
g = globals()
for k, v in _state_vars.iteritems():
state[k] = g['_sget_'+v](g[k])
return state
def __setstate__(state):
g = globals()
for k, v in state.iteritems():
g['_sset_'+_state_vars[k]](k, g[k], v)
return state
def _sget_dict(val):
return val.copy()
def _sset_dict(key, ob, state):
ob.clear()
ob.update(state)
def _sget_object(val):
return val.__getstate__()
def _sset_object(key, ob, state):
ob.__setstate__(state)
_sget_none = _sset_none = lambda *args: None
......@@ -672,12 +704,15 @@ class WorkingSet(object):
for callback in self.callbacks:
callback(dist)
def __getstate__(self):
return (self.entries[:], self.entry_keys.copy(), self.by_key.copy(),
self.callbacks[:])
def __setstate__(self, (entries, keys, by_key, callbacks)):
self.entries = entries[:]
self.entry_keys = keys.copy()
self.by_key = by_key.copy()
self.callbacks = callbacks[:]
......@@ -1638,7 +1673,7 @@ else:
_distribution_finders = {}
_declare_state('dict', _distribution_finders = {})
def register_finder(importer_type, distribution_finder):
"""Register `distribution_finder` to find distributions in sys.path items
......@@ -1720,8 +1755,9 @@ def find_on_path(importer, path_item, only=False):
break
register_finder(ImpWrapper,find_on_path)
_namespace_handlers = {}
_namespace_packages = {}
_declare_state('dict', _namespace_handlers={})
_declare_state('dict', _namespace_packages={})
def register_namespace_handler(importer_type, namespace_handler):
"""Register `namespace_handler` to declare namespace packages
......@@ -2651,7 +2687,7 @@ def _mkstemp(*args,**kw):
os.open = old_open # and then put it back
# Set up global resource manager
# Set up global resource manager (deliberately not state-saved)
_manager = ResourceManager()
def _initialize(g):
for name in dir(_manager):
......@@ -2660,7 +2696,8 @@ def _initialize(g):
_initialize(globals())
# Prepare the master working set and make the ``require()`` API available
working_set = WorkingSet()
_declare_state('object', working_set = WorkingSet())
try:
# Does the main program list any requirements?
from __main__ import __requires__
......
......@@ -266,6 +266,7 @@ class Distribution(_Distribution):
"""Fetch an egg needed for building"""
try:
cmd = self._egg_fetcher
cmd.package_index.to_scan = []
except AttributeError:
from setuptools.command.easy_install import easy_install
dist = self.__class__({'script_args':['easy_install']})
......
import os, sys, __builtin__, tempfile, operator
import os, sys, __builtin__, tempfile, operator, pkg_resources
_os = sys.modules[os.name]
try:
_file = file
......@@ -19,6 +19,7 @@ def run_setup(setup_script, args):
if not os.path.isdir(temp_dir): os.makedirs(temp_dir)
save_tmp = tempfile.tempdir
save_modules = sys.modules.copy()
pr_state = pkg_resources.__getstate__()
try:
tempfile.tempdir = temp_dir
os.chdir(setup_dir)
......@@ -36,6 +37,7 @@ def run_setup(setup_script, args):
raise
# Normal exit, just return
finally:
pkg_resources.__setstate__(pr_state)
sys.modules.update(save_modules)
for key in list(sys.modules):
if key not in save_modules: del sys.modules[key]
......
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