Use this section if you want your package to start with Python source code. Because Conary is also built in Python, the tools needed to build your Python application into a Conary package are part of Conary's most basic recipe class, PackageRecipe.
Use the following template to start your recipe for packaging your Python application, taking advantage of Conary's Python setup tools:
# RECIPE TEMPLATE
# Package an application written in Python
class ExampleApp(PackageRecipe):
name = 'example'
version = '1.0'
buildRequires = [ 'python-setuptools:python' ]
def setup(r):
r.addArchive('http://www.example.com/%(name)s/%(name)s-%(version)s.tar.bz2')
r.PythonSetup()
Replace the class name, package name, version, and archive location as appropriate for your package. Each source or archive you add can be just a file name (if you're checking in those files with the recipe), a network-accessible location as shown in the template example, or a version control checkout action from among Conary's source actions.
The Python packaging template does not have a separate superclass adding recipe actions for you to use. Instead, you add python-setuptools:python to your build requirements so your build environment can run the PythonSetup recipe action.
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 important macros:
# RECIPE TEMPLATE
# Package an application written in Python that requires site-packages
loadInstalled('python')
class ExampleApp(PackageRecipe):
name = 'example'
version = '1.0'
buildRequires = [ 'python-setuptools:python' ]
def setup(r):
r.macros.pyver = Python.majversion
r.macros.sitepkgs = '%(libdir)s/python%(pyver)s/site-packages'
r.addArchive('http://www.example.com/%(name)s/%(name)s-%(version)s.tar.bz2')
r.PythonSetup()
Again, replace the as appropriate for your package. Also, though, you can use the macro %(sitepkgs)s as appropriate in your recipe 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 your package.
The following error might possibly occur when you build your package:
error: option --single-version-externally-managed not recognized
This error indicates that your PythonSetup build action will not work for your recipe. If this happens, replace the PythonSetup action with r.Run('./setup.py --<options>') where <options> are any package-specific options you need to pass to the Python setup. The following two lines work in many cases:
r.Run('python setup.py build')
r.Run('python setup.py install --root=%(destdir)s')