[Checkins] SVN: z3c.recipe.filetemplate/branches/gary-support-system-python/ use new branch of zc.buildout work; offer indented variant of paths; offer clean sys modules list; handle executables in a more buildout-standard way.
Gary Poster
gary.poster at canonical.com
Wed Oct 14 23:22:02 EDT 2009
Log message for revision 105075:
use new branch of zc.buildout work; offer indented variant of paths; offer clean sys modules list; handle executables in a more buildout-standard way.
Changed:
_U z3c.recipe.filetemplate/branches/gary-support-system-python/
U z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/README.txt
U z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/__init__.py
-=-
Property changes on: z3c.recipe.filetemplate/branches/gary-support-system-python
___________________________________________________________________
Modified: svn:externals
- zc.buildout svn+ssh://svn.zope.org/repos/main/zc.buildout/branches/gary-support-system-python-3
bootstrap svn://svn.zope.org/repos/main/zc.buildout/trunk/bootstrap
+ zc.buildout svn+ssh://svn.zope.org/repos/main/zc.buildout/branches/gary-X-wrap-up
bootstrap svn+ssh://svn.zope.org/repos/main/zc.buildout/branches/gary-X-wrap-up/bootstrap
Modified: z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/README.txt
===================================================================
--- z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/README.txt 2009-10-15 02:54:30 UTC (rev 105074)
+++ z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/README.txt 2009-10-15 03:22:01 UTC (rev 105075)
@@ -267,11 +267,11 @@
... """
... [buildout]
... parts = message
- ...
+ ...
... [template_defaults]
... mygreeting = Hi
... myaudience = World
- ...
+ ...
... [message]
... recipe = z3c.recipe.filetemplate
... files = helloworld.txt
@@ -309,49 +309,63 @@
paths for directories that might contain .pth files (like site-packages
or directories added with extra-paths), and "all_paths" to be the
combination of all three in the order of egg_paths, dir_paths, and
-stdlib_paths. Then combine those with three variants: "os" paths,
-joined by os.pathsep; "string" paths, quoted paths separated by strings,
-suitable for Python lists; and "space" paths, joined by a space. The
-results of the combination are defined roughly as given here.
+stdlib_paths. Then combine those with four variants: "os" paths,
+joined by os.pathsep; "string" paths, quoted paths separated by commas,
+suitable for Python lists; "indented" paths, quoted paths each separated
+by a comma, newline, and a four space indent; and "space" paths, joined
+by a space. The results of the combination are defined roughly as given
+here.
``os-paths``
``(os.pathsep).join(all_paths)``
-
+
``string-paths``
``', '.join(repr(p) for p in all_paths)``
+``indented-paths``
+ ``',\n '.join(repr(p) for p in all_paths)``
+
``space-paths``
``' '.join(all_paths)``
``os-stdlib-paths``
``(os.pathsep).join(stdlib_paths)``
-
+
``string-stdlib-paths``
``', '.join(repr(p) for p in stdlib_paths)``
+``indented-stdlib-paths``
+ ``',\n '.join(repr(p) for p in stdlib_paths)``
+
``space-stdlib-paths``
``' '.join(stdlib_paths)``
``os-egg-paths``
``(os.pathsep).join(egg_paths)``
-
+
``string-egg-paths``
``', '.join(repr(p) for p in egg_paths)``
+``indented-egg-paths``
+ ``',\n '.join(repr(p) for p in egg_paths)``
+
``space-egg-paths``
``' '.join(egg_paths)``
``os-dir-paths``
``(os.pathsep).join(dir_paths)``
-
+
``string-dir-paths``
``', '.join(repr(p) for p in dir_paths)``
+``indented-dir-paths``
+ ``',\n '.join(repr(p) for p in dir_paths)``
+
``space-dir-paths``
``' '.join(dir_paths)``
(Note that you can work with the different path lists in different ways
-with the interpreted options described in the section below.)
+with the interpreted options described in the section below.)
For instance, consider this example.
@@ -359,7 +373,7 @@
... """
... [buildout]
... parts = message
- ...
+ ...
... [message]
... recipe = z3c.recipe.filetemplate
... files = helloworld.txt
@@ -379,6 +393,9 @@
... String paths:
... ${string-paths}
... ---
+ ... Indented paths:
+ ... ${indented-paths}
+ ... ---
... Space paths:
... ${space-paths}
... ---
@@ -388,6 +405,9 @@
... String stdlib paths:
... ${string-stdlib-paths}
... ---
+ ... Indented stdlib paths:
+ ... ${indented-stdlib-paths}
+ ... ---
... Space stdlib paths:
... ${space-stdlib-paths}
... ---
@@ -397,6 +417,9 @@
... String egg paths:
... ${string-egg-paths}
... ---
+ ... Indented egg paths:
+ ... ${indented-egg-paths}
+ ... ---
... Space egg paths:
... ${space-egg-paths}
... ---
@@ -406,6 +429,9 @@
... String dir paths:
... ${string-dir-paths}
... ---
+ ... Indented dir paths:
+ ... ${indented-dir-paths}
+ ... ---
... Space dir paths:
... ${space-dir-paths}
... """)
@@ -426,8 +452,14 @@
String paths:
'.../eggs/demo-0.2...egg', '.../eggs/demoneeded-1.2c1...egg', '...'
---
+ Indented paths:
+ '.../eggs/demo-0.2...egg',
+ '.../eggs/demoneeded-1.2c1...egg',
+ '...'
+ ---
Space paths:
- .../eggs/demo-0.2...egg .../eggs/demoneeded-1.2c1...egg ...
+ .../eggs/demo-0.2...egg .../eggs/demoneeded-1.2c1...egg
+ ...
Notice that included multiple paths. In fact, it includes the site packages
and the standard library, so these are appropriate for entirely replacing
@@ -442,7 +474,7 @@
... """
... [buildout]
... parts = message
- ...
+ ...
... [message]
... recipe = z3c.recipe.filetemplate
... files = helloworld.txt
@@ -495,6 +527,34 @@
Space dir paths:
.../sample-buildout/foo ...
+Identifying clean sys.modules
+=============================
+
+Should you want it, the ``clean-sys-modules`` contains the names of the
+modules loaded when Python is started with -S. They are quoted and indented,
+as would be useful in a Python collection. This can be useful for
+writing scripts that need to be able to run as if site-packages were not
+loaded.
+
+ >>> write(sample_buildout, 'helloworld.txt.in',
+ ... """
+ ... Hello! Here are the clean sys.modules.
+ ... ${clean-sys-modules}
+ ... """)
+
+ >>> print system(buildout)
+ Uninstalling message.
+ Installing message.
+ <BLANKLINE>
+
+ >>> cat(sample_buildout, 'helloworld.txt') # doctest:+ELLIPSIS
+ Hello! Here are the clean sys.modules.
+ ...,
+ 'os',
+ 'os.path',
+ ...
+
+
Defining options in Python
==========================
@@ -526,12 +586,14 @@
egg_paths, dir_paths, and stdlib_paths.
``paths``
A shorthand for ``all_paths``.
+``clean_sys_modules``
+ The sys.modules names loaded when the executable is started with -S.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = message
- ...
+ ...
... [message]
... recipe = z3c.recipe.filetemplate
... files = helloworld.txt
@@ -543,8 +605,9 @@
... message-reversed-is-egassem
... my-name = name
... paths-are-equivalent
- ...
- ... first-interpreted-option =
+ ... sys-mods = repr(clean_sys_modules)
+ ...
+ ... first-interpreted-option =
... options['interpreted-options'].split()[0].strip()
... message-reversed-is-egassem=
... ''.join(
@@ -568,6 +631,7 @@
... message-reversed-is-egassem: ${message-reversed-is-egassem}
... my-name: ${my-name}
... paths-are-equivalent: ${paths-are-equivalent}
+ ... sys-mods: ${sys-mods}
... """)
>>> print system(buildout)
@@ -583,3 +647,4 @@
message-reversed-is-egassem: egassem
my-name: message
paths-are-equivalent: True
+ sys-mods: [..., 'os', 'os.path', ...]
Modified: z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/__init__.py
===================================================================
--- z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/__init__.py 2009-10-15 02:54:30 UTC (rev 105074)
+++ z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/__init__.py 2009-10-15 03:22:01 UTC (rev 105075)
@@ -43,11 +43,14 @@
defaults.update(self.buildout[section_name])
for key, value in defaults.items():
self.options.setdefault(key, value)
+ python_section = options.get('python', buildout['buildout']['python'])
+ self.options.setdefault(
+ 'executable', buildout[python_section]['executable'])
# set up paths for eggs, if given
all_paths = []
if 'eggs' in self.options:
relative_paths = self.options.get(
- 'relative-paths',
+ 'relative-paths',
buildout['buildout'].get('relative-paths', 'false')
)
if relative_paths != 'false':
@@ -76,7 +79,14 @@
self.options['os-%s' % (path_name,)] = (os.pathsep).join(paths)
self.options['string-%s' % (path_name,)] = ', '.join(
repr(p) for p in paths)
+ self.options['indented-%s' % (path_name,)] = ',\n '.join(
+ repr(p) for p in paths)
self.options['space-%s' % (path_name,)] = ' '.join(paths)
+ clean_sys_modules = zc.buildout.easy_install.get_clean_sys_modules(
+ self.options['executable'])
+ clean_sys_modules.sort()
+ self.options['clean-sys-modules'] = ',\n '.join(
+ repr(name) for name in clean_sys_modules)
# get and check the files to be created
self.filenames = self.options.get('files', '*').split()
self.source_dir = self.options.get('source-directory', '').strip()
@@ -173,7 +183,8 @@
locs = {'name': name, 'options': options, 'buildout': buildout,
'paths': all_paths, 'all_paths': all_paths,
'stdlib_paths': stdlib, 'egg_paths': egg_paths,
- 'dir_paths': dir_paths}
+ 'dir_paths': dir_paths,
+ 'clean_sys_modules': clean_sys_modules,}
for value in interpreted.split('\n'):
if value:
value = value.split('=', 1)
More information about the checkins
mailing list