#!/usr/bin/python

'''
Check if debian/versions is sane and generate substvars for numpy:Provides.
'''

import os

def main():
    os.chdir(os.path.join(os.path.dirname(__file__), '..'))
    data = {}
    file = open('numpy/core/setup_common.py', 'r')
    try:
        exec(file.read(), data)
    finally:
        file.close()
    file = open('debian/versions', 'r')
    try:
        for line in file:
            line = line.strip()
            if not line or line.startswith('#'):
                continue
            key, value = line.split(None, 1)
            data[key] = value
    finally:
        file.close()
    assert data['abi'] == str(data['C_ABI_VERSION'] - 0x1000000), 'Is debian/versions up-to-date?'
    assert data['api'] == str(data['C_API_VERSION']), 'Is debian/versions up-to-date?'
    print 'numpy:Provides=python-numpy-abi%s, python-numpy-api%s' % (data['abi'], data['api'])

if __name__ == '__main__':
    main()
