]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/python_distutils.pm
Modular object-orientied buildsystem implementation (try 2).
[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         if (grep(/^\Q$action\E$/, qw{build install clean})) {
24                 return -e "setup.py";
25         }
26         return 0;
27 }
28
29 sub setup_py {
30         my $self=shift;
31         my $act=shift;
32
33         if ($self->get_builddir()) {
34                 unshift @_, "--build-base=" . $self->get_builddir();
35         }
36         doit("python", "setup.py", $act, @_);
37 }
38
39 sub build {
40         my $self=shift;
41         $self->setup_py("build", @_);
42 }
43
44 sub install {
45         my $self=shift;
46         my $destdir=shift;
47         $self->setup_py("install", "--root=$destdir", "--no-compile", "-O0", @_);
48 }
49
50 sub clean {
51         my $self=shift;
52         $self->setup_py("clean", "-a", @_);
53         # The setup.py might import files, leading to python creating pyc
54         # files.
55         doit('find', '.', '-name', '*.pyc', '-exec', 'rm', '{}', ';');
56 }
57
58 1;