I know you are asking for cv2.resize only, but you could use the imutils library which does some of the ratio code for you.
import imutils
resized = imutils.resize(img, width=newwidth)
Inside imutils:
dim = None
(h, w) = image.shape[:2]
# check to see if the width is None
if width is None:
# calculate the ratio of the height and construct the
# dimensions
r = height / float(h)
dim = (int(w * r), height)
# otherwise, the height is None
else:
# calculate the ratio of the width and construct the
# dimensions
r = width / float(w)
dim = (width, int(h * r))
# resize the image
resized = cv2.resize(image, dim, interpolation=inter)