Merge lp:~rafalcieslak256/ubuntu-accomplishments-viewer/982246 into lp:ubuntu-accomplishments-viewer

Proposed by Rafał Cieślak
Status: Merged
Merged at revision: 10
Proposed branch: lp:~rafalcieslak256/ubuntu-accomplishments-viewer/982246
Merge into: lp:ubuntu-accomplishments-viewer
Diff against target: 29 lines (+12/-0)
1 file modified
bin/accomplishments-viewer (+12/-0)
To merge this branch: bzr merge lp:~rafalcieslak256/ubuntu-accomplishments-viewer/982246
Reviewer Review Type Date Requested Status
Jono Bacon Pending
Review via email: mp+102031@code.launchpad.net

Description of the change

This branch is meant to fix #982246 in the viewer, by introducing proper PATH setting.

This merge is related to https://code.launchpad.net/~rafalcieslak256/ubuntu-accomplishments-daemon/982246/+merge/102030, it fixes the same problem in the daemon.

The client-side fix turned out to be much simpler, as it is enough to repair the PATH in bin/accomplishment-viewer launcher. The problem was that the launcher was setting the path correctly only if it was installed to /opt/extras.ubuntu.com/accomplishments-viewer, I made it simply add the required locations based on PROJECT_ROOT_DIRECTORY.

===
That change introduces one more great feature:
It is now possible to pair a certain version of daemon/client. By installing BOTH the daemon and client to the same directory one can be sure that the client will use the api files from exactly that daemon installation.

Also, although I have not checked it because I do not have these packaging scripts, I think it may be beneficial when it comes to packaging. I'm unsure of how it works with python, but e.g. autotools love to set their custom prefix for packages, and supporting that within the app's code is a desired feature.

===
The next step would be to fix #982047 so that it works not only in packages, but in any installation :-)

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/accomplishments-viewer'
2--- bin/accomplishments-viewer 2012-04-10 04:29:26 +0000
3+++ bin/accomplishments-viewer 2012-04-15 15:34:19 +0000
4@@ -15,6 +15,17 @@
5 PROJECT_ROOT_DIRECTORY = os.path.abspath(
6 os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))
7
8+# Prepate paths for importing modules
9+sys.path.insert(0,os.path.join(PROJECT_ROOT_DIRECTORY,'lib/python2.7/site-packages'))
10+sys.path.insert(0,os.path.join(PROJECT_ROOT_DIRECTORY,'lib/python2.7/dist-packages'))
11+os.environ["PYTHONPATH"] = "$PYTHONPATH:."
12+os.environ['PYTHONPATH'] = os.path.join(PROJECT_ROOT_DIRECTORY,'lib/python2.7/site-packages') + ":" + os.environ['PYTHONPATH']
13+os.environ['PYTHONPATH'] = os.path.join(PROJECT_ROOT_DIRECTORY,'lib/python2.7/dist-packages') + ":" + os.environ['PYTHONPATH']
14+
15+# Original code, left for convenience. Reasons why it is discarted:
16+# - It supports installation only in /opt/extras.ubuntu.com/accomplishments-viewer
17+# - It does not set site-packages directory, which seems to be nessesary
18+"""
19 python_path = []
20 if os.path.abspath(__file__).startswith('/opt'):
21 syspath = sys.path[:] # copy to avoid infinite loop in pending objects
22@@ -28,6 +39,7 @@
23 sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
24 if python_path:
25 os.putenv('PYTHONPATH', "%s:%s" % (os.getenv('PYTHONPATH', ''), ':'.join(python_path))) # for subprocesses
26+"""
27
28 import accomplishments_viewer
29 accomplishments_viewer.main()

Subscribers

People subscribed via source and target branches

to all changes: