summaryrefslogtreecommitdiff
path: root/dh_python
diff options
context:
space:
mode:
Diffstat (limited to 'dh_python')
-rwxr-xr-xdh_python42
1 files changed, 38 insertions, 4 deletions
diff --git a/dh_python b/dh_python
index 8b248ff..952a77d 100755
--- a/dh_python
+++ b/dh_python
@@ -27,7 +27,8 @@ specific python version. The dependency will be substituted into your
package's control file wherever you place the token "${python:Depends}".
If some modules need to be byte-compiled at install time, appropriate
-postinst and prerm scripts will be generated.
+postinst and prerm scripts will be generated. If already byte-compiled
+modules are found, they are removed.
If you use this program, your package should build-depend on python.
@@ -43,6 +44,9 @@ command line. By default, it will check /usr/lib/site-python,
/usr/lib/$PACKAGE, /usr/share/$PACKAGE, /usr/lib/games/$PACKAGE,
/usr/share/games/$PACKAGE and /usr/lib/python?.?/site-packages.
+Note: only /usr/lib/site-python, /usr/lib/python?.?/site-packages and the
+extra names on the command line are searched for binary (.so) modules.
+
=item B<-V> I<version>
If the .py files your package ships are meant to be used by a specific
@@ -107,6 +111,8 @@ foreach (@ARGV) {
use constant PROGRAM => 1;
use constant PY_MODULE => 2;
use constant PY_MODULE_NONSTANDARD => 4;
+use constant SO_MODULE => 8;
+use constant SO_MODULE_NONSTANDARD => 16;
foreach my $package (@{$dh{DOPACKAGES}}) {
my $tmp = tmpdir($package);
@@ -114,6 +120,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
delsubstvar($package, "python:Depends");
my @dirs = ("usr/lib/site-python", "usr/lib/$package", "usr/share/$package", "usr/lib/games/$package", "usr/share/games/$package", @ARGV );
+ my @dirs_so = ("usr/lib/site-python", @ARGV );
my $dep_on_python = 0;
my $strong_dep = 0;
@@ -130,11 +137,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
}
else {
push @dirs, "usr/lib/python$python_version/site-packages" ;
+ push @dirs_so, "usr/lib/python$python_version/site-packages" ;
$look_for_pythonXY = 0;
}
}
@dirs = grep -d, map "$tmp/$_", @dirs;
+ @dirs_so = grep -d, map "$tmp/$_", @dirs_so;
my $deps = 0;
my %verdeps = ();
@@ -165,7 +174,10 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
$curdir =~ s%^$tmp/%%;
find sub {
return unless -f;
- $has_module = 1 if /\.py$/;
+ if (/\.py$/) {
+ $has_module = 1;
+ doit(("rm","-f",$_."c",$_."o"));
+ }
}, "$tmp/$curdir" ;
if ($has_module) {
if ($dh{V_FLAG_SET}) {
@@ -177,10 +189,28 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
}
}
}
+ if (@dirs_so) {
+ foreach my $curdir (@dirs_so) {
+ my $has_module = 0;
+ $curdir =~ s%^$tmp/%%;
+ find sub {
+ return unless -f;
+ $has_module = 1 if /\.so$/;
+ }, "$tmp/$curdir" ;
+ if ($has_module) {
+ if ($dh{V_FLAG_SET}) {
+ $verdeps{$usepython} |= SO_MODULE_NONSTANDARD;
+ }
+ else {
+ $deps |= SO_MODULE;
+ }
+ }
+ }
+ }
# Dependencies on current python
$dep_on_python = 1 if $deps;
- $strong_dep = 1 if($deps & PY_MODULE);
+ $strong_dep = 1 if($deps & (PY_MODULE|SO_MODULE));
if ($dep_on_python) {
addsubstvar($package, "python:Depends", $python, ">= $python_version");
@@ -200,7 +230,11 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
if (grep -d,"$tmp$pydir") {
find sub {
return unless -f;
- $verdeps{$pyver} |= PY_MODULE if /\.py$/;
+ if (/\.py$/) {
+ $verdeps{$pyver} |= PY_MODULE;
+ doit(("rm","-f",$_."c",$_."o"));
+ }
+ $verdeps{$pyver} |= SO_MODULE if /\.so$/;
}, "$tmp$pydir";
}
}