Using the SuSE OBS to package your python module

This is a crash course (or tutorial) in how to get started using OpenSUSE Build Server OBS and packaging your first python module so you can target a python interpreter.

In the OBS server each user can have:

If you are already familiar with OBS and you wanted just a .spec file generator, simply use it from: Pyquality spec file creator.

Requirements

To be follow this tutorial you need:

  1. an account on OBS
  2. the Osc command line client

Configuration

Filling the following information will update the tutorial in order to provide a cut'n copy step by step instructions.

The OBS account
the one you just acquired on the OBS server
The new project name
a project name for your modules
home::
The new package name
The module name possibly with a version
home:::
The desired opt-python interpreter
the python tag to build against the module

Workflow

Although the following steps can be done using the web base interface, we focus in using the cli interface here.

First time

Create a new project
osc meta prj -e home::

You need the relevant fileds in the xml configuration file and the build targets against which the build will be performed (see build targes).

Select the desired python intepreters to use (as many as you need):
osc linkpac home:cavallo71:opt-python-interpreters \
    opt-python home::

You could use any of the current python builds from the main page.

For each package

Create the package within the project:
osc meta pkg -e home:: \
    

Again you need to set the xml fields to match your requirements.

Creating a local working copy

The Osc command line client has a syntax similar to subversion: developer used to it shouldn't have problems in using it. The workflow follows the usual scheme: check out the working copy of a project, go to the package directory, add/edit/delete the files then commit the changes: the OBS server will perform the build on the committed files.

What follows is using a simple test module that builds on almost all the rpm based platforms: this is a possible good starting point in packaging your module.

  1. Check out a local copy for your project:
    osc co home::
  2. Enter the local working copy for you module:
    cd "home::/"
  3. Add the files to the Package either:

    • grabbing a ready made example module tar file + .spec file:
      curl -LO "http://cclimited.webfactional.com/data/pyquality/pyquality.spec"
      curl -LO "http://cclimited.webfactional.com/data/pyquality/pyquality.tar.bz2"
      curl -LO "http://cclimited.webfactional.com/data/pyquality/ident2.sh"
    • if you have a tar file and you just need a spec file for it you can make use of: Pyquality spec file creator).

    Either way you should have a .spec file + one or more source files in your working dir.

  4. Fix the opt-python line in the .spec file
    perl -p -i -e \
      's/opt-python-svn12345/opt-python/g' pyquality.spec
  5. Add the files (if you've used the ready made example)
    osc add pyquality.spec pyquality.tar.bz2 ident2.sh
  6. Commit the changes
    osc commit

    Enter a commit message

  7. Et voila! If the build goes well the results should be under:

    http://download.opensuse.org/repositories/home:/:/