Personal tools
     DOCUMENTATION

Conary:Python App Template

From rPath Wiki

Jump to: navigation, search
Conary --> Packaging --> Recipe --> Recipe Templates --> Python App Template

Conary packagers can write a package recipe to package a Python application. This type of recipe inherits directly from the PackageRecipe class.

Use the following template to start the recipe, and make the changes suggested:

 
class MyApp(PackageRecipe):
    name = 'myapp'
    version = '1.0'
 
    buildRequires = [ 'python-setuptools:python' ]
 
    def setup(r):
        r.addArchive('http://www.example.com/sample/')
        r.PythonSetup()

Suggested changes:

  • Change the class name to a CamelCase representation of the application name
  • Change the value for name to the application name as packaged
  • Change the value for version to the application version
  • After cooking (with cvc) or building (with rMake), add items to the buildRequires section as instructed by the build messages (see Conary Recipe Structure for more information)
  • Change the URL to reflect the location of the application

If the application requires the use of the Python site-packages directory, adjust the recipe template as shown to load python.recipe and to set two macros:

 
loadInstalled('python.recipe')
class MyApp(PackageRecipe):
    # class variables as in the previous template
    def setup(r):
        r.macros.pyver = Python.majversion
        r.macros.sitepkgs = '%(libdir)s/python%(pyver)s/site-packages'
        # actions as in the previous template

After this modification, use %(sitepkgs)s as needed in the recipe's policy actions. Note that %(libdir)s on a 64-bit platform will be correct only if there is architecture-specific code in the Python library of the package.

Troubleshooting Note: The following error may appear when the package is cooked:

error: option --single-version-externally-managed not recognized

This error indicates that the PythonSetup build action is not appropriate for the recipe. In such a case, replace the PythonSetup line with r.Run('./setup.py --<options>') where <options> are any package-specific options that should be passed. The following two lines work in many cases:

 
        r.Run('python setup.py build')
        r.Run('python setup.py install --root=%(destdir)s')



From here you may wish to:

Participate in the rPath Community | Contribute to rPath Wiki | Report an issue to rPath