#!/usr/bin/env python
import urllib2, re, glob, shutil

dlpage = urllib2.urlopen("http://sourceforge.net/projects/numpy/files/NumPy/")
versions = re.findall(r'''/projects/numpy/files/NumPy/([0-9.]+)/''', dlpage.read())

versions.sort(key=lambda x: map(int, x.split(".")) )
version = versions[-1]

newBuildFile = "numpy-" + version + ".build"
buildFile, = glob.glob("numpy-*.build")

if buildFile != newBuildFile:
    print "mv {old} {new}".format(old=buildFile, new=newBuildFile)
    shutil.move(buildFile, newBuildFile)
