From 41f42be6cca147b56aa6c253bf0d4e6c8214d914 Mon Sep 17 00:00:00 2001 From: Hugh Saunders Date: Wed, 21 Sep 2016 11:02:50 +0100 Subject: [PATCH] Filter pre_release versions of packages Get-pypi-pkg-version should not return pre release versions. This comit filters them out with a simple regex. Change-Id: I3919fc1a9872250acc100e751f4b78cc857b3348 --- scripts/get-pypi-pkg-version.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/get-pypi-pkg-version.py b/scripts/get-pypi-pkg-version.py index 33d9d6eda7..a1a9131e76 100755 --- a/scripts/get-pypi-pkg-version.py +++ b/scripts/get-pypi-pkg-version.py @@ -24,12 +24,16 @@ from __future__ import print_function import argparse +import re import xmlrpclib +PRE_RELEASE_RE = re.compile('a|b|rc') + def get_package_version(pypiConn, pkg_name): """Get the current package version from PyPI.""" - pkg_result = pypiConn.package_releases(pkg_name) + pkg_result = [v for v in pypiConn.package_releases(pkg_name, True) + if not PRE_RELEASE_RE.search(v)] if pkg_result: pkg_version = pkg_result[0] else: