Merge lp://staging/~gary/launchpad/lazr_uri into lp://staging/launchpad

Proposed by Gary Poster
Status: Merged
Approved by: Francis J. Lacoste
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp://staging/~gary/launchpad/lazr_uri
Merge into: lp://staging/launchpad
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~gary/launchpad/lazr_uri
Reviewer Review Type Date Requested Status
Francis J. Lacoste (community) Approve
Review via email: mp+11219@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :
Download full text (5.1 KiB)

This seemingly innocuous branch hides a fair amount of code churn under the surface.

The point of this branch is to eliminate the build problems on Karmic--or more specifically, when lazr.uri was installed by apt.

The problem was caused by the lazr.uri setup.py doing a sys.path hack in the setup.py so that it could import __version__ from its own __init__.py. In the case of lazr.uri, that caused it to import apt's version of the __version__, and so misreport its own version, which halted the build.

The right fix is to make buildout not allow this confusion, if possible. However, a quick fix was to use a newer, already existing version of lazr.uri (1.0.1 -> 1.0.2) because the newer one did not do the sys.path-in-setup.py trick. I tried that first. That did fix the problem for lazr.uri, but then lazr.smtptest, which does a similar trick, fell over for a related reason that I won't get into unless asked.

At that point, I decided to try to change buildout to do the right thing.

This coincided in timing with my trying to bring my zc.buildout branch back up to trunk so that it could be reviewed and merged upstream. It was a good time to work on the two problems, because the merge was going to make me rewrite a part of the code that fixing the sys.path-in-setup.py problem would touch.

Therefore, I merged zc.buildout's trunk with my branch, and in the course of resolving conflicts, rewrote one part of it to accommodate both concerns. The selected versions of zc.buildout, zc.recipe.egg, and z3c.recipe.filetemplate come from this effort. The diff of this effort is thousands of lines, and in zc.buildout's case necessarily merged with the changes from upstream's trunk.

For lack of an idea of what better to do, I include the test for the specific problem from zc.buildout below.

Thank you!

Gary

If you use a Python that has a different version of one of your
dependencies, and the new package tries to do sys.path tricks in the
setup.py to get a __version__, and it uses namespace packages, the older
package will be loaded first, making the setup version the wrong number.
While very arguably packages simply shouldn't do this, some do, and we
don't want buildout to fall over when they do.

To demonstrate this, we will need to create a distribution that has one of
these unpleasant tricks, and a Python that has an older version installed.

    >>> for i in (0, 1):
    ... 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', 'version')
    ... write(tmp, 'src', 'tellmy', 'version',
    ... '__init__.py', '__version__="1.%d"\n' % i)
    ... write(
    ... tmp, 'setup.py',
    ... "from setuptools import setup\n"
    ... "import sys\n"
    ... "sys.path.insert(0, 'src')\n"
    ... "from tellmy.version import __version__\n"
    ... ...

Read more...

Revision history for this message
Francis J. Lacoste (flacoste) wrote :

On IRC, I only asked that the for i in (0,1): part be changed to be more clear about the intent.

Otherwise, r=me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'versions.cfg'
2--- versions.cfg 2009-08-31 20:35:58 +0000
3+++ versions.cfg 2009-09-04 17:23:08 +0000
4@@ -26,7 +26,7 @@
5 lazr.restful = 0.9.5
6 lazr.restfulclient = 0.9.5
7 lazr.smtptest = 1.1
8-lazr.uri = 1.0.1
9+lazr.uri = 1.0.2
10 mechanize = 0.1.7b
11 mocker = 0.10.1
12 mozrunner = 1.3.4
13@@ -70,7 +70,7 @@
14 z3c.pagelet = 1.0.2
15 z3c.pt = 1.0b16
16 z3c.ptcompat = 0.5.3
17-z3c.recipe.filetemplate = 2.1dev-gary-r102489
18+z3c.recipe.filetemplate = 2.1dev-gary-r103545
19 z3c.recipe.i18n = 0.5.3
20 z3c.recipe.tag = 0.2.0
21 z3c.rml = 0.7.3
22@@ -85,9 +85,9 @@
23 zc.catalog = 1.2.0
24 zc.datetimewidget = 0.5.2
25 zc.i18n = 0.5.2
26-zc.buildout = 1.4.0dev-gary-r102684
27+zc.buildout = 1.5.0dev-gary-r103515
28 zc.lockfile = 1.0.0
29-zc.recipe.egg = 1.3.0dev-gary-r102684
30+zc.recipe.egg = 1.3.0dev-gary-r103515
31 zc.zservertracelog = 1.1.5
32 ZConfig = 2.6.1
33 zdaemon = 2.0.2