[Checkins] SVN: z3c.setuptools_mercurial/trunk/ - Bug: Improve the Buildout support. Thanks to Gary Poster for helping
Stephan Richter
srichter at gmail.com
Mon Aug 30 17:02:56 EDT 2010
Log message for revision 116041:
- Bug: Improve the Buildout support. Thanks to Gary Poster for helping
me out.
- Get ready for release.
Changed:
U z3c.setuptools_mercurial/trunk/CHANGES.txt
U z3c.setuptools_mercurial/trunk/buildout.cfg
U z3c.setuptools_mercurial/trunk/setup.py
U z3c.setuptools_mercurial/trunk/src/z3c/setuptools_mercurial/README.txt
U z3c.setuptools_mercurial/trunk/src/z3c/setuptools_mercurial/finder.py
-=-
Modified: z3c.setuptools_mercurial/trunk/CHANGES.txt
===================================================================
--- z3c.setuptools_mercurial/trunk/CHANGES.txt 2010-08-30 19:35:30 UTC (rev 116040)
+++ z3c.setuptools_mercurial/trunk/CHANGES.txt 2010-08-30 21:02:56 UTC (rev 116041)
@@ -2,10 +2,10 @@
CHANGES
=======
-1.1.1 (2010-??-??)
+1.1.1 (2010-08-30)
------------------
-- ...
+- Bug: Improve the Buildout support. Thanks to Gary Poster for helping me out.
1.1.0 (2010-08-30)
------------------
Modified: z3c.setuptools_mercurial/trunk/buildout.cfg
===================================================================
--- z3c.setuptools_mercurial/trunk/buildout.cfg 2010-08-30 19:35:30 UTC (rev 116040)
+++ z3c.setuptools_mercurial/trunk/buildout.cfg 2010-08-30 21:02:56 UTC (rev 116041)
@@ -11,6 +11,7 @@
recipe = zc.recipe.testrunner
include-site-packages = true
eggs = z3c.setuptools_mercurial [test]
+ zc.buildout
defaults = ['--coverage', '${buildout:directory}/coverage']
[coverage-report]
Modified: z3c.setuptools_mercurial/trunk/setup.py
===================================================================
--- z3c.setuptools_mercurial/trunk/setup.py 2010-08-30 19:35:30 UTC (rev 116040)
+++ z3c.setuptools_mercurial/trunk/setup.py 2010-08-30 21:02:56 UTC (rev 116041)
@@ -23,7 +23,7 @@
setup (
name='z3c.setuptools_mercurial',
- version='1.1.1dev',
+ version='1.1.1',
author = "Stephan Richter and the Zope Community",
author_email = "zope-dev at zope.org",
description = "Mercurial File Finder Plugin for Setuptools",
Modified: z3c.setuptools_mercurial/trunk/src/z3c/setuptools_mercurial/README.txt
===================================================================
--- z3c.setuptools_mercurial/trunk/src/z3c/setuptools_mercurial/README.txt 2010-08-30 19:35:30 UTC (rev 116040)
+++ z3c.setuptools_mercurial/trunk/src/z3c/setuptools_mercurial/README.txt 2010-08-30 21:02:56 UTC (rev 116041)
@@ -65,3 +65,23 @@
>>> finder.find_files(os.path.join(repos, 'dir1'))
['data1.txt',
'dir11/data1.txt']
+
+Buildout 1.5 and higher
+-----------------------
+
+When one uses zc.buildout 1.5 or higher, the system's environment is
+manipulated. In particular, the PYTHONPATH OS environment variable is
+rewritten. In that case it should be deleted:
+
+ >>> import os
+ >>> bo_orig_path = os.environ.pop('BUILDOUT_ORIGINAL_PYTHONPATH', None)
+ >>> orig_path = os.environ.get('PYTHONPATH')
+ >>> os.environ['PYTHONPATH'] = '/bogus'
+
+ >>> finder.find_files(os.path.join(repos, 'dir1'))
+ ['data1.txt', 'dir11/data1.txt']
+
+ >>> if bo_orig_path:
+ ... os.environ['BUILDOUT_ORIGINAL_PYTHONPATH'] = bo_orig_path
+ >>> if orig_path:
+ ... os.environ['PYTHONPATH'] = orig_path
Modified: z3c.setuptools_mercurial/trunk/src/z3c/setuptools_mercurial/finder.py
===================================================================
--- z3c.setuptools_mercurial/trunk/src/z3c/setuptools_mercurial/finder.py 2010-08-30 19:35:30 UTC (rev 116040)
+++ z3c.setuptools_mercurial/trunk/src/z3c/setuptools_mercurial/finder.py 2010-08-30 21:02:56 UTC (rev 116041)
@@ -16,33 +16,39 @@
import logging
import os
import os.path
+import pkg_resources
import subprocess
+def get_buildout_version():
+ pkg = pkg_resources.working_set.find(
+ pkg_resources.Requirement.parse('zc.buildout'))
+ if pkg is None:
+ return ('00000000',)
+ return pkg_resources.parse_version(pkg.version)
+
def find_files(dirname="."):
"""Find all files checked into a mercurial repository."""
dirname = os.path.abspath(dirname)
# Support for zc.buildout 1.5 and higher.
- python_path = None
+ env = os.environ.copy()
if 'BUILDOUT_ORIGINAL_PYTHONPATH' in os.environ:
- python_path = os.environ['PYTHONPATH']
- os.environ['PYTHONPATH'] = os.environ['BUILDOUT_ORIGINAL_PYTHONPATH']
+ env['PYTHONPATH'] = os.environ['BUILDOUT_ORIGINAL_PYTHONPATH']
+ elif 'PYTHONPATH' in env:
+ if get_buildout_version() >= pkg_resources.parse_version('1.5.0'):
+ del env['PYTHONPATH']
try:
# List all files of the repository as absolute paths.
proc = subprocess.Popen(['hg', 'locate', '-f'],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
- cwd=dirname)
+ cwd=dirname,
+ env=env)
stdout, stderr = proc.communicate()
except Exception, err:
logging.error(str(err))
- if python_path:
- os.environ['PYTHONPATH'] = python_path
# If anything happens, return an empty list.
return []
- if python_path:
- os.environ['PYTHONPATH'] = python_path
-
# The process finished, but returned an error code.
if proc.returncode != 0:
logging.error(stderr+ ' (code %i)' %proc.returncode)
More information about the checkins
mailing list