[Checkins] SVN: zc.buildout/branches/gary-4alt/ basic implementation. Current downside: it breaks backward compatibility for people who have something in site-packages. Do we care? News at 11.

Gary Poster gary.poster at canonical.com
Mon Dec 7 16:58:33 EST 2009


Log message for revision 106263:
  basic implementation.  Current downside: it breaks backward compatibility for people who have something in site-packages.  Do we care?  News at 11.

Changed:
  U   zc.buildout/branches/gary-4alt/src/zc/buildout/bootstrap.txt
  U   zc.buildout/branches/gary-4alt/src/zc/buildout/easy_install.py
  U   zc.buildout/branches/gary-4alt/src/zc/buildout/easy_install.txt
  U   zc.buildout/branches/gary-4alt/src/zc/buildout/update.txt
  U   zc.buildout/branches/gary-4alt/zc.recipe.egg_/src/zc/recipe/egg/README.txt

-=-
Modified: zc.buildout/branches/gary-4alt/src/zc/buildout/bootstrap.txt
===================================================================
--- zc.buildout/branches/gary-4alt/src/zc/buildout/bootstrap.txt	2009-12-07 21:54:36 UTC (rev 106262)
+++ zc.buildout/branches/gary-4alt/src/zc/buildout/bootstrap.txt	2009-12-07 21:58:33 UTC (rev 106263)
@@ -58,7 +58,6 @@
     ...
     X
     No local packages or download links found for zc.buildout==UNKNOWN...
-    error: Could not find suitable distribution for Requirement.parse('zc.buildout==UNKNOWN')
     ...
 
 Now let's try with `1.1.2`, which happens to exist::

Modified: zc.buildout/branches/gary-4alt/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/gary-4alt/src/zc/buildout/easy_install.py	2009-12-07 21:54:36 UTC (rev 106262)
+++ zc.buildout/branches/gary-4alt/src/zc/buildout/easy_install.py	2009-12-07 21:58:33 UTC (rev 106263)
@@ -976,7 +976,7 @@
             )
         rpsetup = relative_paths_setup
         for i in range(_relative_depth(relative_paths, sname)):
-            rpsetup += "base = os.path.dirname(base)\n"
+            rpsetup += "\nbase = os.path.dirname(base)"
     else:
         spath = repr(path)[1:-1].replace(', ', ',\n  ')
         rpsetup = ''
@@ -1021,19 +1021,20 @@
 
 
 relative_paths_setup = """
-import os
-
 join = os.path.join
-base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
-"""
+base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))"""
 
+
 def _script(module_name, attrs, path, dest, executable, arguments,
             initialization, rsetup):
     generated = []
     script = dest
     if is_win32:
         dest += '-script.py'
-
+    if rsetup:
+        relative_paths_import = '\nimport os'
+    else:
+        relative_paths_import = ''
     contents = script_template % dict(
         python = _safe_arg(executable),
         path = path,
@@ -1041,6 +1042,7 @@
         attrs = attrs,
         arguments = arguments,
         initialization = initialization,
+        relative_paths_import = relative_paths_import,
         relative_paths_setup = rsetup,
         )
     changed = not (os.path.exists(dest) and open(dest).read() == contents)
@@ -1072,10 +1074,10 @@
     script_header = '#!%(python)s'
 
 
-script_template = script_header + '''\
-
-%(relative_paths_setup)s
+script_template = script_header + ''' -S
+%(relative_paths_import)s
 import sys
+%(relative_paths_setup)s
 sys.path[0:0] = [
   %(path)s,
   ]
@@ -1119,39 +1121,18 @@
     generated.append(dest)
     return generated
 
-py_script_template = script_header + '''\
+py_script_template = script_header + '''
 
-%(relative_paths_setup)s
+import os
 import sys
-
-sys.path[0:0] = [
+%(relative_paths_setup)s
+pythonpath = [
   %(path)s,
   ]
-
-_interactive = True
-if len(sys.argv) > 1:
-    _options, _args = __import__("getopt").getopt(sys.argv[1:], 'ic:m:')
-    _interactive = False
-    for (_opt, _val) in _options:
-        if _opt == '-i':
-            _interactive = True
-        elif _opt == '-c':
-            exec _val
-        elif _opt == '-m':
-            sys.argv[1:] = _args
-            _args = []
-            __import__("runpy").run_module(
-                 _val, {}, "__main__", alter_sys=True)
-
-    if _args:
-        sys.argv[:] = _args
-        __file__ = _args[0]
-        del _options, _args
-        execfile(__file__)
-
-if _interactive:
-    del _interactive
-    __import__("code").interact(banner="", local=globals())
+argv = [sys.executable, '-S'] + sys.argv[1:]
+environ = os.environ.copy()
+environ['PYTHONPATH'] = os.pathsep.join(pythonpath)
+os.execve(sys.executable, argv, environ)
 '''
 
 runsetup_template = """

Modified: zc.buildout/branches/gary-4alt/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/branches/gary-4alt/src/zc/buildout/easy_install.txt	2009-12-07 21:54:36 UTC (rev 106262)
+++ zc.buildout/branches/gary-4alt/src/zc/buildout/easy_install.txt	2009-12-07 21:58:33 UTC (rev 106263)
@@ -581,9 +581,10 @@
 The demo script run the entry point defined in the demo egg:
 
     >>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
     <BLANKLINE>
     import sys
+    <BLANKLINE>
     sys.path[0:0] = [
       '/sample-install/demo-0.3-py2.4.egg',
       '/sample-install/demoneeded-1.1-py2.4.egg',
@@ -618,9 +619,10 @@
     ...     ws, sys.executable, bin)
 
     >>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
     <BLANKLINE>
     import sys
+    <BLANKLINE>
     sys.path[0:0] = [
       '/sample-install/demo-0.3-py2.4.egg',
       '/sample-install/demoneeded-1.1-py2.4.egg',
@@ -664,42 +666,23 @@
     >>> cat(bin, 'py') # doctest: +NORMALIZE_WHITESPACE
     #!/usr/local/bin/python2.4
     <BLANKLINE>
+    import os
     import sys
     <BLANKLINE>
-    sys.path[0:0] = [
+    pythonpath = [
       '/sample-install/demo-0.3-pyN.N.egg',
       '/sample-install/demoneeded-1.1-pyN.N.egg',
       ]
-    <BLANKLINE>
-    _interactive = True
-    if len(sys.argv) > 1:
-        _options, _args = __import__("getopt").getopt(sys.argv[1:], 'ic:m:')
-        _interactive = False
-        for (_opt, _val) in _options:
-            if _opt == '-i':
-                _interactive = True
-            elif _opt == '-c':
-                exec _val
-            elif _opt == '-m':
-                sys.argv[1:] = _args
-                _args = []
-                __import__("runpy").run_module(
-                     _val, {}, "__main__", alter_sys=True)
-    <BLANKLINE>
-        if _args:
-            sys.argv[:] = _args
-            __file__ = _args[0]
-            del _options, _args
-            execfile(__file__)
-    <BLANKLINE>
-    if _interactive:
-        del _interactive
-        __import__("code").interact(banner="", local=globals())
+    argv = [sys.executable, '-S'] + sys.argv[1:]
+    environ = os.environ.copy()
+    environ['PYTHONPATH'] = os.pathsep.join(pythonpath)
+    os.execve(sys.executable, argv, environ)
 
 If invoked with a script name and arguments, it will run that script, instead.
 
     >>> write('ascript', '''
     ... "demo doc"
+    ... import sys
     ... print sys.argv
     ... print (__name__, __file__, __doc__)
     ... ''')
@@ -748,12 +731,13 @@
     ...    extra_paths=[foo])
 
     >>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
     <BLANKLINE>
     import sys
+    <BLANKLINE>
     sys.path[0:0] = [
-      '/sample-install/demo-0.3-py2.4.egg',
-      '/sample-install/demoneeded-1.1-py2.4.egg',
+      '/sample-install/demo-0.3-pyN.N.egg',
+      '/sample-install/demoneeded-1.1-pyN.N.egg',
       '/foo',
       ]
     <BLANKLINE>
@@ -762,6 +746,7 @@
     if __name__ == '__main__':
         eggrecipedemo.main()
 
+
 Providing script arguments
 --------------------------
 
@@ -774,11 +759,13 @@
     ...    arguments='1, 2')
 
     >>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
+    <BLANKLINE>
     import sys
+    <BLANKLINE>
     sys.path[0:0] = [
-      '/sample-install/demo-0.3-py2.4.egg',
-      '/sample-install/demoneeded-1.1-py2.4.egg',
+      '/sample-install/demo-0.3-pyN.N.egg',
+      '/sample-install/demoneeded-1.1-pyN.N.egg',
       ]
     <BLANKLINE>
     import eggrecipedemo
@@ -786,6 +773,7 @@
     if __name__ == '__main__':
         eggrecipedemo.main(1, 2)
 
+
 Passing initialization code
 ---------------------------
 
@@ -797,11 +785,13 @@
     ...    initialization='import os\nos.chdir("foo")')
 
     >>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
+    <BLANKLINE>
     import sys
+    <BLANKLINE>
     sys.path[0:0] = [
-      '/sample-install/demo-0.3-py2.4.egg',
-      '/sample-install/demoneeded-1.1-py2.4.egg',
+      '/sample-install/demo-0.3-pyN.N.egg',
+      '/sample-install/demoneeded-1.1-pyN.N.egg',
       ]
     <BLANKLINE>
     import os
@@ -812,6 +802,7 @@
     if __name__ == '__main__':
         eggrecipedemo.main(1, 2)
 
+
 Relative paths
 --------------
 
@@ -837,15 +828,14 @@
     ...    relative_paths=bo)
 
     >>> cat(bo, 'bin', 'run')
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
     <BLANKLINE>
     import os
+    import sys
     <BLANKLINE>
     join = os.path.join
     base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
     base = os.path.dirname(base)
-    <BLANKLINE>
-    import sys
     sys.path[0:0] = [
       join(base, 'eggs/demo-0.3-pyN.N.egg'),
       join(base, 'eggs/demoneeded-1.1-pyN.N.egg'),
@@ -858,6 +848,7 @@
     if __name__ == '__main__':
         eggrecipedemo.main()
 
+
 Note that the extra path we specified that was outside the directory
 passed as relative_paths wasn't converted to a relative path.
 
@@ -872,44 +863,21 @@
     #!/usr/local/bin/python2.4
     <BLANKLINE>
     import os
+    import sys
     <BLANKLINE>
     join = os.path.join
     base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
     base = os.path.dirname(base)
-    <BLANKLINE>
-    import sys
-    <BLANKLINE>
-    sys.path[0:0] = [
+    pythonpath = [
       join(base, 'eggs/demo-0.3-pyN.N.egg'),
       join(base, 'eggs/demoneeded-1.1-pyN.N.egg'),
       '/ba',
       join(base, 'bar'),
       ]
-    <BLANKLINE>
-    _interactive = True
-    if len(sys.argv) > 1:
-        _options, _args = __import__("getopt").getopt(sys.argv[1:], 'ic:m:')
-        _interactive = False
-        for (_opt, _val) in _options:
-            if _opt == '-i':
-                _interactive = True
-            elif _opt == '-c':
-                exec _val
-            elif _opt == '-m':
-                sys.argv[1:] = _args
-                _args = []
-                __import__("runpy").run_module(
-                     _val, {}, "__main__", alter_sys=True)
-    <BLANKLINE>
-        if _args:
-            sys.argv[:] = _args
-            __file__ = _args[0]
-            del _options, _args
-            execfile(__file__)
-    <BLANKLINE>
-    if _interactive:
-        del _interactive
-        __import__("code").interact(banner="", local=globals())
+    argv = [sys.executable, '-S'] + sys.argv[1:]
+    environ = os.environ.copy()
+    environ['PYTHONPATH'] = os.pathsep.join(pythonpath)
+    os.execve(sys.executable, argv, environ)
 
 
 Handling custom build options for extensions provided in source distributions

Modified: zc.buildout/branches/gary-4alt/src/zc/buildout/update.txt
===================================================================
--- zc.buildout/branches/gary-4alt/src/zc/buildout/update.txt	2009-12-07 21:54:36 UTC (rev 106262)
+++ zc.buildout/branches/gary-4alt/src/zc/buildout/update.txt	2009-12-07 21:58:33 UTC (rev 106263)
@@ -81,12 +81,13 @@
 Our buildout script has been updated to use the new eggs:
 
     >>> cat(sample_buildout, 'bin', 'buildout')
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
     <BLANKLINE>
     import sys
+    <BLANKLINE>
     sys.path[0:0] = [
-      '/sample-buildout/eggs/zc.buildout-99.99-py2.4.egg',
-      '/sample-buildout/eggs/setuptools-99.99-py2.4.egg',
+      '/sample-buildout/eggs/zc.buildout-NINETYNINE.NINETYNINE-pyN.N.egg',
+      '/sample-buildout/eggs/setuptools-NINETYNINE.NINETYNINE-pyN.N.egg',
       ]
     <BLANKLINE>
     import zc.buildout.buildout

Modified: zc.buildout/branches/gary-4alt/zc.recipe.egg_/src/zc/recipe/egg/README.txt
===================================================================
--- zc.buildout/branches/gary-4alt/zc.recipe.egg_/src/zc/recipe/egg/README.txt	2009-12-07 21:54:36 UTC (rev 106262)
+++ zc.buildout/branches/gary-4alt/zc.recipe.egg_/src/zc/recipe/egg/README.txt	2009-12-07 21:58:33 UTC (rev 106263)
@@ -373,12 +373,13 @@
 Let's look at the script that was generated:
 
     >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
     <BLANKLINE>
     import sys
+    <BLANKLINE>
     sys.path[0:0] = [
-      '/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
-      '/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
+      '/sample-buildout/eggs/demo-0.4c1-pyN.N.egg',
+      '/sample-buildout/eggs/demoneeded-1.2c1-pyN.N.egg',
       '/foo/bar',
       '/sample-buildout/spam',
       ]
@@ -388,6 +389,7 @@
     if __name__ == '__main__':
         eggrecipedemo.main()
 
+
 Relative egg paths
 ------------------
 
@@ -420,15 +422,14 @@
 Let's look at the script that was generated:
 
     >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
     <BLANKLINE>
     import os
+    import sys
     <BLANKLINE>
     join = os.path.join
     base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
     base = os.path.dirname(base)
-    <BLANKLINE>
-    import sys
     sys.path[0:0] = [
       join(base, 'eggs/demo-0.4c1-pyN.N.egg'),
       join(base, 'eggs/demoneeded-1.2c1-pyN.N.egg'),
@@ -467,15 +468,14 @@
     Generated script '/sample-buildout/bin/foo'.
 
     >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
     <BLANKLINE>
     import os
+    import sys
     <BLANKLINE>
     join = os.path.join
     base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
     base = os.path.dirname(base)
-    <BLANKLINE>
-    import sys
     sys.path[0:0] = [
       join(base, 'eggs/demo-0.4c1-pyN.N.egg'),
       join(base, 'eggs/demoneeded-1.2c1-pyN.N.egg'),
@@ -488,6 +488,7 @@
     if __name__ == '__main__':
         eggrecipedemo.main()
 
+
 Specifying initialialization code and arguments
 -----------------------------------------------
 
@@ -520,12 +521,13 @@
     Generated script '/sample-buildout/bin/foo'.
 
     >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
     <BLANKLINE>
     import sys
+    <BLANKLINE>
     sys.path[0:0] = [
-      '/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
-      '/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
+      '/sample-buildout/eggs/demo-0.4c1-pyN.N.egg',
+      '/sample-buildout/eggs/demoneeded-1.2c1-pyN.N.egg',
       '/foo/bar',
       '/sample-buildout/spam',
       ]
@@ -538,6 +540,7 @@
     if __name__ == '__main__':
         eggrecipedemo.main(a, 2)
 
+
 Here we see that the initialization code we specified was added after
 setting the path.  Note, as mentioned above, that leading whitespace
 has been stripped.  Similarly, the argument code we specified was
@@ -578,12 +581,13 @@
     -  other
 
     >>> cat(sample_buildout, 'bin', 'other')
-    #!/usr/local/bin/python2.4
+    #!/usr/local/bin/python2.4 -S
     <BLANKLINE>
     import sys
+    <BLANKLINE>
     sys.path[0:0] = [
-      '/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
-      '/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
+      '/sample-buildout/eggs/demo-0.4c1-pyN.N.egg',
+      '/sample-buildout/eggs/demoneeded-1.2c1-pyN.N.egg',
       '/foo/bar',
       '/sample-buildout/spam',
       ]
@@ -593,6 +597,7 @@
     if __name__ == '__main__':
         foo.bar.a.b.c()
 
+
 Generating all scripts
 ----------------------
 



More information about the checkins mailing list