From 3e32356716572e59c9f10c6c2622bedf5f48b07e Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 25 May 2017 11:31:38 -0400 Subject: [PATCH 1/6] __version__.py --- requests/__init__.py | 8 +------- requests/__version__.py | 13 +++++++++++++ setup.py | 14 ++++++-------- 3 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 requests/__version__.py diff --git a/requests/__init__.py b/requests/__init__.py index 7f6c480f..2bcba252 100644 --- a/requests/__init__.py +++ b/requests/__init__.py @@ -40,13 +40,7 @@ is at . :license: Apache 2.0, see LICENSE for more details. """ -__title__ = 'requests' -__version__ = '2.14.2' -__build__ = 0x021402 -__author__ = 'Kenneth Reitz' -__license__ = 'Apache 2.0' -__copyright__ = 'Copyright 2017 Kenneth Reitz' -__cake__ = u'✨ 🍰 ✨ Thanks for using my software. It means the world to me. --kennethreitz' +from .__version__ import * # Attempt to enable urllib3's SNI support, if possible try: diff --git a/requests/__version__.py b/requests/__version__.py new file mode 100644 index 00000000..7b09e44e --- /dev/null +++ b/requests/__version__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +# .-. .-. .-. . . .-. .-. .-. .-. +# |( |- |.| | | |- `-. | `-. +# ' ' `-' `-`.`-' `-' `-' ' `-' + +__title__ = 'requests' +__version__ = '2.14.2' +__build__ = 0x021402 +__author__ = 'Kenneth Reitz' +__license__ = 'Apache 2.0' +__copyright__ = 'Copyright 2017 Kenneth Reitz' +__cake__ = u'✨ 🍰 ✨ Thanks for using my software. It means the world to me. --kennethreitz' \ No newline at end of file diff --git a/setup.py b/setup.py index b9588ebd..5e1b6788 100755 --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ from codecs import open from setuptools import setup from setuptools.command.test import test as TestCommand +here = os.path.abspath(os.path.dirname(__file__)) class PyTest(TestCommand): user_options = [('pytest-args=', 'a', "Arguments to pass into py.test")] @@ -28,7 +29,7 @@ class PyTest(TestCommand): errno = pytest.main(self.pytest_args) sys.exit(errno) - +# 'setup.py publish' shortcut. if sys.argv[-1] == 'publish': os.system('python setup.py sdist upload') sys.exit() @@ -51,12 +52,9 @@ packages = [ requires = [] test_requirements = ['pytest>=2.8.0', 'pytest-httpbin==0.0.7', 'pytest-cov', 'pytest-mock'] -with open('requests/__init__.py', 'r', 'utf-8') as fd: - version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError('Cannot find version information') +about = {} +with open(os.path.join(here, "requests", "__version__.py")) as f: + exec(f.read(), about) with open('README.rst', 'r', 'utf-8') as f: readme = f.read() @@ -65,7 +63,7 @@ with open('HISTORY.rst', 'r', 'utf-8') as f: setup( name='requests', - version=version, + version=about['__version__'], description='Python HTTP for Humans.', long_description=readme + '\n\n' + history, author='Kenneth Reitz', From e634ab73b27f111a1e280f6553a63620293340fa Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 25 May 2017 11:33:04 -0400 Subject: [PATCH 2/6] better '' --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5e1b6788..fdc33fce 100755 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ requires = [] test_requirements = ['pytest>=2.8.0', 'pytest-httpbin==0.0.7', 'pytest-cov', 'pytest-mock'] about = {} -with open(os.path.join(here, "requests", "__version__.py")) as f: +with open(os.path.join(here, 'requests', '__version__.py')) as f: exec(f.read(), about) with open('README.rst', 'r', 'utf-8') as f: From 9fbfd22f6b6bf0075619e2181e66d557511b14d8 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 25 May 2017 11:46:00 -0400 Subject: [PATCH 3/6] take a page out of @sigmavirus42's book --- requests/__version__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requests/__version__.py b/requests/__version__.py index 7b09e44e..9abded42 100644 --- a/requests/__version__.py +++ b/requests/__version__.py @@ -5,9 +5,12 @@ # ' ' `-' `-`.`-' `-' `-' ' `-' __title__ = 'requests' +__description__ = 'Python HTTP for Humans.' +__url__ = 'http://python-requests.org' __version__ = '2.14.2' __build__ = 0x021402 __author__ = 'Kenneth Reitz' +__author_email__ = 'me@kennethreitz.org' __license__ = 'Apache 2.0' __copyright__ = 'Copyright 2017 Kenneth Reitz' __cake__ = u'✨ 🍰 ✨ Thanks for using my software. It means the world to me. --kennethreitz' \ No newline at end of file From 7abfd92aeaeba82e1c527460b539667844fbb557 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 25 May 2017 11:46:12 -0400 Subject: [PATCH 4/6] take a page out of @sigmavirus42's book --- setup.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index fdc33fce..534b23aa 100755 --- a/setup.py +++ b/setup.py @@ -62,19 +62,19 @@ with open('HISTORY.rst', 'r', 'utf-8') as f: history = f.read() setup( - name='requests', + name=about['__title__'], version=about['__version__'], - description='Python HTTP for Humans.', + description=about['__description__'], long_description=readme + '\n\n' + history, - author='Kenneth Reitz', - author_email='me@kennethreitz.com', - url='http://python-requests.org', + author=about['__author__'], + author_email=about['__author_email__'], + url=about['__url__'], packages=packages, package_data={'': ['LICENSE', 'NOTICE'], 'requests': ['*.pem']}, package_dir={'requests': 'requests'}, include_package_data=True, install_requires=requires, - license='Apache 2.0', + license=about['__license__'], zip_safe=False, classifiers=( 'Development Status :: 5 - Production/Stable', From ce882a2eae4eaffc4e4f31d9b5917701f714b619 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 25 May 2017 19:07:48 -0400 Subject: [PATCH 5/6] fix rtd --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 9b135d31..674f198e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,7 @@ sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0, os.path.abspath('_themes')) import requests -from requests import __version__ +from requests.__version__ import __version__ # -- General configuration ------------------------------------------------ From e038aad3ccbd5526346150bd37c8c8a8ee0a0b9b Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Thu, 25 May 2017 18:44:30 -0500 Subject: [PATCH 6/6] Avoid breaking people using requests.__version__ Using __version__ as a module breaks users who expect requests.__version__ to be the version string. --- docs/conf.py | 2 +- requests/{__version__.py => __about__.py} | 0 requests/__init__.py | 2 +- setup.py | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename requests/{__version__.py => __about__.py} (100%) diff --git a/docs/conf.py b/docs/conf.py index 674f198e..9b135d31 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,7 @@ sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0, os.path.abspath('_themes')) import requests -from requests.__version__ import __version__ +from requests import __version__ # -- General configuration ------------------------------------------------ diff --git a/requests/__version__.py b/requests/__about__.py similarity index 100% rename from requests/__version__.py rename to requests/__about__.py diff --git a/requests/__init__.py b/requests/__init__.py index 2bcba252..4d3055c8 100644 --- a/requests/__init__.py +++ b/requests/__init__.py @@ -40,7 +40,7 @@ is at . :license: Apache 2.0, see LICENSE for more details. """ -from .__version__ import * +from .__about__ import * # Attempt to enable urllib3's SNI support, if possible try: diff --git a/setup.py b/setup.py index 534b23aa..fd8a1716 100755 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ requires = [] test_requirements = ['pytest>=2.8.0', 'pytest-httpbin==0.0.7', 'pytest-cov', 'pytest-mock'] about = {} -with open(os.path.join(here, 'requests', '__version__.py')) as f: +with open(os.path.join(here, 'requests', '__about__.py')) as f: exec(f.read(), about) with open('README.rst', 'r', 'utf-8') as f: