From: Ian Cordasco Date: Sat, 14 Mar 2015 02:47:29 +0000 (-0500) Subject: Parse version number out of requests/__init__.py X-Git-Tag: v2.6.0~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1acc4992d42950b54a7be1b0dcacdaac35d32436;p=services%2Fpython-requests.git Parse version number out of requests/__init__.py With the new import machinery in requests/packages/__init__.py people using `python setup.py test` will not be able to run the tests the first time on a new environment. The VendorAlias logic breaks the import machinery and the tests fail. By removing the import of requests in setup.py, we avoid the issue where sys.meta_path continues to have the version of VendorAlias from the import in setup.py. Closes #2462 --- diff --git a/setup.py b/setup.py index 813fc87..4637291 100755 --- a/setup.py +++ b/setup.py @@ -1,10 +1,9 @@ #!/usr/bin/env python import os +import re import sys -import requests - from codecs import open try: @@ -29,6 +28,18 @@ packages = [ 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 + +if not version: + raise RuntimeError('Cannot find version information') + with open('README.rst', 'r', 'utf-8') as f: readme = f.read() with open('HISTORY.rst', 'r', 'utf-8') as f: @@ -36,7 +47,7 @@ with open('HISTORY.rst', 'r', 'utf-8') as f: setup( name='requests', - version=requests.__version__, + version=version, description='Python HTTP for Humans.', long_description=readme + '\n\n' + history, author='Kenneth Reitz', @@ -60,7 +71,6 @@ setup( 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4' - ), extras_require={ 'security': ['pyOpenSSL', 'ndg-httpsclient', 'pyasn1'],