]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/python_distutils.pm
code review, added 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 Debian::Debhelper::Dh_Buildsystem_Bases;
13 use base 'Debian::Debhelper::Dh_Buildsystem_Option';
14
15 sub DESCRIPTION {
16         "support for building Python distutils based packages"
17 }
18
19 sub is_buildable {
20         return -e "setup.py";
21 }
22
23 sub get_builddir_option {
24         my $self=shift;
25         if ($self->get_builddir()) {
26                 return "--build-base=". $self->get_builddir();
27         }
28         return;
29 }
30
31 # XXX JEH the default for all these methods is to do nothing successfully.
32 # So either this, or those default stubs, need to be removed.
33 sub configure_impl {
34         # Do nothing
35         1;
36 }
37
38 sub build_impl {
39         my $self=shift;
40         doit("python", "setup.py", "build", @_);
41 }
42
43 # XXX JEH see anove comment
44 sub test_impl {
45         1;
46 }
47
48 sub install_impl {
49         my $self=shift;
50         my $destdir=shift;
51
52         doit("python", "setup.py", "install", 
53              "--root=$destdir",
54              "--no-compile", "-O0", @_);
55 }
56
57 sub clean_impl {
58         my $self=shift;
59         doit("python", "setup.py", "clean", "-a", @_);
60         # The setup.py might import files, leading to python creating pyc
61         # files.
62         doit('find', '.', '-name', '*.pyc', '-exec', 'rm', '{}', ';');
63 }
64
65 1;