Python Example: A Package Wrapper

There are occasions where you cannot add GPT files to source code that needs to be packages. To solve this it possible to wrap a GPT package around the software. As an example of this, we have a python module called ola_mundo version 0.1 which needs to be wrapped. As shown in the following directory listing, the top level directory of a package wrapper consists of the GPT files plus the source distribution as a subdirectory:

drwxr-xr-x    2 mbletzin mbletzin     4.0k May 16 12:01 CVS
-rw-r--r--    1 mbletzin mbletzin      106 May 16 11:33 filelist
drwxr-xr-x    5 mbletzin mbletzin     4.0k May 16 12:01 ola_mundo-0.1
-rw-r--r--    1 mbletzin mbletzin      530 May 16 11:38 pkg_data_src.gpt

All of the files can be seen here. The filelist has the same content as it would for a normal package. The package data file has a new attribute in the Build_Instructions element called SrcDir which points to the source distribution:


    <src_pkg>

    <Version_Label>0.1</Version_Label>

    <Build_Instructions SrcDir="ola_mundo-0.1">

      <Build_Step>python setup.py install --prefix=INSTALLDIR_GPTMACRO</Build_Step>

    </Build_Instructions>

    </src_pkg>


A Version_Label element has also been added to the packaging data. This allows the version of the source to be displayed to the user even though it does not follow the GPT package version scheme. When the source is updated the version number, version label, and source directory needs to be edited also.

Running gpt-build and then gpt-query in this directory shows how the package is built in the source subdirectory and how the package and software versions are displayed to the user.

bash$ gpt-build
gpt-build ====> CHECKING BUILD DEPENDENCIES FOR ola_mando
gpt-build ====> Changing to /home/mbletzin/nmi/gpt-docs/examples/ola_mundo_pnb/ola_mundo-0.1
gpt-build ====> BUILDING FLAVOR 
gpt-build ====> Changing to /home/mbletzin/install/globus/etc
gpt-build ====> REMOVING empty package ola_mando-noflavor-dev
gpt-build ====> REMOVING empty package ola_mando-noflavor-rtl
bash$ gpt-query
4 packages were found in /home/mbletzin/install/globus that matched your query:

packages found that matched your query 
	guten_tag_welt-noflavor-pgm pkg version: 0.0.0
	hello_world-noflavor-pgm pkg version: 0.1.0
	hello_world_c-noflavor-pgm pkg version: 0.0.0
	ola_mando-noflavor-pgm pkg version: 0.0.0 software version: 0.1

As with all of the other examples, this python example was used to demonstrate the language independence of GPT. However to keep things simple, we have not spend a lot of time on python portability issues. For example, as can be seen from the filelist, the python modules are installed in a versioned python directory. How this works if the end user installs this package on a platform with python version 1.6 is left as an exercise :).