{"id":170,"date":"2011-06-10T15:45:34","date_gmt":"2011-06-10T19:45:34","guid":{"rendered":"http:\/\/www.samontab.com\/web\/?p=170"},"modified":"2011-06-10T15:45:34","modified_gmt":"2011-06-10T19:45:34","slug":"create-installable-applications-sis-files-from-your-python-scripts-for-symbian","status":"publish","type":"post","link":"https:\/\/www.samontab.com\/web\/2011\/06\/create-installable-applications-sis-files-from-your-python-scripts-for-symbian\/","title":{"rendered":"Create installable applications (.sis files) from your Python scripts for Symbian"},"content":{"rendered":"<p>Python is great. It makes everything simple. Also, it can be run almost anywhere, even on your Nokia smartphones. In this post I will show you how to create an installable application (.sis file) from your Python scripts.<\/p>\n<p>The first step is to install Python 2.5 on your computer. It <strong>has<\/strong> to be <strong>2.5<\/strong>. If you have a newer version of Python installed, either downgrade to 2.5 or create a local folder with Python 2.5 executable on it and make sure you use that version. You can install Python 2.5 from <a title=\"Python 2.5\" href=\"http:\/\/www.python.org\/download\/releases\/2.5.4\/\">here<\/a>.<\/p>\n<p>If you are on Ubuntu, probably you have a newer version of Python. Just get the source and compile it locally:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncd ~\r\nmkdir py2sis\r\ncd py2sis\r\nwget http:\/\/www.python.org\/ftp\/python\/2.5.4\/Python-2.5.4.tgz\r\ntar -xvzf Python-2.5.4.tgz\r\nrm Python-2.5.4.tgz\r\ncd Python-2.5.4\r\n.\/configure\r\nmake\r\n<\/pre>\n<p>OK, so now we should have a local copy of Python 2.5.4. To test that everything is fine, run the following command:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n~\/py2sis\/Python-2.5.4\/python --version\r\n<\/pre>\n<p>It should report <strong>Python 2.5.4<\/strong>. Windows or Linux users that installed Python 2.5.4 on their entire system can always substitute <strong>~\/py2sis\/Python-2.5.4\/python<\/strong> by just <strong>python<\/strong>. For them, the following command should report the same result:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\npython --version\r\n <\/pre>\n<p>Now, we need to get the utilities that will allow us to create the sis files. That software is called <a title=\"ensymble\" href=\"http:\/\/code.google.com\/p\/ensymble\/\">ensymble<\/a>. We need exactly this file: <a title=\"ensymble_python2.5-0.27.py\" href=\"http:\/\/ensymble.googlecode.com\/files\/ensymble_python2.5-0.27.py\">ensymble_python2.5-0.27.py<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n cd ~\/py2sis\r\nwget http:\/\/ensymble.googlecode.com\/files\/ensymble_python2.5-0.27.py\r\n~\/py2sis\/Python-2.5.4\/python ~\/py2sis\/ensymble_python2.5-0.27.py version\r\n <\/pre>\n<p>You should get this result: <strong>Ensymble v0.27 2008-06-30<\/strong>.<\/p>\n<p>Now let&#8217;s get <a title=\"Python For S60\" href=\"http:\/\/sourceforge.net\/projects\/pys60\/\">PythonForS60<\/a> sis file that will be installed alongside your script. We need the file PythonForS60_1_4_5_3rdEd.sis.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncd ~\/py2sis\r\nwget http:\/\/sourceforge.net\/projects\/pys60\/files\/pys60\/1.4.5\/PythonForS60_1_4_5_3rdEd.sis\/download\r\nmv download PythonForS60_1_4_5_3rdEd.sis\r\n<\/pre>\n<p>All done configuring the tools. Now we are going to create a Python script.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncd ~\r\nmkdir myFirstScript\r\ncd myFirstScript\r\ngedit default.py &amp;\r\n<\/pre>\n<p>Here you can put any Python code for Symbian S60. Let&#8217;s start with something simple. Write this and save the file:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nimport appuifw\r\nappuifw.note(u&quot;Hello Symbian\/Python World&quot;, &quot;info&quot;)\r\n<\/pre>\n<p>Time to create your first Python SIS file. Execute the following:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncd ~\r\n~\/py2sis\/Python-2.5.4\/python ~\/py2sis\/ensymble_python2.5-0.27.py py2sis myFirstScript\r\n<\/pre>\n<p>It should generate a file called <strong>myFirstScript_v1_0_0.sis<\/strong>. This is the sis file for your script. If you already have PythonForS60 sis installed in your phone, it should work. Most of the time though, users will not have it, so let&#8217;s merge the two into just one sis:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncd ~\r\n~\/py2sis\/Python-2.5.4\/python ~\/py2sis\/ensymble_python2.5-0.27.py mergesis myFirstScript_v1_0_0.sis ~\/py2sis\/PythonForS60_1_4_5_3rdEd.sis myFirstScript_v1_0_0_with_Python.sis\r\n<\/pre>\n<p>Now, you can just install <strong>myFirstScript_v1_0_0_with_Python.sis<\/strong> in your Nokia Symbian S60 3rd edition phone (like the E71 for example) and when you open it, you should see something like this:<\/p>\n<p><a href=\"http:\/\/www.samontab.com\/web\/wp-content\/uploads\/2011\/06\/helloSymbianPython.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-171\" title=\"helloSymbianPython\" src=\"http:\/\/www.samontab.com\/web\/wp-content\/uploads\/2011\/06\/helloSymbianPython.jpg\" alt=\"\" width=\"320\" height=\"240\" srcset=\"https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2011\/06\/helloSymbianPython.jpg 320w, https:\/\/www.samontab.com\/web\/wp-content\/uploads\/2011\/06\/helloSymbianPython-300x225.jpg 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><\/p>\n<p>Great, so now let&#8217;s automate this using a script:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo touch \/usr\/local\/bin\/py2sis.sh\r\nsudo chmod +x \/usr\/local\/bin\/py2sis.sh\r\nsudo gedit \/usr\/local\/bin\/py2sis.sh &amp;\r\n<\/pre>\n<p>Write these commands on the file:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n#!\/bin\/bash\r\necho &quot;Creating script sis file...&quot;\r\n~\/py2sis\/Python-2.5.4\/python ~\/py2sis\/ensymble_python2.5-0.27.py py2sis myFirstScript\r\necho &quot;Merging script sis file with Python for S60 sis file...&quot;\r\n~\/py2sis\/Python-2.5.4\/python ~\/py2sis\/ensymble_python2.5-0.27.py mergesis myFirstScript_v1_0_0.sis ~\/py2sis\/PythonForS60_1_4_5_3rdEd.sis myFirstScript_v1_0_0_with_Python.sis\r\necho &quot;Done.&quot;\r\n<\/pre>\n<p>Now let&#8217;s test it erasing the files we just created and then generating them with the script:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncd ~\r\nrm myFirstScript_v1_0_0*\r\npy2sis.sh\r\n<\/pre>\n<p>It should create the same 2 sis files we just created before manually. Now, let&#8217;s edit the script so that we can tell it where is our source code and set other options:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo gedit \/usr\/local\/bin\/py2sis.sh &amp;\r\n<\/pre>\n<p>Replace the existing code with this:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n#!\/bin\/bash\r\n\r\n#Check that only 1 parameter is passed (the directory of your script)\r\nEXPECTED_ARGS=1\r\nif &#x5B; $# -ne $EXPECTED_ARGS ]\r\nthen\r\necho &quot;Usage: `basename $0` &#x5B;ScriptDirectory]&quot;\r\nexit -1\r\nfi\r\n\r\n#This is the directory where your Python for S60 Script is\r\nPYTHON_SCRIPT_DIR=$1\r\n\r\n#Application parameters\r\nAPP_SCRIPT_SIS_NAME=&quot;myApp.sis&quot;\r\nAPP_SCRIPT_WITH_PYTHON_SIS_NAME=&quot;myApp_with_python.sis&quot;\r\nAPP_NAME=&quot;My App&quot;\r\nAPP_VERSION=&quot;1.0.0&quot;\r\nAPP_SHORT_CAPTION=&quot;Short description.&quot;\r\nAPP_CAPTION=&quot;Here you can describe your application in more detail.&quot;\r\n#Icon path. It should be a Tiny SVG compatible icon.\r\n#To add an app icon, just uncomment the following line and edit the path to point to your icon\r\n#APP_ICON=--icon=&quot;\/path\/to\/your\/icon.svg&quot;\r\n\r\n#Environment variables\r\nPYTHON_PATH=~\/py2sis\/Python-2.5.4\/python\r\nENSYMBLE_PATH=~\/py2sis\/ensymble_python2.5-0.27.py\r\nPYTHON_FOR_S60_PATH=~\/py2sis\/PythonForS60_1_4_5_3rdEd.sis\r\n\r\necho &quot;Creating script sis file...&quot;\r\n&quot;${PYTHON_PATH}&quot; &quot;${ENSYMBLE_PATH}&quot; py2sis --appname=&quot;${APP_NAME}&quot; --version=&quot;${APP_VERSION}&quot; --shortcaption=&quot;${APP_SHORT_CAPTION}&quot; --caption=&quot;${APP_CAPTION}&quot; ${APP_ICON} &quot;${PYTHON_SCRIPT_DIR}&quot; &quot;${APP_SCRIPT_SIS_NAME}&quot;\r\necho &quot;Merging script sis file with Python for S60 sis file...&quot;\r\n${PYTHON_PATH} ${ENSYMBLE_PATH} mergesis ${APP_SIS_NAME} ${PYTHON_FOR_S60_PATH} ${APP_SCRIPT_WITH_PYTHON_SIS_NAME}\r\necho &quot;Done.&quot;\r\n\r\n<\/pre>\n<p>There you can set many parameters for your app, like the name, icon, description, and more. Now you should be able to convert your Python scripts to a sis file by just doing this:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\npy2sis.sh ScriptDirectory\r\n<\/pre>\n<p>Remember to name the main script <strong>default.py<\/strong> since that is the file that ensymble is looking for inside the script folder.<\/p>\n<p>Let&#8217;s test this new script, erasing the sis files and then executing this script to generate new sis files:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncd ~\r\nrm myFirstScript_v1_0_0*\r\npy2sis.sh myFirstScript\r\n<\/pre>\n<p>You should see now a <strong>myApp.sis<\/strong> and a <strong>myApp_with_python.sis<\/strong> files. Note that those were the properties set in the script. Anytime you want to change these settings, just run this and edit them directly:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo gedit \/usr\/local\/bin\/py2sis.sh &amp;\r\n<\/pre>\n<p>OK, now go and create some cool Python apps in no time for your Nokia phone. Check out this <a title=\"Python for S60 tutorial\" href=\"http:\/\/mobilenin.com\/pys60\/menu.htm\">excellent Symbian for S60 tutorial<\/a> made by a fellow Nokia Forum Champion, Jurgen Scheible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python is great. It makes everything simple. Also, it can be run almost anywhere, even on your Nokia smartphones. In this post I will show you how to create an installable application (.sis file) from your Python scripts. The first step is to install Python 2.5 on your computer. It has to be 2.5. If [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-170","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts\/170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/comments?post=170"}],"version-history":[{"count":0,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/posts\/170\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/media?parent=170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/categories?post=170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.samontab.com\/web\/wp-json\/wp\/v2\/tags?post=170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}