Pippy allows the student to examine, execute, and modify simple Python programs. In addition it is possible to write Python statements to play sounds, calculate expressions, or make simple text based interactive games.
We are wasting our time changing file names and imports to avoid system packages. It is a never-ending task, and impossible to avoid future conflict. There is an underlying problem; the import path resolution for a Sugar activity is wrong.
An interactive Python session or Python script run from a command line do not show a conflict; the local module or file is used rather than the system package. Something is different between the normal Python environment and the environment of an activity within Sugar.
We are wasting our time changing file names and imports to avoid system packages. It is a never-ending task, and impossible to avoid future conflict. There is an underlying problem; the import path resolution for a Sugar activity is wrong.
An interactive Python session or Python script run from a command line do not show a conflict; the local module or file is used rather than the system package. Something is different between the normal Python environment and the environment of an activity within Sugar.
Other examples where we have been doing this are;
import espeak
https://github.com/sugarlabs/speak/commit/86cfd1bcff150cee1c705e151253c63bfb483e5aimport player
https://github.com/sugarlabs/jukebox-activity/commit/c913a7b0803c25febc6787e63e7392bd52ca2094import player
https://github.com/sugarlabs/maze-activity/commit/776b61fde7b53ca352081c47136b7e6e5476a911So can we instead investigate and fix the underlying problem in Sugar or the toolkit?
Here is
sys.path
at the start of theActivity.__init__
method:Here is
sys.path
in an interactive Python shell started from the Terminal activity bash prompt;Comparing them we get;
Why is the first element of sys.path changed from
''
to/usr/bin
? Is it because we now call every activity through/usr/bin/sugar-activity
?Why is the activity directory added to the end of
sys.path
, and not the beginning? See line 117 ofbin/sugar-activity
Would it be more correct for
sugar-activity
to replace/usr/bin/
with the bundle path rather than add the bundle path to the end?