[Checkins] SVN: zc.buildout/branches/gary-7-clean-up/ eggs before stdlib in scripts; faux-interpreter should put scripts directory in path; stdlib list of directories should not include the current directory; sitecustomize should not be cleaned from sys.modules.
Gary Poster
gary.poster at canonical.com
Wed Oct 14 20:08:16 EDT 2009
Log message for revision 105072:
eggs before stdlib in scripts; faux-interpreter should put scripts directory in path; stdlib list of directories should not include the current directory; sitecustomize should not be cleaned from sys.modules.
Changed:
U zc.buildout/branches/gary-7-clean-up/src/zc/buildout/easy_install.py
U zc.buildout/branches/gary-7-clean-up/src/zc/buildout/easy_install.txt
U zc.buildout/branches/gary-7-clean-up/src/zc/buildout/update.txt
U zc.buildout/branches/gary-7-clean-up/zc.recipe.egg_/src/zc/recipe/egg/README.txt
-=-
Modified: zc.buildout/branches/gary-7-clean-up/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/gary-7-clean-up/src/zc/buildout/easy_install.py 2009-10-15 00:04:07 UTC (rev 105071)
+++ zc.buildout/branches/gary-7-clean-up/src/zc/buildout/easy_install.py 2009-10-15 00:08:16 UTC (rev 105072)
@@ -84,7 +84,7 @@
def get_sys_path(clean=False):
cmd = [executable, "-c",
"import sys, os;"
- "print repr([os.path.normpath(p) for p in sys.path])"]
+ "print repr([os.path.normpath(p) for p in sys.path if p])"]
if clean:
cmd.insert(1, '-S')
_proc = subprocess.Popen(
@@ -109,7 +109,7 @@
site_packages = [p for p in get_sys_path() if p not in stdlib]
return (stdlib, site_packages)
-def _get_clean_sys_modules(executable):
+def get_clean_sys_modules(executable):
cmd = [executable, '-S', '-c',
'import sys; print repr(sys.modules.keys())']
_proc = subprocess.Popen(
@@ -1116,8 +1116,9 @@
):
stdlib, eggs, site_dirs = get_path(
working_set, executable, extra_paths, include_site_packages)
- clean_modules = set(_get_clean_sys_modules(executable))
+ clean_modules = set(get_clean_sys_modules(executable))
clean_modules.add('site')
+ clean_modules.add('sitecustomize')
clean_modules.add('sys')
generated = []
@@ -1301,10 +1302,10 @@
del sys.modules[k]
sys.path[:] = [
- %(stdlib)s
+ %(eggs)s
]
sys.path.extend([
- %(eggs)s
+ %(stdlib)s
])
site_dirs = [
%(site_dirs)s
@@ -1433,10 +1434,9 @@
%(site_dirs)s
]
-sys.path[:] = stdlib
-
if options.import_site:
- sys.path.extend(egg_paths)
+ sys.path[:] = egg_paths
+ sys.path.extend(stdlib)
# Add the site_dirs before `addsitedir` in case it has setuptools.
sys.path.extend(site_dirs)
# Process all buildout-controlled eggs before site-packages by importing
@@ -1449,24 +1449,30 @@
# Process .pth files.
for p in site_dirs:
site.addsitedir(p)
-sys.path.insert(0, '.')
+else:
+ sys.path[:] = stdlib
pythonpath = os.environ.get('PYTHONPATH', '')
sys.path[0:0] = filter(None, (p.strip() for p in pythonpath.split(':')))
interactive = options.inspect
if getattr(options, 'command', False):
+ sys.path.insert(0, os.getcwd())
sys.argv[:] = options.sys_argv
exec options.runnable in globs
elif getattr(options, 'module', False):
+ sys.path.insert(0, os.getcwd())
# runpy is only available in Python >= 2.5, so only try if we're asked
import runpy
sys.argv[:] = options.sys_argv
runpy.run_module(options.runnable, {}, "__main__", alter_sys=True)
elif args:
+ filename = args[0]
+ sys.path.insert(0, os.path.abspath(os.path.dirname(filename)))
sys.argv[:] = args
- globs['__file__'] = args[0]
- execfile(args[0], globs)
+ globs['__file__'] = filename
+ execfile(filename, globs)
else:
+ sys.path.insert(0, '.')
interactive = True
if interactive:
Modified: zc.buildout/branches/gary-7-clean-up/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/branches/gary-7-clean-up/src/zc/buildout/easy_install.txt 2009-10-15 00:04:07 UTC (rev 105071)
+++ zc.buildout/branches/gary-7-clean-up/src/zc/buildout/easy_install.txt 2009-10-15 00:08:16 UTC (rev 105072)
@@ -656,17 +656,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ '/sample-install/demo-0.3-pyN.N.egg',
+ '/sample-install/demoneeded-1.1-pyN.N.egg'
]
sys.path.extend([
- '/sample-install/demo-0.3-pyN.N.egg',
- '/sample-install/demoneeded-1.1-pyN.N.egg'
+ ...
])
site_dirs = [
...
@@ -725,17 +728,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ '/sample-install/demo-0.3-pyN.N.egg',
+ '/sample-install/demoneeded-1.1-pyN.N.egg'
]
sys.path.extend([
- '/sample-install/demo-0.3-pyN.N.egg',
- '/sample-install/demoneeded-1.1-pyN.N.egg'
+ ...
])
site_dirs = [
...
@@ -804,6 +810,9 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
@@ -861,10 +870,9 @@
...
]
<BLANKLINE>
- sys.path[:] = stdlib
- <BLANKLINE>
if options.import_site:
- sys.path.extend(egg_paths)
+ sys.path[:] = egg_paths
+ sys.path.extend(stdlib)
# Add the site_dirs before `addsitedir` in case it has setuptools.
sys.path.extend(site_dirs)
# Process all buildout-controlled eggs before site-packages by importing
@@ -877,24 +885,30 @@
# Process .pth files.
for p in site_dirs:
site.addsitedir(p)
- sys.path.insert(0, '.')
+ else:
+ sys.path[:] = stdlib
pythonpath = os.environ.get('PYTHONPATH', '')
sys.path[0:0] = filter(None, (p.strip() for p in pythonpath.split(':')))
<BLANKLINE>
interactive = options.inspect
if getattr(options, 'command', False):
+ sys.path.insert(0, os.getcwd())
sys.argv[:] = options.sys_argv
exec options.runnable in globs
elif getattr(options, 'module', False):
+ sys.path.insert(0, os.getcwd())
# runpy is only available in Python >= 2.5, so only try if we're asked
import runpy
sys.argv[:] = options.sys_argv
runpy.run_module(options.runnable, {}, "__main__", alter_sys=True)
elif args:
+ filename = args[0]
+ sys.path.insert(0, os.path.abspath(os.path.dirname(filename)))
sys.argv[:] = args
- globs['__file__'] = args[0]
- execfile(args[0], globs)
+ globs['__file__'] = filename
+ execfile(filename, globs)
else:
+ sys.path.insert(0, '.')
interactive = True
<BLANKLINE>
if interactive:
@@ -962,17 +976,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ '/sample-install/demo-0.3-pyN.N.egg',
+ '/sample-install/demoneeded-1.1-pyN.N.egg'
]
sys.path.extend([
- '/sample-install/demo-0.3-pyN.N.egg',
- '/sample-install/demoneeded-1.1-pyN.N.egg'
+ ...
])
site_dirs = [
'/foo',
@@ -1087,17 +1104,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ '/sample-install/demo-0.3-pyN.N.egg',
+ '/sample-install/demoneeded-1.1-pyN.N.egg'
]
sys.path.extend([
- '/sample-install/demo-0.3-pyN.N.egg',
- '/sample-install/demoneeded-1.1-pyN.N.egg'
+ ...
])
site_dirs = [
...
@@ -1139,17 +1159,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ '/sample-install/demo-0.3-pyN.N.egg',
+ '/sample-install/demoneeded-1.1-pyN.N.egg'
]
sys.path.extend([
- '/sample-install/demo-0.3-pyN.N.egg',
- '/sample-install/demoneeded-1.1-pyN.N.egg'
+ ...
])
site_dirs = [
...
@@ -1214,17 +1237,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ join(base, 'eggs/demo-0.3-pyN.N.egg'),
+ join(base, 'eggs/demoneeded-1.1-pyN.N.egg')
]
sys.path.extend([
- join(base, 'eggs/demo-0.3-pyN.N.egg'),
- join(base, 'eggs/demoneeded-1.1-pyN.N.egg')
+ ...
])
site_dirs = [
'/ba',
@@ -1278,6 +1304,9 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
@@ -1337,10 +1366,9 @@
...
]
<BLANKLINE>
- sys.path[:] = stdlib
- <BLANKLINE>
if options.import_site:
- sys.path.extend(egg_paths)
+ sys.path[:] = egg_paths
+ sys.path.extend(stdlib)
# Add the site_dirs before `addsitedir` in case it has setuptools.
sys.path.extend(site_dirs)
# Process all buildout-controlled eggs before site-packages by importing
@@ -1353,24 +1381,30 @@
# Process .pth files.
for p in site_dirs:
site.addsitedir(p)
- sys.path.insert(0, '.')
+ else:
+ sys.path[:] = stdlib
pythonpath = os.environ.get('PYTHONPATH', '')
sys.path[0:0] = filter(None, (p.strip() for p in pythonpath.split(':')))
<BLANKLINE>
interactive = options.inspect
if getattr(options, 'command', False):
+ sys.path.insert(0, os.getcwd())
sys.argv[:] = options.sys_argv
exec options.runnable in globs
elif getattr(options, 'module', False):
+ sys.path.insert(0, os.getcwd())
# runpy is only available in Python >= 2.5, so only try if we're asked
import runpy
sys.argv[:] = options.sys_argv
runpy.run_module(options.runnable, {}, "__main__", alter_sys=True)
elif args:
+ filename = args[0]
+ sys.path.insert(0, os.path.abspath(os.path.dirname(filename)))
sys.argv[:] = args
- globs['__file__'] = args[0]
- execfile(args[0], globs)
+ globs['__file__'] = filename
+ execfile(filename, globs)
else:
+ sys.path.insert(0, '.')
interactive = True
<BLANKLINE>
if interactive:
Modified: zc.buildout/branches/gary-7-clean-up/src/zc/buildout/update.txt
===================================================================
--- zc.buildout/branches/gary-7-clean-up/src/zc/buildout/update.txt 2009-10-15 00:04:07 UTC (rev 105071)
+++ zc.buildout/branches/gary-7-clean-up/src/zc/buildout/update.txt 2009-10-15 00:08:16 UTC (rev 105072)
@@ -89,17 +89,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ '/sample-buildout/eggs/zc.buildout-NINETYNINE.NINETYNINE-pyN.N.egg',
+ '/sample-buildout/eggs/setuptools-NINETYNINE.NINETYNINE-pyN.N.egg'
]
sys.path.extend([
- '/sample-buildout/eggs/zc.buildout-NINETYNINE.NINETYNINE-pyN.N.egg',
- '/sample-buildout/eggs/setuptools-NINETYNINE.NINETYNINE-pyN.N.egg'
+ ...
])
site_dirs = [
...
Modified: zc.buildout/branches/gary-7-clean-up/zc.recipe.egg_/src/zc/recipe/egg/README.txt
===================================================================
--- zc.buildout/branches/gary-7-clean-up/zc.recipe.egg_/src/zc/recipe/egg/README.txt 2009-10-15 00:04:07 UTC (rev 105071)
+++ zc.buildout/branches/gary-7-clean-up/zc.recipe.egg_/src/zc/recipe/egg/README.txt 2009-10-15 00:08:16 UTC (rev 105072)
@@ -382,17 +382,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ '/sample-buildout/eggs/demo-0.4c1-pyN.N.egg',
+ '/sample-buildout/eggs/demoneeded-1.2c1-pyN.N.egg'
]
sys.path.extend([
- '/sample-buildout/eggs/demo-0.4c1-pyN.N.egg',
- '/sample-buildout/eggs/demoneeded-1.2c1-pyN.N.egg'
+ ...
])
site_dirs = [
'/foo/bar',
@@ -464,17 +467,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ join(base, 'eggs/demo-0.4c1-pyN.N.egg'),
+ join(base, 'eggs/demoneeded-1.2c1-pyN.N.egg')
]
sys.path.extend([
- join(base, 'eggs/demo-0.4c1-pyN.N.egg'),
- join(base, 'eggs/demoneeded-1.2c1-pyN.N.egg')
+ ...
])
site_dirs = [
'/foo/bar',
@@ -499,6 +505,7 @@
if __name__ == '__main__':
eggrecipedemo.main()
+
You can specify relative paths in the buildout section, rather than in
each individual script section:
@@ -539,17 +546,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ join(base, 'eggs/demo-0.4c1-pyN.N.egg'),
+ join(base, 'eggs/demoneeded-1.2c1-pyN.N.egg')
]
sys.path.extend([
- join(base, 'eggs/demo-0.4c1-pyN.N.egg'),
- join(base, 'eggs/demoneeded-1.2c1-pyN.N.egg')
+ ...
])
site_dirs = [
'/foo/bar',
@@ -581,7 +591,6 @@
use the initialialization and arguments options to specify extra code
to be included in generated scripts:
-
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
@@ -615,17 +624,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ '/sample-buildout/eggs/demo-0.4c1-pyN.N.egg',
+ '/sample-buildout/eggs/demoneeded-1.2c1-pyN.N.egg'
]
sys.path.extend([
- '/sample-buildout/eggs/demo-0.4c1-pyN.N.egg',
- '/sample-buildout/eggs/demoneeded-1.2c1-pyN.N.egg'
+ ...
])
site_dirs = [
'/foo/bar',
@@ -702,17 +714,20 @@
# Clean out sys.modules from site's processing of .pth files.
clean_modules = [
...
+ 'site',
+ 'sitecustomize',
+ ...
]
for k in sys.modules.keys():
if k not in clean_modules:
del sys.modules[k]
<BLANKLINE>
sys.path[:] = [
- ...
+ '/sample-buildout/eggs/demo-0.4c1-pyN.N.egg',
+ '/sample-buildout/eggs/demoneeded-1.2c1-pyN.N.egg'
]
sys.path.extend([
- '/sample-buildout/eggs/demo-0.4c1-pyN.N.egg',
- '/sample-buildout/eggs/demoneeded-1.2c1-pyN.N.egg'
+ ...
])
site_dirs = [
'/foo/bar',
More information about the checkins
mailing list