#!/usr/bin/env python
import re
try:
    from urllib.request import urlopen
except ImportError:
    from urllib2 import urlopen


urldir = u"https://www.kernel.org/pub/software/scm/git/"
filespec = u"git-{version}.tar.xz"

dlpage = urlopen(urldir).read().decode("utf-8")
versions = re.findall(filespec.format(version=u"([0-9][0-9.]*[0-9])"), dlpage)

versions.sort(key=lambda v: [int(n) for n in v.split(u".")])
version = versions[-1]

url = urldir + filespec.format(version=version)

print(url)
