From: Guido Günther Date: Wed, 28 Apr 2021 07:03:28 +0000 (+0200) Subject: setup.py: Avoid dpkg-parsechangelog X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35d91d5f1dbdeadb49aca1d91184b45aeb43a1b8;p=tools%2Fgit-buildpackage.git setup.py: Avoid dpkg-parsechangelog This helps on non-debian systems --- diff --git a/setup.py b/setup.py index fc99c5a9..962bf14c 100755 --- a/setup.py +++ b/setup.py @@ -18,20 +18,20 @@ # END OF COPYRIGHT # import os +import re from setuptools import setup, find_packages -import subprocess VERSION_PY_PATH = 'gbp/version.py' def _parse_changelog(): """Get version from debian changelog and write it to gbp/version.py""" - popen = subprocess.Popen('dpkg-parsechangelog', stdout=subprocess.PIPE) - out, ret = popen.communicate() - for line in out.decode('utf-8').split('\n'): - if line.startswith('Version:'): - version = line.split(' ')[1].strip() - return version + with open("debian/changelog") as f: + line = f.readline() + + m = re.match(".* \\(([0-9.]+)\\) ", line) + if m: + return m.group(1) raise ValueError('Could not parse version from debian/changelog')