You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by qu...@apache.org on 2017/12/16 14:29:14 UTC
[3/4] libcloud git commit: Finish removing support for Python 2.5/3.2
Finish removing support for Python 2.5/3.2
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/2224ec79
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/2224ec79
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/2224ec79
Branch: refs/heads/trunk
Commit: 2224ec797e1a6dae197b30eaa27cb04f2391f60c
Parents: 74c1db8
Author: Quentin Pradet <qu...@apache.org>
Authored: Sat Dec 16 11:41:45 2017 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Sat Dec 16 18:28:05 2017 +0400
----------------------------------------------------------------------
docs/testing.rst | 7 ++---
libcloud/common/base.py | 11 ++------
libcloud/test/common/test_openstack.py | 11 ++------
libcloud/utils/py3.py | 41 +++--------------------------
setup.py | 11 +++-----
5 files changed, 14 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/2224ec79/docs/testing.rst
----------------------------------------------------------------------
diff --git a/docs/testing.rst b/docs/testing.rst
index 3a8511d..26461d5 100644
--- a/docs/testing.rst
+++ b/docs/testing.rst
@@ -34,10 +34,7 @@ To run the tests on all the supported Python versions run the following command:
.. sourcecode:: bash
- sudo tox
-
-You need to run this command as a root user, because Python 2.5 depends on ssl
-module and you need root permissions to install it.
+ tox
Running Tests Manually
----------------------
@@ -81,7 +78,7 @@ contains the test coverage.
Running tests inside a Docker container
---------------------------------------
-To run the tests on all the supported Python versions (minus Python 2.5), run
+To run the tests on all the supported Python versions, run
the following command:
.. sourcecode:: bash
http://git-wip-us.apache.org/repos/asf/libcloud/blob/2224ec79/libcloud/common/base.py
----------------------------------------------------------------------
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index fbcdd92..24fdbdb 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import json
import os
import sys
import ssl
@@ -23,16 +24,10 @@ import time
from libcloud.utils.py3 import ET
-try:
- import simplejson as json
-except:
- import json
-
import requests
import libcloud
-from libcloud.utils.py3 import PY25
from libcloud.utils.py3 import httplib
from libcloud.utils.py3 import urlparse
from libcloud.utils.py3 import urlencode
@@ -439,9 +434,7 @@ class Connection(object):
if not hasattr(kwargs, 'cert_file') and hasattr(self, 'cert_file'):
kwargs.update({'cert_file': getattr(self, 'cert_file')})
- # Timeout is only supported in Python 2.6 and later
- # http://docs.python.org/library/httplib.html#httplib.HTTPConnection
- if self.timeout and not PY25:
+ if self.timeout:
kwargs.update({'timeout': self.timeout})
if self.proxy_url:
http://git-wip-us.apache.org/repos/asf/libcloud/blob/2224ec79/libcloud/test/common/test_openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/common/test_openstack.py b/libcloud/test/common/test_openstack.py
index b5e9341..4f5420b 100644
--- a/libcloud/test/common/test_openstack.py
+++ b/libcloud/test/common/test_openstack.py
@@ -19,7 +19,6 @@ import unittest
from mock import Mock
from libcloud.common.base import LibcloudConnection
from libcloud.common.openstack import OpenStackBaseConnection
-from libcloud.utils.py3 import PY25
class OpenStackBaseConnectionTest(unittest.TestCase):
@@ -38,14 +37,8 @@ class OpenStackBaseConnectionTest(unittest.TestCase):
def test_base_connection_timeout(self):
self.connection.connect()
self.assertEqual(self.connection.timeout, self.timeout)
- if PY25:
- self.connection.conn_class.assert_called_with(host='127.0.0.1',
- port=443)
- else:
- self.connection.conn_class.assert_called_with(host='127.0.0.1',
- secure=1,
- port=443,
- timeout=10)
+ self.connection.conn_class.assert_called_with(
+ host='127.0.0.1', secure=1, port=443, timeout=10)
if __name__ == '__main__':
http://git-wip-us.apache.org/repos/asf/libcloud/blob/2224ec79/libcloud/utils/py3.py
----------------------------------------------------------------------
diff --git a/libcloud/utils/py3.py b/libcloud/utils/py3.py
index 9b7a866..645ffc7 100644
--- a/libcloud/utils/py3.py
+++ b/libcloud/utils/py3.py
@@ -37,14 +37,10 @@ except ImportError:
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
-PY2_pre_25 = PY2 and sys.version_info < (2, 5)
-PY2_pre_26 = PY2 and sys.version_info < (2, 6)
PY2_pre_27 = PY2 and sys.version_info < (2, 7)
PY2_pre_279 = PY2 and sys.version_info < (2, 7, 9)
-PY3_pre_32 = PY3 and sys.version_info < (3, 2)
PY2 = False
-PY25 = False
PY26 = False
PY27 = False
PY3 = False
@@ -53,9 +49,6 @@ PY32 = False
if sys.version_info >= (2, 0) and sys.version_info < (3, 0):
PY2 = True
-if sys.version_info >= (2, 5) and sys.version_info < (2, 6):
- PY25 = True
-
if sys.version_info >= (2, 6) and sys.version_info < (2, 7):
PY26 = True
@@ -68,7 +61,7 @@ if sys.version_info >= (3, 0):
if sys.version_info >= (3, 2) and sys.version_info < (3, 3):
PY32 = True
-if PY2_pre_279 or PY3_pre_32:
+if PY2_pre_279:
try:
from backports.ssl_match_hostname import match_hostname, CertificateError # NOQA
except ImportError:
@@ -157,17 +150,10 @@ else:
from __builtin__ import reload # NOQA
- if PY25:
- import cgi
-
- parse_qs = cgi.parse_qs
- parse_qsl = cgi.parse_qsl
- else:
- parse_qs = urlparse.parse_qs
- parse_qsl = urlparse.parse_qsl
+ parse_qs = urlparse.parse_qs
+ parse_qsl = urlparse.parse_qsl
- if not PY25:
- from os.path import relpath # NOQA
+ from os.path import relpath # NOQA
# Save the real value of unicode because urlquote needs it to tell the
# difference between a unicode string and a byte string.
@@ -212,25 +198,6 @@ else:
# s needs to be a string.
return [x.encode("hex") for x in s]
-if PY25:
- import posixpath
-
- # Taken from http://jimmyg.org/work/code/barenecessities/index.html
- # (MIT license)
- # pylint: disable=function-redefined
- def relpath(path, start=posixpath.curdir): # NOQA
- """Return a relative version of a path"""
- if not path:
- raise ValueError("no path specified")
- start_list = posixpath.abspath(start).split(posixpath.sep)
- path_list = posixpath.abspath(path).split(posixpath.sep)
- # Work out how much of the filepath is shared by start and path.
- i = len(posixpath.commonprefix([start_list, path_list]))
- rel_list = [posixpath.pardir] * (len(start_list) - i) + path_list[i:]
- if not rel_list:
- return posixpath.curdir
- return posixpath.join(*rel_list)
-
if PY27 or PY3:
unittest2_required = False
else:
http://git-wip-us.apache.org/repos/asf/libcloud/blob/2224ec79/setup.py
----------------------------------------------------------------------
diff --git a/setup.py b/setup.py
index f9be490..b58ff9f 100644
--- a/setup.py
+++ b/setup.py
@@ -36,11 +36,10 @@ libcloud.utils.SHOW_DEPRECATION_WARNING = False
# installed / available
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
-PY2_pre_25 = PY2 and sys.version_info < (2, 5)
+PY3_pre_34 = PY3 and sys.version_info < (3, 4)
PY2_pre_26 = PY2 and sys.version_info < (2, 6)
PY2_pre_27 = PY2 and sys.version_info < (2, 7)
PY2_pre_279 = PY2 and sys.version_info < (2, 7, 9)
-PY3_pre_32 = PY3 and sys.version_info < (3, 2)
HTML_VIEWSOURCE_BASE = 'https://svn.apache.org/viewvc/libcloud/trunk'
PROJECT_BASE_DIR = 'http://libcloud.apache.org'
@@ -64,7 +63,7 @@ TEST_REQUIREMENTS = [
'pytest-runner'
]
-if PY2_pre_279 or PY3_pre_32:
+if PY2_pre_279:
TEST_REQUIREMENTS.append('backports.ssl_match_hostname')
if PY2_pre_27:
@@ -72,7 +71,7 @@ if PY2_pre_27:
else:
unittest2_required = False
-if PY2_pre_25:
+if PY2_pre_26 or PY3_pre_34:
version = '.'.join([str(x) for x in sys.version_info[:3]])
print('Version ' + version + ' is not supported. Supported versions are ' +
', '.join(SUPPORTED_VERSIONS))
@@ -127,10 +126,8 @@ class ApiDocsCommand(Command):
forbid_publish()
install_requires = ['requests']
-if PY2_pre_26:
- install_requires.extend(['ssl', 'simplejson'])
-if PY2_pre_279 or PY3_pre_32:
+if PY2_pre_279:
install_requires.append('backports.ssl_match_hostname')
setup(