View Full Version : .deb from python source

November 25th, 2006, 11:52 AM
i have a python source.
my question is : could I obtain a .deb package from it with all dependencies satisfied?

thanks for reply

November 25th, 2006, 11:08 PM
I didn't understand you:
you want to build a .deb from your python source? or you want a .deb for python already built?

November 25th, 2006, 11:15 PM
i'v got a python source with setup.py to install it but i would like to create a .deb ,is it possibile?

November 26th, 2006, 01:04 AM
Sorry to bother you with questions but you want to create a .deb for example to share it or you want it just because you want that the package manager take care of its installing in your machine?

You already have python in the repos in .deb but I assume you need another version than the one in the repos. Intalling it from source it's not hard (I did it last week in a redhat without problems, although this machine has no previous python version).

If it's just a one time need you better do it from source since learning how to build packages is a subject in itself: See http://linuxdevices.com/articles/AT8047723203.html

But maybe it can get easy with CheckInstall: https://help.ubuntu.com/community/CheckInstall
Somebody recommend it to me in the past but I have no experience with it.

November 26th, 2006, 01:52 AM
Thanks for you reply.
So, i've just installed the program with python setup.py and everything is ok. I only need .deb package to share it but checkinstall doesn't run i guess.
I need a program like this :
but doesn't run on my edgy :(


November 27th, 2006, 11:35 PM
Here's a tutorial for building a .deb for a python app.
It's for the maemo platform, but works great for Linux.

November 28th, 2006, 12:30 AM
thanks! i've tried. i arrive to make debian directory but i don't understand how modify rules file ....](*,)

November 29th, 2006, 02:02 AM
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))

configure: configure-stamp
# Add here commands to configure the package.

touch configure-stamp

build: build-stamp

build-stamp: configure-stamp

# Add here commands to compile the package.
#docbook-to-man debian/obliqueness.sgml > obliqueness.1

touch build-stamp

rm -f build-stamp configure-stamp

# Add here commands to clean up after the build process.
-$(MAKE) clean


install: build
dh_clean -k

# Add here commands to install the package into debian/obliqueness.
$(MAKE) install DESTDIR=$(CURDIR)/debian/obliqueness

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
# dh_install
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
# dh_installinfo
# dh_perl
# dh_python
# dh_makeshlibs

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

This is a rules file from a small python app I've made. Basically you don't have to do anything to it. The tutorial says to take the stuff out from the binary-arch and put it under the binary-indep, if you want to make it architecture independent. If you want to do that just put all the stuff that's not commented out under it binary-arch under binary-indep, that should do it. (I didn't bother myself.)
This may help:
Debian maintainers guide is a very good resource, if you can slog through it.

January 9th, 2009, 11:28 PM
It looks like checkinstall can work with python installations, but when I try it doesn't really work. It says it works, but when I remove the package, it doesn't really remove the egg.

I have seen "checkinstall python setup.py install" on the web. I'm not sure if it really works. I have not seen anyone using "checkinstall easy_install something", and when I tried it, it didn't seem to work. Then again, I'm not sure which of these I should be using:

checkinstall easy_install something
sudo checkinstall easy_install something
checkinstall sudo easy_install something
sudo checkinstall sudo easy_install something

Some of these don't work, others create a package, but it doesn't seem to work.

There's also http://easy-deb.sourceforge.net/

Suppose you want to package the "graph" module. It is available on pypi (http://easy-deb.sourceforge.net/www.python.org/pypi), so, to get the sources and create a debian source archive, you type:

$ easy-deb -v2.4 -d python-pypi-delegate -D /tmp graph
$ easy-deb -v2.4 -D /tmp delegate

The above commands will create source packages of graph and delegate for python2.4 . The graph package will depend on the delegate package.

$ cd /tmp/deb-pkg-graph-0.4/python-pypi-graph-0.4 && debuild
$ cd /tmp/deb-pkg-delegate-0.1/python-pypi-delegate-0.1 && debuild

Now to install the packages type:

$ sudo dpkg -i/tmp/deb-pkg-graph-0.4/python-pypi-graph-0.4/*.deb
$ sudo dpkg -i/tmp/deb-pkg-delegate-0.1/python-pypi-delegate-0.1/*.deb

Darwin Award Winner
April 9th, 2010, 10:40 PM
There's also stdeb, which adds a setup.py command bdist_deb which you can use to build a deb file as easily as an rpm or tarball.

Just install stdeb, and add the following to ~/.pydistutils.cfg so that distutils will know about stdeb:

command-packages: stdeb.command

Then, in your python source dir, type the following:

python setup.py bdist_deb

Read the rest of the documentation for even easier ways to use stdeb. It can download python sources and build them and install them automatically for you.