[Checkins] SVN: zc.buildout/branches/gary-support-system-python-4/ added two tests, with associated fixes, with associated changes in other tests (maybe we could not copy the entirety of the various scripts every time it is shown in the tests).

Gary Poster gary.poster at canonical.com
Wed Sep 23 17:36:09 EDT 2009


Log message for revision 104465:
  added two tests, with associated fixes, with associated changes in other tests (maybe we could not copy the entirety of the various scripts every time it is shown in the tests).

Changed:
  U   zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/easy_install.py
  U   zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/easy_install.txt
  U   zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/tests.py
  U   zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/update.txt
  U   zc.buildout/branches/gary-support-system-python-4/zc.recipe.egg_/src/zc/recipe/egg/README.txt
  U   zc.buildout/branches/gary-support-system-python-4/zc.recipe.egg_/src/zc/recipe/egg/egg.py

-=-
Modified: zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/easy_install.py	2009-09-23 21:12:58 UTC (rev 104464)
+++ zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/easy_install.py	2009-09-23 21:36:09 UTC (rev 104465)
@@ -109,7 +109,18 @@
     site_packages = [p for p in get_sys_path() if p not in stdlib]
     return (stdlib, site_packages)
 
+def _get_clean_sys_modules(executable):
+    cmd = [executable, '-S', '-c',
+           'import sys; print repr(sys.modules.keys())']
+    _proc = subprocess.Popen(
+        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    stdout, stderr = _proc.communicate();
+    if _proc.returncode:
+        raise RuntimeError(
+            'error trying to get system packages:\n%s' % (stderr,))
+    return eval(stdout)
 
+
 class IncompatibleVersionError(zc.buildout.UserError):
     """A specified version is incompatible with a given requirement.
     """
@@ -1109,6 +1120,10 @@
             ):
     stdlib, eggs, site_dirs = get_path(
         working_set, executable, extra_paths, include_site_packages)
+    clean_modules = set(_get_clean_sys_modules(executable))
+    clean_modules.add('site')
+    clean_modules.add('sys')
+
     generated = []
 
     if isinstance(reqs, str):
@@ -1133,6 +1148,7 @@
             entry_points.append(req)
 
     stdlib = repr(stdlib)[1:-1].replace(', ', ',\n    ')
+    clean_modules = repr(sorted(clean_modules))[1:-1].replace(', ', ',\n    ')
 
     for name, module_name, attrs in entry_points:
         if scripts is not None:
@@ -1147,9 +1163,9 @@
             script_name, eggs, site_dirs, relative_paths)
 
         generated.extend(
-            _script(module_name, attrs, stdlib, script_eggs, script_site_dirs,
-                    script_name, executable, arguments, initialization,
-                    rpsetup)
+            _script(module_name, attrs, clean_modules, stdlib, script_eggs,
+                    script_site_dirs, script_name, executable,
+                    arguments, initialization, rpsetup)
             )
 
     if interpreter:
@@ -1157,8 +1173,8 @@
         script_eggs, script_site_dirs, rpsetup = _relative_path_and_setup(
             script_name, eggs, site_dirs, relative_paths)
         generated.extend(
-            _pyscript(stdlib, script_eggs, script_site_dirs, script_name,
-                      executable, rpsetup))
+            _pyscript(clean_modules, stdlib, script_eggs, script_site_dirs,
+                      script_name, executable, rpsetup))
 
     return generated
 
@@ -1228,8 +1244,8 @@
 base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
 """
 
-def _script(module_name, attrs, stdlib, eggs, site_dirs, dest, executable,
-            arguments, initialization, rsetup):
+def _script(module_name, attrs, clean_modules, stdlib, eggs, site_dirs, dest,
+            executable, arguments, initialization, rsetup):
     generated = []
     script = dest
     if is_win32:
@@ -1237,6 +1253,7 @@
 
     contents = script_template % dict(
         python = _safe_arg(executable),
+        clean_modules = clean_modules,
         stdlib = stdlib,
         eggs = eggs,
         site_dirs = site_dirs,
@@ -1280,6 +1297,15 @@
 %(relative_paths_setup)s
 import site
 import sys
+
+# Clean out sys.modules from site's processing of .pth files.
+clean_modules = [
+    %(clean_modules)s
+    ]
+for k in sys.modules.keys():
+    if k not in clean_modules:
+        del sys.modules[k]
+
 sys.path[:] = [
     %(stdlib)s
     ]
@@ -1291,6 +1317,13 @@
     ]
 # 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
+# pkg_resources.  This is only important for namespace packages, so it may
+# not have been added, so ignore import errors.
+try:
+    import pkg_resources
+except ImportError:
+    pass
 # Process .pth files.
 for p in site_dirs:
     site.addsitedir(p)
@@ -1302,7 +1335,8 @@
 '''
 
 
-def _pyscript(stdlib, eggs, site_dirs, dest, executable, rsetup):
+def _pyscript(clean_modules, stdlib, eggs, site_dirs, dest, executable,
+              rsetup):
     generated = []
     script = dest
     if is_win32:
@@ -1310,6 +1344,7 @@
 
     contents = py_script_template % dict(
         python = _safe_arg(executable),
+        clean_modules = clean_modules,
         stdlib = stdlib,
         eggs = eggs,
         site_dirs = site_dirs,
@@ -1343,12 +1378,22 @@
 
 %(relative_paths_setup)s
 
+import site
+import sys
+
+# Clean out sys.modules from site's processing of .pth files.
+clean_modules = [
+    %(clean_modules)s
+    ]
+for k in sys.modules.keys():
+    if k not in clean_modules:
+        del sys.modules[k]
+
 import code
 import optparse
 import os
-import site
-import sys
 
+
 def _version_callback(*args, **kwargs):
     print 'Python ' + sys.version.split()[0]
     sys.exit(0)
@@ -1401,6 +1446,13 @@
     sys.path.extend(egg_paths)
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)

Modified: zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/easy_install.txt	2009-09-23 21:12:58 UTC (rev 104464)
+++ zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/easy_install.txt	2009-09-23 21:36:09 UTC (rev 104465)
@@ -652,6 +652,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -664,6 +673,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)
@@ -706,6 +722,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -718,6 +743,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)
@@ -765,12 +797,22 @@
     <BLANKLINE>
     <BLANKLINE>
     <BLANKLINE>
+    import site
+    import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     import code
     import optparse
     import os
-    import site
-    import sys
     <BLANKLINE>
+    <BLANKLINE>
     def _version_callback(*args, **kwargs):
         print 'Python ' + sys.version.split()[0]
         sys.exit(0)
@@ -824,6 +866,13 @@
         sys.path.extend(egg_paths)
         # 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
+        # pkg_resources.  This is only important for namespace packages, so it may
+        # not have been added, so ignore import errors.
+        try:
+            import pkg_resources
+        except ImportError:
+            pass
         # Process .pth files.
         for p in site_dirs:
             site.addsitedir(p)
@@ -908,6 +957,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -921,6 +979,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)
@@ -938,7 +1003,7 @@
 precisely, those that are not included when Python is started with the -S
 argument--are loosely referred to as "site-packages" here.
 
-When generating scripts, paths that come from the site-packages are ordered 
+When generating scripts, paths that come from the site-packages are ordered
 after the other specific dependencies generated from the working set.  This
 is so that directories such as "site-packages" that can contain multiple
 dependencies come after the more specific distributions found by setuptools,
@@ -1017,6 +1082,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -1029,6 +1103,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)
@@ -1053,6 +1134,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -1065,6 +1155,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)
@@ -1113,6 +1210,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -1127,6 +1233,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)
@@ -1159,12 +1272,22 @@
     base = os.path.dirname(base)
     <BLANKLINE>
     <BLANKLINE>
+    import site
+    import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     import code
     import optparse
     import os
-    import site
-    import sys
     <BLANKLINE>
+    <BLANKLINE>
     def _version_callback(*args, **kwargs):
         print 'Python ' + sys.version.split()[0]
         sys.exit(0)
@@ -1220,6 +1343,13 @@
         sys.path.extend(egg_paths)
         # 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
+        # pkg_resources.  This is only important for namespace packages, so it may
+        # not have been added, so ignore import errors.
+        try:
+            import pkg_resources
+        except ImportError:
+            pass
         # Process .pth files.
         for p in site_dirs:
             site.addsitedir(p)

Modified: zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/tests.py	2009-09-23 21:12:58 UTC (rev 104464)
+++ zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/tests.py	2009-09-23 21:36:09 UTC (rev 104465)
@@ -2548,6 +2548,124 @@
 
     """
 
+def handle_namespace_package_in_both_site_packages_and_buildout_eggs():
+    r"""
+If you have the same namespace package in both site-packages and in
+buildout, we need to be very careful that faux-Python-executables and
+scripts correctly combine the two.
+
+To demonstrate this, we will create three packages: tellmy.version 1.0,
+tellmy.version 1.1, and tellmy.fortune 1.0.
+
+    >>> for pkg, version in (('version', '1.0'), ('version', '1.1'),
+    ...                      ('fortune', '1.0')):
+    ...     tmp = tempfile.mkdtemp()
+    ...     try:
+    ...         write(tmp, 'README.txt', '')
+    ...         mkdir(tmp, 'src')
+    ...         mkdir(tmp, 'src', 'tellmy')
+    ...         write(tmp, 'src', 'tellmy', '__init__.py',
+    ...             "__import__("
+    ...             "'pkg_resources').declare_namespace(__name__)\n")
+    ...         mkdir(tmp, 'src', 'tellmy', pkg)
+    ...         write(tmp, 'src', 'tellmy', pkg,
+    ...               '__init__.py', '__version__=%r\n' % version)
+    ...         write(
+    ...             tmp, 'setup.py',
+    ...             "from setuptools import setup\n"
+    ...             "setup(\n"
+    ...             " name='tellmy.%(pkg)s',\n"
+    ...             " package_dir = {'': 'src'},\n"
+    ...             " packages = ['tellmy', 'tellmy.%(pkg)s'],\n"
+    ...             " install_requires = ['setuptools'],\n"
+    ...             " namespace_packages=['tellmy'],\n"
+    ...             " zip_safe=True, version=%(version)r,\n"
+    ...             " author='bob', url='bob', author_email='bob')\n"
+    ...             % globals()
+    ...             )
+    ...         zc.buildout.testing.sdist(tmp, sample_eggs)
+    ...         if pkg == 'version' and version == '1.1':
+    ...             # We install the 1.1 version in site packages the way a
+    ...             # system packaging system (debs, rpms) would do it.
+    ...             zc.buildout.testing.sys_install(tmp, site_packages)
+    ...     finally:
+    ...         shutil.rmtree(tmp)
+    >>> primed_python = get_executable_with_system_installed_packages()
+    >>> print system(
+    ...     primed_python + " -c '" +
+    ...     "import tellmy.version\n" +
+    ...     "print tellmy.version.__version__\n" +
+    ...     "'")
+    1.1
+    <BLANKLINE>
+
+Now we will create a buildout that creates a script and a faux-Python script.
+We want to see that both can successfully import the specified versions of
+tellmy.version and tellmy.fortune.
+
+    >>> write('buildout.cfg',
+    ... '''
+    ... [buildout]
+    ... parts = eggs
+    ... find-links = %(link_server)s
+    ...
+    ... [primed_python]
+    ... executable = %(primed_python)s
+    ...
+    ... [eggs]
+    ... recipe = zc.recipe.egg
+    ... python = primed_python
+    ... interpreter = py
+    ... eggs = tellmy.version == 1.0
+    ...        tellmy.fortune == 1.0
+    ...        demo
+    ... initialization =
+    ...     import tellmy.version
+    ...     print tellmy.version.__version__
+    ...     import tellmy.fortune
+    ...     print tellmy.fortune.__version__
+    ... ''' % globals())
+
+    >>> print system(primed_python+" "+buildout)
+    Installing eggs.
+    Getting distribution for 'tellmy.version==1.0'.
+    Got tellmy.version 1.0.
+    Getting distribution for 'tellmy.fortune==1.0'.
+    Got tellmy.fortune 1.0.
+    Generated script '/sample-buildout/bin/demo'.
+    Generated interpreter '/sample-buildout/bin/py'.
+    <BLANKLINE>
+
+Finally, we are ready for the actual test.  Prior to the bug fix that
+this tests, the results of both calls below was the following::
+
+    1.1
+    Traceback (most recent call last):
+      ...
+    ImportError: No module named fortune
+    <BLANKLINE>
+
+In other words, we got the site-packages version of tellmy.version, and
+we could not import tellmy.fortune at all.  The following are the correct
+results.
+
+    >>> print system(
+    ...     join('bin', 'py') + " -c '" +
+    ...     "import tellmy.version\n" +
+    ...     "print tellmy.version.__version__\n" +
+    ...     "import tellmy.fortune\n" +
+    ...     "print tellmy.fortune.__version__\n" +
+    ...     "'")
+    1.0
+    1.0
+    <BLANKLINE>
+    >>> print system(join('bin', 'demo'))
+    1.0
+    1.0
+    3 1
+    <BLANKLINE>
+    """
+
 def isolated_include_site_packages():
     """
 
@@ -2719,6 +2837,109 @@
 
     """
 
+def scripts_clean_sys_modules_when_site_packages_excluded():
+    r"""
+If you are using a Python with site-packages, the faux-Python-executables
+and scripts must be sure to not let any .pth files in site-packages affect
+sys.modules, which they can do normally because of importing site.py.
+
+Of course, .pth files that only contain paths simply affect sys.path, not
+sys.modules.  They can also contain arbitrary Python, however: if a line
+begins with "import" (followed by a space or a tab) then the line will be
+interpreted as Python (see http://docs.python.org/library/site.html ).
+
+The setuptools package uses this mechanism to create namespace packages, for
+instance.  The line ends up modifying sys.modules.
+
+This test verifies that, if ``include-site-packages = false``, sys.modules is
+not affected by the namespace package .pth files in the Python's
+site-packages.
+
+We begin by creating a namespace package installed as a distribution might
+install it.
+
+    >>> tmp = tempfile.mkdtemp()
+    >>> try:
+    ...     write(tmp, 'README.txt', '')
+    ...     mkdir(tmp, 'src')
+    ...     mkdir(tmp, 'src', 'tellmy')
+    ...     write(tmp, 'src', 'tellmy', '__init__.py',
+    ...         "__import__("
+    ...         "'pkg_resources').declare_namespace(__name__)\n")
+    ...     mkdir(tmp, 'src', 'tellmy', 'fortune')
+    ...     write(tmp, 'src', 'tellmy', 'fortune',
+    ...           '__init__.py', '__version__="1.0"\n')
+    ...     write(
+    ...         tmp, 'setup.py',
+    ...         "from setuptools import setup\n"
+    ...         "setup(\n"
+    ...         " name='tellmy.fortune',\n"
+    ...         " package_dir = {'': 'src'},\n"
+    ...         " packages = ['tellmy', 'tellmy.fortune'],\n"
+    ...         " install_requires = ['setuptools'],\n"
+    ...         " namespace_packages=['tellmy'],\n"
+    ...         " zip_safe=True, version='1.0',\n"
+    ...         " author='bob', url='bob', author_email='bob')\n"
+    ...         )
+    ...     zc.buildout.testing.sdist(tmp, sample_eggs)
+    ...     zc.buildout.testing.sys_install(tmp, site_packages)
+    ... finally:
+    ...     shutil.rmtree(tmp)
+    >>> primed_python = get_executable_with_system_installed_packages()
+
+Now we create a buildout that uses this Python but does not want to
+include site-packages.
+
+    >>> write('buildout.cfg',
+    ... '''
+    ... [buildout]
+    ... parts = eggs
+    ... find-links = %(link_server)s
+    ... include-site-packages = false
+    ...
+    ... [primed_python]
+    ... executable = %(primed_python)s
+    ...
+    ... [eggs]
+    ... recipe = zc.recipe.egg
+    ... python = primed_python
+    ... interpreter = py
+    ... eggs = demo
+    ... initialization =
+    ...     import tellmy
+    ... ''' % globals())
+
+    >>> print system(primed_python+" "+buildout)
+    Installing eggs.
+    Getting distribution for 'demo'.
+    Got demo 0.4c1.
+    Getting distribution for 'demoneeded'.
+    Got demoneeded 1.2c1.
+    Generated script '/sample-buildout/bin/demo'.
+    Generated interpreter '/sample-buildout/bin/py'.
+    <BLANKLINE>
+
+Finally, we are ready for the actual test.  Prior to the bug fix that
+this tests, the results of both calls was no errors. In other words, you
+could still import tellmy because it was stashed in sys.modules, even
+though sys.path had been cleaned out.
+
+    >>> print system(
+    ...     join('bin', 'py') + " -c '" +
+    ...     "import eggrecipedemo\n" +
+    ...     "import tellmy\n" +
+    ...     "'") # doctest: +ELLIPSIS
+    Traceback (most recent call last):
+      ...
+    ImportError: No module named tellmy
+    <BLANKLINE>
+    >>> print system(join('bin', 'demo')) # doctest: +ELLIPSIS
+    Traceback (most recent call last):
+      ...
+    ImportError: No module named tellmy
+    <BLANKLINE>
+    """
+
 def include_site_packages_with_buildout():
     """
 When buildout gets a recipe egg (as opposed to runs a recipe), it starts with
@@ -3556,7 +3777,7 @@
             '''
             [buildout]
             parts = interpreter
-       
+
             [interpreter]
             recipe = zc.recipe.egg
             scripts = py

Modified: zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/update.txt
===================================================================
--- zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/update.txt	2009-09-23 21:12:58 UTC (rev 104464)
+++ zc.buildout/branches/gary-support-system-python-4/src/zc/buildout/update.txt	2009-09-23 21:36:09 UTC (rev 104465)
@@ -21,7 +21,7 @@
     ... index = %(new_releases)s
     ... parts = show-versions
     ... develop = showversions
-    ... 
+    ...
     ... [show-versions]
     ... recipe = showversions
     ... """ % dict(new_releases=new_releases))
@@ -31,7 +31,7 @@
 
     >>> mkdir(sample_buildout, 'showversions')
 
-    >>> write(sample_buildout, 'showversions', 'showversions.py', 
+    >>> write(sample_buildout, 'showversions', 'showversions.py',
     ... """
     ... import pkg_resources
     ...
@@ -52,7 +52,7 @@
     >>> write(sample_buildout, 'showversions', 'setup.py',
     ... """
     ... from setuptools import setup
-    ... 
+    ...
     ... setup(
     ...     name = "showversions",
     ...     entry_points = {'zc.buildout': ['default = showversions:Recipe']},
@@ -85,6 +85,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -97,6 +106,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)
@@ -119,7 +135,7 @@
     ... develop = showversions
     ... zc.buildout-version = < 99
     ... setuptools-version = < 99
-    ... 
+    ...
     ... [show-versions]
     ... recipe = showversions
     ... """ % dict(new_releases=new_releases))
@@ -138,7 +154,7 @@
     setuptools 0.6
 
 There are a number of cases, described below, in which the updates
-don't happen. 
+don't happen.
 
 We won't upgrade in offline mode:
 
@@ -149,7 +165,7 @@
     ... index = %(new_releases)s
     ... parts = show-versions
     ... develop = showversions
-    ... 
+    ...
     ... [show-versions]
     ... recipe = showversions
     ... """ % dict(new_releases=new_releases))
@@ -178,9 +194,9 @@
     ... [buildout]
     ... find-links = %(new_releases)s
     ... index = %(new_releases)s
-    ... parts = 
+    ... parts =
     ... """ % dict(new_releases=new_releases))
-    
+
     >>> cd(sample_buildout2)
     >>> print system(buildout),
     Creating directory '/sample_buildout2/bin'.

Modified: zc.buildout/branches/gary-support-system-python-4/zc.recipe.egg_/src/zc/recipe/egg/README.txt
===================================================================
--- zc.buildout/branches/gary-support-system-python-4/zc.recipe.egg_/src/zc/recipe/egg/README.txt	2009-09-23 21:12:58 UTC (rev 104464)
+++ zc.buildout/branches/gary-support-system-python-4/zc.recipe.egg_/src/zc/recipe/egg/README.txt	2009-09-23 21:36:09 UTC (rev 104465)
@@ -96,7 +96,7 @@
     >>> ls(sample_buildout, 'bin')
     -  buildout
 
-If we want scripts provided by eggs to be installed, we should use the 
+If we want scripts provided by eggs to be installed, we should use the
 scripts recipe:
 
     >>> write(sample_buildout, 'buildout.cfg',
@@ -135,7 +135,7 @@
 
    This option is useful when working with distributions that don't
    declare entry points, such as distributions not written to work
-   with setuptools. 
+   with setuptools.
 
    Examples can be seen in the section "Specifying entry points" below.
 
@@ -271,7 +271,7 @@
     -  setuptools-0.6-py2.3.egg
     -  zc.buildout-1.0-py2.3.egg
 
-If we run the buildout on the default online and newest modes, 
+If we run the buildout on the default online and newest modes,
 we'll get an update for demo:
 
     >>> print system(buildout),
@@ -378,6 +378,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -392,6 +401,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)
@@ -444,6 +460,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -458,6 +483,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)
@@ -504,6 +536,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -518,6 +559,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)
@@ -564,6 +612,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -578,6 +635,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)
@@ -635,6 +699,15 @@
     <BLANKLINE>
     import site
     import sys
+    <BLANKLINE>
+    # Clean out sys.modules from site's processing of .pth files.
+    clean_modules = [
+        ...
+        ]
+    for k in sys.modules.keys():
+        if k not in clean_modules:
+            del sys.modules[k]
+    <BLANKLINE>
     sys.path[:] = [
         ...
         ]
@@ -649,6 +722,13 @@
         ]
     # 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
+    # pkg_resources.  This is only important for namespace packages, so it may
+    # not have been added, so ignore import errors.
+    try:
+        import pkg_resources
+    except ImportError:
+        pass
     # Process .pth files.
     for p in site_dirs:
         site.addsitedir(p)

Modified: zc.buildout/branches/gary-support-system-python-4/zc.recipe.egg_/src/zc/recipe/egg/egg.py
===================================================================
--- zc.buildout/branches/gary-support-system-python-4/zc.recipe.egg_/src/zc/recipe/egg/egg.py	2009-09-23 21:12:58 UTC (rev 104464)
+++ zc.buildout/branches/gary-support-system-python-4/zc.recipe.egg_/src/zc/recipe/egg/egg.py	2009-09-23 21:36:09 UTC (rev 104465)
@@ -58,8 +58,10 @@
 
     @property
     def include_site_packages(self):
-        return get_bool(self.options, 'include-site-packages',
-                        self.buildout['buildout']['include-site-packages'])
+        res = get_bool(self.options, 'include-site-packages', None)
+        if res is None:
+            res = get_bool(self.buildout['buildout'], 'include-site-packages')
+        return res
 
     def working_set(self, extra=()):
         """Separate method to just get the working set



More information about the checkins mailing list