[Sugar-devel] [PATCH sugar-toolkit] Insert activity root path in front of the reset of sys.path

Aleksey Lim alsroot at activitycentral.org
Sat Feb 12 18:57:40 EST 2011


On Sat, Feb 12, 2011 at 02:47:32PM -0500, Martin Langhoff wrote:
> On Sat, Feb 12, 2011 at 1:57 PM, Sascha Silbe <silbe at activitycentral.com> wrote:
> >> The behaviour sought by Aleksey's patch makes sense. I am surprised
> >> that CWD isn't set to SUGAR_BUNDLE_PATH, maybe that needs to get fixed
> >> instead.
> >
> > Thanks for disproving my assumption that it's something Python 2.x does
> > differently and pointing at the actual issue.
> >
> > I agree that we should either change the working directory or tweak
> > sys.path, but I'm still a bit worried about compatibility.
> 
> Hm. AFAICS, when an activity starts under S-0.84 the cwd is set
> correctly. I've been debugging an activity that starts from a shell
> script (as activities using libsugarize are prone to do) and the
> script assumes (correctly) that CWD is the activity directory.
> 
> So I am intrigued about Aleksey's patch. Aleksey -- did you prep your
> patch in response to an observed behaviour? What was it? Maybe the
> problem was misdiagnosed?

The problem is, if I got it right, that cwd means nothing for searching
modules, only sys.path(and so) makes sense. After launching Python
interpreter, the $0 becomes sys.path[0]. But the problem is that
activities start from sugar-activity command, thus sys.path[0] is
/usr/bin/. So, there is need in adding SUGAR_BUNDLE_PATH to the sys.path
manually (ie simulate Python interpreter behaviour). But existed code
does it wrong (add to the end of sys.path).

> 
> cheers,
> 
> 
> m
> -- 
>  martin.langhoff at gmail.com
>  martin at laptop.org -- Software Architect - OLPC
>  - ask interesting questions
>  - don't get distracted with shiny stuff  - working code first
>  - http://wiki.laptop.org/go/User:Martinlanghoff
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
> 

-- 
Aleksey


More information about the Sugar-devel mailing list