def computeMD5(filepath, relativepath = ""):
	'''Computes an MD5 checksum.
		Depending on the file size, we either run the computation in Python or spawn a subprocess.
		The implementation is slower in Python than the tested OS but there is an overhead associated with the spawning.
		On my one-machine test (CentOS release 5.4 final on the webserver), @2MB was where the times converged.
		'''
	filename = os.path.basename(filepath)
	checksum = None
	
	sz = os.path.getsize(filepath)
	if sz < 2 * 1024 * 1024:
		checksum = md5.new()
		F = open(filepath, 'rb')
		while True:
			bytes = F.read(65536)
			if len(bytes) == 0:
				break # end of file
			checksum.update(bytes)
		checksum = checksum.hexdigest()
		
	else:
		p = subprocess.Popen(["md5sum", filepath], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
		stdoutdata, stderrdata = p.communicate()
		if stderrdata:
			raise Exception(stderrdata)
		stdoutdata = stdoutdata.split()
		checksum = stdoutdata[0]
		filename = os.path.basename(stdoutdata[1])

	return "%s  %s" % (checksum, os.path.join(relativepath, filename))