To build Python packages, use the python_package class. This class works for packages that are built on some variation of

setup.py build
setup.py install --prefix=<install_dir>

The minimal build class for a Python package abc is:

class abc_package(python_package):
    def init(self):
        super(abc_package, self).init()

There are two basic ways of customizing the build class: setting properties, and defining helper methods.

Customizing the build by changing python_package properties

The first is to set one of the following properties (shown with default values) to something different in the init method:

ldflags = 'LDFLAGS=-L%s/lib' % self.absolute_python_dir
self.build_command = '%s %s setup.py build --verbose' % (ldflags, self.python)
self.build_options = ''
self.install_command = '%s %s setup.py install --prefix=%s' % (ldflags, self.python, self.absolute_install_dir)
self.install_options = ''
  • If you need to add to the build command, set self.build_options to contain the additional options.
  • If you need to change the build command to something else, or prepend a string (such as the setting of an environment variable), then modify or replace self.build_command.
  • If you want to skip the build step, set self.build_command to None.
  • The same rules apply to self.install_command.

Customizing the build by overriding python_package methods

If you need to perform other actions in the build,, then you can override the following method.. By default this method is defined to do nothing.

    def after_extract(self):
        pass
  • No labels