]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/python_distutils.pm
more comments
[debhelper.git] / Debian / Debhelper / Buildsystem / python_distutils.pm
1 # A buildsystem plugin for building Python Distutils based
2 # projects.
3 #
4 # Copyright: © 2008 Joey Hess
5 #            © 2008-2009 Modestas Vainius
6 # License: GPL-2+
7
8 package Debian::Debhelper::Buildsystem::python_distutils;
9
10 use strict;
11 use Debian::Debhelper::Dh_Lib;
12 use base 'Debian::Debhelper::Dh_Buildsystem_Basic';
13
14 sub DESCRIPTION {
15         "support for building Python distutils based packages"
16 }
17
18 sub is_auto_buildable {
19         my $self=shift;
20         my $action=shift;
21
22         # Handle build install clean; the rest - next class
23         # XXX JEH shouldn't it also handle configure? It would be handled
24         # by doing nothing, but that's what's appropriate for python.
25         if (grep(/^\Q$action\E$/, qw{build install clean})) {
26                 return -e "setup.py";
27         }
28         return 0;
29 }
30
31 sub setup_py {
32         my $self=shift;
33         my $act=shift;
34
35         if ($self->get_builddir()) {
36                 unshift @_, "--build-base=" . $self->get_builddir();
37         }
38         doit("python", "setup.py", $act, @_);
39 }
40
41 sub build {
42         my $self=shift;
43         $self->setup_py("build", @_);
44 }
45
46 sub install {
47         my $self=shift;
48         my $destdir=shift;
49         $self->setup_py("install", "--root=$destdir", "--no-compile", "-O0", @_);
50 }
51
52 sub clean {
53         my $self=shift;
54         $self->setup_py("clean", "-a", @_);
55         # The setup.py might import files, leading to python creating pyc
56         # files.
57         doit('find', '.', '-name', '*.pyc', '-exec', 'rm', '{}', ';');
58 }
59
60 1;