Merge lp:~vila/u1-test-utils/fix-version-handling into lp:u1-test-utils

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: 98
Merged at revision: 97
Proposed branch: lp:~vila/u1-test-utils/fix-version-handling
Merge into: lp:u1-test-utils
Diff against target: 30 lines (+10/-2)
1 file modified
fabfile/environment.py (+10/-2)
To merge this branch: bzr merge lp:~vila/u1-test-utils/fix-version-handling
Reviewer Review Type Date Requested Status
Leo Arias (community) code review, reproduced the problems, tested the fixes Approve
Review via email: mp+187482@code.launchpad.net

Commit message

Fix virtualenv version handling and work around fabric scary "let's pop sys.path blindly" bug.

Description of the change

virtualenv version handling was broken:

  '1.10' < '1.7' -> True

whereas
   [1, 10] < [1, 7] -> False

Trivial but conservative fix below (no need to go into 1.11.beta1 madness).

Once again, I wish fab tasks can be properly tested...

To post a comment you must log in.
98. By Vincent Ladeuil

Work around fabric removing the first entry in the path.

Revision history for this message
Leo Arias (elopio) wrote :

Thank you!

review: Approve (code review, reproduced the problems, tested the fixes)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'fabfile/environment.py'
2--- fabfile/environment.py 2013-04-12 16:00:54 +0000
3+++ fabfile/environment.py 2013-09-25 16:52:55 +0000
4@@ -46,9 +46,12 @@
5 virtualenv_bin_path = local('which virtualenv', capture=True)
6 virtualenv_version = local('{0} {1} --version'.format(
7 sys.executable, virtualenv_bin_path), capture=True)
8+ # We only care about major.minor revision numbers
9+ version_strings = virtualenv_version.split('.')[0:1]
10+ virtualenv_version = [int(x) for x in version_strings]
11 args = '--distribute --clear'
12- if virtualenv_version < '1.7':
13- args += ' --no-site-packagaes'
14+ if virtualenv_version < [1, 7]:
15+ args += ' --no-site-packages'
16 local('{0} {1} {2} {3}'.format(sys.executable, virtualenv_bin_path,
17 args, VIRTUALENV), capture=False)
18
19@@ -57,6 +60,11 @@
20 activate_this = os.path.abspath(
21 '{0}/bin/activate_this.py'.format(env.virtualenv))
22 execfile(activate_this, dict(__file__=activate_this))
23+ # Work around fabric unconditionally removing first entry in sys.path by
24+ # adding a dummy one. Agreed with Leo on IRC that the workaround is ok as
25+ # the plan is to stop using fabric in the long run and the bug itself is a
26+ # blocker. -- vila 2013-09-25
27+ sys.path.insert(0, '/I-dont-exist-blow-me-away-I-dont-care')
28
29
30 def _install_dependencies():

Subscribers

People subscribed via source and target branches

to all changes: