Merge lp:~brian.curtin/ubuntuone-dev-tools/prefer-path into lp:ubuntuone-dev-tools

Proposed by Brian Curtin on 2012-01-20
Status: Rejected
Rejected by: Brian Curtin on 2012-01-20
Proposed branch: lp:~brian.curtin/ubuntuone-dev-tools/prefer-path
Merge into: lp:ubuntuone-dev-tools
Diff against target: 30 lines (+11/-2)
1 file modified
bin/u1lint (+11/-2)
To merge this branch: bzr merge lp:~brian.curtin/ubuntuone-dev-tools/prefer-path
Reviewer Review Type Date Requested Status
Roberto Alsina (community) 2012-01-20 Approve on 2012-01-20
Review via email: mp+89475@code.launchpad.net

Commit Message

Check on the Path for python.exe before looking in the registry, to allow buildout-based setups to work with the proper Python setup. Additionally, for the buildout setups, check for scripts next to python.exe before trying the traditional Scripts/ folder.

Description of the Change

u1lint should prefer the Python on the path and fall back to checking the registry. When running within a buildout, the copy of Python that gets run is on the Path and not in the registry, so the wrong one ends up being found.

Additionally, in that buildout setup, scripts appear next to python.exe rather than in a Scripts folder (like on a regular install). Check first whether the script is beside python.exe and fall back to Scripts/.

To post a comment you must log in.
Roberto Alsina (ralsina) wrote :

+1

review: Approve
57. By Brian Curtin on 2012-01-20

Add the missing os.path.join - corrects a push of a bad version of the file.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/u1lint'
2--- bin/u1lint 2011-12-19 22:37:31 +0000
3+++ bin/u1lint 2012-01-20 18:51:23 +0000
4@@ -38,7 +38,12 @@
5 """Return the path where python was installed."""
6 assert(sys.platform == 'win32')
7 # To get the correct path of the script we need the installation path
8- # of python. To get the isntallation path we read the registry.
9+ # of python. To get the installation path we first check on the path,
10+ # then read the registry.
11+
12+ for path in os.getenv("Path", "").split(";"):
13+ if os.path.exists(os.path.join(path, "python.exe")):
14+ return path
15
16 # pylint: disable=F0401
17 import _winreg
18@@ -78,7 +83,11 @@
19 if sys.platform == 'win32':
20 if python_path is None:
21 python_path = find_python_installation_path()
22- return os.path.join(python_path, 'Scripts', script)
23+ # In a buildout the scripts go next to python.exe, no Scripts folder.
24+ if os.path.exists(python_path, script):
25+ return os.path.join(python_path, script)
26+ else:
27+ return os.path.join(python_path, 'Scripts', script)
28 else:
29 # the default is to return the name of the script beacuse we expect it
30 # to be executable and in the path.

Subscribers

People subscribed via source and target branches

to all changes: