#!/usr/bin/perl -w

use strict;
use File::Find;
use Debian::Debhelper::Dh_Lib;

init();

my $numpy_next_version;
my $numpy_version = `python -c 'from numpy import __version__; print __version__'`;
if (! defined $numpy_version || $numpy_version eq "")
{
    error("Numpy is not installed, aborting. (Probably forgot to Build-Depend on python-numpy.)");
}
elsif ($numpy_version =~ m/^(\d+)[.](\d+)([.]\d+)*/)
{
    $numpy_version = sprintf("%d.%d", $1, $2);
    $numpy_next_version = sprintf("%d.%d", $1, $2 + 1);
}
else
{
    error("Unable to parse Numpy version out of \"$numpy_version\".");
}

foreach my $package (@{$dh{DOPACKAGES}})
{
    addsubstvar($package, "python:Depends",
        "python-numpy (>= 1:$numpy_version), " .
        "python-numpy (<< 1:$numpy_next_version)"
    );
}

# vim:ts=4 sw=4 et
