7. Module Repository

Introduction

Starting with PyS60 1.9.x series, the Python core is upgraded to 2.5.4. With this, PyS60 1.9.x is loaded with much more core Python modules than the previous PyS60 releases that were based on Python 2.2.2 core. This also means that the size of the runtime SIS file increases by many folds. Bigger runtime SIS means longer time to download it and also longer time to install it on to a device. This also results in slowing down the interpreter load time.

The following were the main ideas behind this packaging tool:

These have been achieved in PyS60 1.9.x by:

Module repository (hereafter module-repo) is the name given to the directory structure where all the Python modules are placed. This can be extended by the users by adding their own modules in it. This also includes information required to package all the Python modules on which a given Python script is dependent on. This module-repo is installed on the host machine along with the PyS60 Application Packager.

Note: The following codecs related modules _codecs_cn, _codecs_hk, _codecs_jp, _codecs_kr and _codecs_tw are not packaged automatically. If the application depends on any of them, then they can be packaged by explicitly specifying them using the -extra-modules option of ensymble. (Use 'Additional options' field in the GUI)

Extending Module-repo

Developers can extend the module-repo by adding the new modules that they develop or receive from other extension developers. Module-repo can be extended by the steps mentioned below:

    {'type': 'repo',  'deps': ["socket", "btsocket", "my_mod1"]}

Directory structure on the PC

<PythonForS60>\
                module-repo\
                        standard-modules\
                            ...
                        dev-modules\
                            module_search_path.cfg
                            mod1\
                                module_config.cfg
                                mod1.py
                            mod2\
                                module_config.cfg
                                kf_mod2.pyd
                            mod3\
                                module_config.cfg
                                mod3\
                                    __init__.py
                                    mod3_run.py
                            mod4\
                                module_config.cfg
                                kf_mod4core.pyd
                                kf_mod4base.pyd
                                mod4\
                                    __init__.py
                                    mod4_wrapper.py

Distributing extension modules to application developers

Distributing extension modules to application developers is much easier now with the PyS60 application packager scanning for dependencies automatically. The extension module developers should create a zip/rar/tar archive of their module directory in the format mentioned above so that the application developers can directly extract it to the dev-modules folder. After this the application developers just need to use PyS60 application packager to package their script. The application packager will automatically scan the dependencies and package the dev-modules the script is dependent on.

Module search path

A module when being included in the application package, is first searched in the paths specified in the configuration file - module_search_path.cfg unless it is distributed by PyS60( e.g. : messaging, contacts, sysinfo etc.). If it is not found in these locations, then it searches for this module in the module-repo.

The paths in the config file are in a list(['path1', 'path2']). This feature is useful in the scenario when the Python modules (especially the extension modules - PYD files) are not present in the module-repo. The developer can just specify the path to be searched for the modules, instead of copying them to the module-repo.

For example, if the developer is developing an extension module, he can specify the path to $\backslash$epoc32$\backslash$release$\backslash$armv5$\backslash$urel in the module search path and the module is automatically picked up while packaging. Without this option, the developer needs to copy the module to module-repo every time he compiles the code.

Directory structure on a device

The application SIS will contain all its dependencies packaged along with it. All the py files except default.py are zipped into lib.zip and placed in the application's private directory. A white-list.cfg is maintained which contains entries for all the PYDs packaged with the application which will be used by PyS60's import mechanism.

The files are placed on a device as shown below:

!:\
    private\
        [app-UID]\
            white-list.cfg [List of PYDs packaged with the app]
            default.py [application script]
            lib.zip [standard, dev and application py files]

        resource\
            python25\
                core-modules [PY files compiled and zipped - placed by base runtime]

        sys\
            bin\
                core-modules [PYDs - placed by base runtime]
                repo-modules [standard-pyd and dev-pyd files, renamed with application's UID]

Include additional modules

A new option is added to PyS60 application packager which can be used to include additional modules with the application. If the application packager does not include a module needed by the application automatically, then the user can use the --extra-modules option to forcefully include additional modules with the application.

See About this document... for information on suggesting changes.