From ce234d53a5b8d829eca4f27857e6ea2625575fe8 Mon Sep 17 00:00:00 2001 From: deronnax Date: Wed, 25 Mar 2015 18:21:34 +0100 Subject: [PATCH 1/2] shorter and faster version extraction from __init__.py --- setup.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 4637291f..67ca2eed 100755 --- a/setup.py +++ b/setup.py @@ -30,12 +30,8 @@ requires = [] version = '' with open('requests/__init__.py', 'r') as fd: - reg = re.compile(r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]') - for line in fd: - m = reg.match(line) - if m: - version = m.group(1) - break + version = re.search(r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read()).group(1) if not version: raise RuntimeError('Cannot find version information') From 1145fe64a54d5d1f813b96bf2923aff954267554 Mon Sep 17 00:00:00 2001 From: deronnax Date: Thu, 26 Mar 2015 15:53:19 +0100 Subject: [PATCH 2/2] matching the version only at the begining of lines --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 67ca2eed..f98f5281 100755 --- a/setup.py +++ b/setup.py @@ -30,8 +30,8 @@ requires = [] version = '' with open('requests/__init__.py', 'r') as fd: - version = re.search(r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read()).group(1) + version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) if not version: raise RuntimeError('Cannot find version information')