[beginner] How to build a python package?

I have the specfile (see below) and I have tar/gzipped sources for my library. The sources just contain a directory with four Python files inside.

osc build fails with this error:

    4s] + ./configure --host=x86_64-suse-linux-gnu --build=x86_64-suse-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/lib --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking    4s] /var/tmp/rpm-tmp.QzoXlX: line 34: ./configure: No such file or directory
    4s] error: Bad exit status from /var/tmp/rpm-tmp.QzoXlX (%build)

I don’t have any configure script, nor a Makefile. In fact I don’t have a clue what to put there - and where to put these as I don’t think these things should be part of the source.

Can you point me where I can learn about that? I didn’t find anything relevant here:
openSUSE:Build Service Tutorial - openSUSE

Here’s my specfile:

# spec file for package
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
Name:           python-fastjsonrpc                                                                                                                                                                
Version:        1.0                                                                                                                                                                               
Release:        2                                                                                                                                                                                 
License:        Apache Licence, version 2.0                                                                                                                                                       
Summary:        JSON-RPC client and server for Twisted                                                                                                                                            
Url:            https://github.com/tadeas/fastjsonrpc                                                                                                                                             
Group:          Development/Libraries/Python                                                                                                                                                      
Source:         %{name}-%{version}.tar.gz                                                                                                                                                         
PreReq:         python-Twisted                                                                                                                                                                    
Provides:       python-fastjsonrpc                                                                                                                                                                
BuildRoot:      %{_tmppath}/%{name}-%{version}-build                                                                                                                                              

A library for writing asynchronous JSON-RPC servers and clients in
Python, using Twisted. It aims to be as simple and easy to understand (and
hack) as possible.

%setup -q

make %{?_smp_mflags}






You need to create and add a setup.py file to install the files, build
an egg info file etc.

Have a look here for the spec file to use;

Have a look here for an example setup.py;

Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 12.2 (x86_64) Kernel 3.4.11-2.16-desktop
up 21:52, 4 users, load average: 0.26, 0.20, 0.16
CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU

or you can just copy them to %{buildroot}%{python_sitelib} in %install section.

leave the %build empty. manually copy them to the place python lib should goes into (you may have to make directories first).

it’s pretty easy in specfile, like:

mkdir %{buildroot}%{python_sitelib}/%{name}
mv * %{buildroot}%{python_sitelib}/%{name}

just like working in a shell. while with a few macros.

you can find meanings of those macros in Portal:Packaging, Packaging_Python and on your own system:

sudo zypper in python-devel

/usr/lib/rpm/suse_macros and /etc/rpm/macros.python should contain all the macros you will meet in python packaging.

Yes that’s an option, but using setup.py creates the egg info.

Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 12.2 (x86_64) Kernel 3.4.11-2.16-desktop
up 23:33, 4 users, load average: 0.11, 0.10, 0.07
CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU

Thank you for your replies! And I’m sorry for the delay, I had a lot of work lately.
Anyway, I don’t understand how comes that I didn’t find the Packaging Python guide ( openSUSE:Packaging Python - openSUSE ). Reading that solve all my problems :wink: .

Thank you again!