[Checkins] SVN: zc.buildout/branches/gary-support-system-python/ support PYTHONPATH in scripts; use standard buildout bootstrap in dev.py; fix bug in egg recipe that did not honor include-site-packages; fix test fragility.

Gary Poster gary.poster at canonical.com
Tue Aug 11 14:36:59 EDT 2009


Log message for revision 102680:
  support PYTHONPATH in scripts; use standard buildout bootstrap in dev.py; fix bug in egg recipe that did not honor include-site-packages; fix test fragility.

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

-=-
Modified: zc.buildout/branches/gary-support-system-python/bootstrap/bootstrap.py
===================================================================
--- zc.buildout/branches/gary-support-system-python/bootstrap/bootstrap.py	2009-08-11 15:53:10 UTC (rev 102679)
+++ zc.buildout/branches/gary-support-system-python/bootstrap/bootstrap.py	2009-08-11 18:36:59 UTC (rev 102680)
@@ -39,7 +39,7 @@
     any of the following options *and* buildout command-line options like
     -c, first use the following options, and then use the buildout options.
 
-    Options: 
+    Options:
       --version=ZC_BUILDOUT_VERSION
                 Specify a version number of the zc.buildout to use
       --ez_setup-source=URL_OR_FILE

Modified: zc.buildout/branches/gary-support-system-python/dev.py
===================================================================
--- zc.buildout/branches/gary-support-system-python/dev.py	2009-08-11 15:53:10 UTC (rev 102679)
+++ zc.buildout/branches/gary-support-system-python/dev.py	2009-08-11 18:36:59 UTC (rev 102680)
@@ -47,9 +47,8 @@
 
 pkg_resources.working_set.add_entry('src')
 
-import zc.buildout.easy_install
-zc.buildout.easy_install.scripts(
-    ['zc.buildout'], pkg_resources.working_set , sys.executable, 'bin')
+import zc.buildout.buildout
+zc.buildout.buildout.main(['bootstrap'])
 
 bin_buildout = os.path.join('bin', 'buildout')
 

Modified: zc.buildout/branches/gary-support-system-python/src/zc/buildout/bootstrap.txt
===================================================================
--- zc.buildout/branches/gary-support-system-python/src/zc/buildout/bootstrap.txt	2009-08-11 15:53:10 UTC (rev 102679)
+++ zc.buildout/branches/gary-support-system-python/src/zc/buildout/bootstrap.txt	2009-08-11 18:36:59 UTC (rev 102680)
@@ -127,7 +127,7 @@
     >>> write('ez_setup.py', '''\
     ... def use_setuptools(**kwargs):
     ...     import sys, pprint
-    ...     pprint.pprint(kwargs)
+    ...     pprint.pprint(kwargs, width=40)
     ...     sys.exit()
     ... ''')
     >>> print system(
@@ -155,7 +155,7 @@
 
     >>> print system(
     ...     zc.buildout.easy_install._safe_arg(sys.executable)+' '+
-    ...     'bootstrap.py --help')
+    ...     'bootstrap.py --help'),
     ... # doctest: +ELLIPSIS
     Bootstrap a buildout-based project
     <BLANKLINE>
@@ -171,7 +171,7 @@
     any of the following options *and* buildout command-line options like
     -c, first use the following options, and then use the buildout options.
     <BLANKLINE>
-    Options: 
+    Options:
       --version=ZC_BUILDOUT_VERSION
                 Specify a version number of the zc.buildout to use
       --ez_setup-source=URL_OR_FILE
@@ -188,6 +188,3 @@
     By using --ez_setup-source and --download-base to point to local resources,
     you can keep this script from going over the network.
     <BLANKLINE>
-    <BLANKLINE>
-
-

Modified: zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.py	2009-08-11 15:53:10 UTC (rev 102679)
+++ zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.py	2009-08-11 18:36:59 UTC (rev 102680)
@@ -1056,19 +1056,19 @@
 def get_path(working_set, executable, extra_paths=(),
              include_site_packages=True):
     """Given working set and path to executable, return value for sys.path.
-    
+
     Distribution locations from the working set come first in the list.  Within
     that collection, this function pushes site-packages-based distribution
     locations to the end of the list, so that they don't mask eggs.
-    
+
     This expects that the working_set has already been created to honor a
     include_site_packages setting.  That is, if include_site_packages is False,
     this function does *not* verify that the working_set's distributions are
     not in site packages.
-    
+
     However, it does explicitly include site packages if include_site_packages
     is True.
-    
+
     The standard library (defined as what the given Python executable has on
     the path before its site.py is run) is always included.
     """
@@ -1260,8 +1260,9 @@
 script_template = script_header + '''\
 
 %(relative_paths_setup)s
-import sys
-sys.path[:] = [
+import sys, os
+pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+sys.path[:] = pythonpath + [
     %(path)s,
     ]
 %(initialization)s
@@ -1309,7 +1310,7 @@
 globs = globals().copy() # get a clean copy early
 
 %(relative_paths_setup)s
-import sys
+import sys, os
 
 _set_path = _interactive = True
 _force_interactive = False
@@ -1345,6 +1346,8 @@
     sys.path[:] = [
     %(path)s,
     ]
+pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+sys.path[0:0] = pythonpath
 sys.path.insert(0, '.')
 
 sys.argv[:] = _args
@@ -1463,4 +1466,3 @@
                     subprocess.call([sys.executable, args])
                 else:
                     os.spawnv(os.P_WAIT, sys.executable, args)
-

Modified: zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.txt	2009-08-11 15:53:10 UTC (rev 102679)
+++ zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.txt	2009-08-11 18:36:59 UTC (rev 102680)
@@ -650,8 +650,9 @@
     >>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
     #!/usr/local/bin/python2.4
     <BLANKLINE>
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
         '/sample-install/demo-0.3-py2.4.egg',
         '/sample-install/demoneeded-1.1-py2.4.egg',
         ...
@@ -689,8 +690,9 @@
     >>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
     #!/usr/local/bin/python2.4
     <BLANKLINE>
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
         '/sample-install/demo-0.3-py2.4.egg',
         '/sample-install/demoneeded-1.1-py2.4.egg',
         ...
@@ -735,7 +737,7 @@
     #!/usr/local/bin/python2.4
     globs = globals().copy() # get a clean copy early
     <BLANKLINE>
-    import sys
+    import sys, os
     <BLANKLINE>
     _set_path = _interactive = True
     _force_interactive = False
@@ -773,6 +775,8 @@
         '/sample-install/demoneeded-1.1-pyN.N.egg',
         ...
         ]
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[0:0] = pythonpath
     sys.path.insert(0, '.')
     <BLANKLINE>
     sys.argv[:] = _args
@@ -825,8 +829,9 @@
     >>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
     #!/usr/local/bin/python2.4
     <BLANKLINE>
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
       '/sample-install/demo-0.3-py2.4.egg',
       '/sample-install/demoneeded-1.1-py2.4.egg',
       '/foo',
@@ -846,7 +851,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,
@@ -913,8 +918,9 @@
 
     >>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
     #!/usr/local/bin/python2.4
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
       '/sample-install/demo-0.3-py2.4.egg',
       '/sample-install/demoneeded-1.1-py2.4.egg',
       ...
@@ -937,8 +943,9 @@
 
     >>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
     #!/usr/local/bin/python2.4
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
         '/sample-install/demo-0.3-py2.4.egg',
         '/sample-install/demoneeded-1.1-py2.4.egg',
         ...
@@ -985,8 +992,9 @@
     base = os.path.dirname(os.path.abspath(__file__))
     base = os.path.dirname(base)
     <BLANKLINE>
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
         join(base, 'eggs/demo-0.3-pyN.N.egg'),
         join(base, 'eggs/demoneeded-1.1-pyN.N.egg'),
         '/ba',
@@ -1020,7 +1028,7 @@
     base = os.path.dirname(os.path.abspath(__file__))
     base = os.path.dirname(base)
     <BLANKLINE>
-    import sys
+    import sys, os
     <BLANKLINE>
     _set_path = _interactive = True
     _force_interactive = False
@@ -1060,6 +1068,8 @@
         join(base, 'bar'),
         ...,
         ]
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[0:0] = pythonpath
     sys.path.insert(0, '.')
     <BLANKLINE>
     sys.argv[:] = _args

Modified: zc.buildout/branches/gary-support-system-python/src/zc/buildout/update.txt
===================================================================
--- zc.buildout/branches/gary-support-system-python/src/zc/buildout/update.txt	2009-08-11 15:53:10 UTC (rev 102679)
+++ zc.buildout/branches/gary-support-system-python/src/zc/buildout/update.txt	2009-08-11 18:36:59 UTC (rev 102680)
@@ -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']},
@@ -83,8 +83,9 @@
     >>> cat(sample_buildout, 'bin', 'buildout') # doctest: +ELLIPSIS
     #!/usr/local/bin/python2.4
     <BLANKLINE>
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
         '/sample-buildout/eggs/zc.buildout-99.99-py2.4.egg',
         '/sample-buildout/eggs/setuptools-99.99-py2.4.egg',
         ...
@@ -108,7 +109,7 @@
     ... develop = showversions
     ... zc.buildout-version = < 99
     ... setuptools-version = < 99
-    ... 
+    ...
     ... [show-versions]
     ... recipe = showversions
     ... """ % dict(new_releases=new_releases))
@@ -127,7 +128,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:
 
@@ -138,7 +139,7 @@
     ... index = %(new_releases)s
     ... parts = show-versions
     ... develop = showversions
-    ... 
+    ...
     ... [show-versions]
     ... recipe = showversions
     ... """ % dict(new_releases=new_releases))
@@ -167,9 +168,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/zc.recipe.egg_/src/zc/recipe/egg/README.txt
===================================================================
--- zc.buildout/branches/gary-support-system-python/zc.recipe.egg_/src/zc/recipe/egg/README.txt	2009-08-11 15:53:10 UTC (rev 102679)
+++ zc.buildout/branches/gary-support-system-python/zc.recipe.egg_/src/zc/recipe/egg/README.txt	2009-08-11 18:36:59 UTC (rev 102680)
@@ -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),
@@ -376,8 +376,9 @@
     ... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
     #!/usr/local/bin/python2.4
     <BLANKLINE>
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
         '/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
         '/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
         '/foo/bar',
@@ -431,8 +432,9 @@
     base = os.path.dirname(os.path.abspath(__file__))
     base = os.path.dirname(base)
     <BLANKLINE>
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
         join(base, 'eggs/demo-0.4c1-pyN.N.egg'),
         join(base, 'eggs/demoneeded-1.2c1-pyN.N.egg'),
         '/foo/bar',
@@ -480,8 +482,9 @@
     base = os.path.dirname(os.path.abspath(__file__))
     base = os.path.dirname(base)
     <BLANKLINE>
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
         join(base, 'eggs/demo-0.4c1-pyN.N.egg'),
         join(base, 'eggs/demoneeded-1.2c1-pyN.N.egg'),
         '/foo/bar',
@@ -529,8 +532,9 @@
     ... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
     #!/usr/local/bin/python2.4
     <BLANKLINE>
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
         '/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
         '/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
         '/foo/bar',
@@ -588,8 +592,9 @@
     >>> cat(sample_buildout, 'bin', 'other') # doctest: +ELLIPSIS
     #!/usr/local/bin/python2.4
     <BLANKLINE>
-    import sys
-    sys.path[:] = [
+    import sys, os
+    pythonpath = filter(None, os.environ.get('PYTHONPATH', '').split(':'))
+    sys.path[:] = pythonpath + [
         '/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
         '/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
         '/foo/bar',

Modified: zc.buildout/branches/gary-support-system-python/zc.recipe.egg_/src/zc/recipe/egg/egg.py
===================================================================
--- zc.buildout/branches/gary-support-system-python/zc.recipe.egg_/src/zc/recipe/egg/egg.py	2009-08-11 15:53:10 UTC (rev 102679)
+++ zc.buildout/branches/gary-support-system-python/zc.recipe.egg_/src/zc/recipe/egg/egg.py	2009-08-11 18:36:59 UTC (rev 102680)
@@ -42,7 +42,7 @@
         allow_hosts = b_options['allow-hosts']
         allow_hosts = tuple([host.strip() for host in allow_hosts.split('\n')
                                if host.strip()!=''])
-        self.allow_hosts = allow_hosts 
+        self.allow_hosts = allow_hosts
 
         options['eggs-directory'] = b_options['eggs-directory']
         options['_e'] = options['eggs-directory'] # backward compat.
@@ -56,6 +56,11 @@
         python = options.get('python', b_options['python'])
         options['executable'] = buildout[python]['executable']
 
+    @property
+    def include_site_packages(self):
+        return get_bool(self.options, 'include-site-packages',
+                        self.buildout['buildout']['include-site-packages'])
+
     def working_set(self, extra=()):
         """Separate method to just get the working set
 
@@ -76,13 +81,11 @@
                 options.get(
                     'allowed-eggs-from-site-packages',
                     b_options['allowed-eggs-from-site-packages']).split('\n'))}
-        if 'include-site-packages' in options:
-            kw['include_site_packages'] = get_bool(
-                options, 'include-site-packages')
         if self.buildout['buildout'].get('offline') == 'true':
             ws = zc.buildout.easy_install.working_set(
                 distributions, options['executable'],
                 [options['develop-eggs-directory'], options['eggs-directory']],
+                include_site_packages = self.include_site_packages,
                 **kw
                 )
         else:
@@ -91,11 +94,12 @@
             ws = zc.buildout.easy_install.install(
                 distributions, options['eggs-directory'],
                 links=self.links,
-                index=self.index, 
+                index=self.index,
                 executable=options['executable'],
                 path=[options['develop-eggs-directory']],
                 newest=self.buildout['buildout'].get('newest') == 'true',
                 allow_hosts=self.allow_hosts,
+                include_site_packages = self.include_site_packages,
                 **kw)
 
         return orig_distributions, ws
@@ -124,7 +128,7 @@
 
 
         relative_paths = options.get(
-            'relative-paths', 
+            'relative-paths',
             buildout['buildout'].get('relative-paths', 'false')
             )
         if relative_paths == 'true':
@@ -159,7 +163,7 @@
                 reqs.append(parsed.groups())
 
             if get_bool(options, 'dependent-scripts'):
-                # generate scripts for all packages in the working set,
+                # Generate scripts for all packages in the working set,
                 # except setuptools.
                 reqs = list(reqs)
                 for dist in ws:
@@ -167,10 +171,6 @@
                     if name != 'setuptools' and name not in reqs:
                         reqs.append(name)
 
-            kw = {}
-            if 'include-site-packages' in options:
-                kw['include_site_packages'] = get_bool(
-                    options, 'include-site-packages')
             return zc.buildout.easy_install.scripts(
                 reqs, ws, options['executable'],
                 options['bin-directory'],
@@ -180,7 +180,7 @@
                 initialization=options.get('initialization', ''),
                 arguments=options.get('arguments', ''),
                 relative_paths=self._relative_paths,
-                **kw
+                include_site_packages = self.include_site_packages,
                 )
 
         return ()



More information about the Checkins mailing list