1- """Stuff that isn't in some old versions of Python """
1+ """Stuff that differs in different Python versions"""
22
33import sys
44import os
99try :
1010 WindowsError = WindowsError
1111except NameError :
12- WindowsError = None
12+ class NeverUsedException (Exception ):
13+ """this exception should never be raised"""
14+ WindowsError = NeverUsedException
1315try :
1416 from hashlib import md5
1517except ImportError :
2022 from pkgutil import walk_packages
2123except ImportError :
2224 # let's fall back as long as we can
23- from _pkgutil import walk_packages
25+ from pip . _pkgutil import walk_packages
2426
2527try :
2628 any = any
@@ -32,6 +34,56 @@ def any(seq):
3234 return True
3335 return False
3436
37+ if sys .version_info >= (3 ,):
38+ from io import StringIO
39+ from functools import reduce
40+ from urllib .error import URLError , HTTPError
41+ from queue import Queue , Empty
42+ from urllib .request import url2pathname
43+ from urllib .request import urlretrieve
44+ from email import message as emailmessage
45+ import urllib .parse as urllib
46+ import urllib .request as urllib2
47+ import configparser as ConfigParser
48+ import xmlrpc .client as xmlrpclib
49+ import urllib .parse as urlparse
50+ import http .client as httplib
51+ def cmp (a , b ):
52+ return (a > b ) - (a < b )
53+ def b (s ):
54+ return s .encode ('utf-8' )
55+ def u (s ):
56+ return s .decode ('utf-8' )
57+ string_types = (str ,)
58+ raw_input = input
59+ else :
60+ from cStringIO import StringIO
61+ from urllib2 import URLError , HTTPError
62+ from Queue import Queue , Empty
63+ from urllib import url2pathname , urlretrieve
64+ from email import Message as emailmessage
65+ import urllib
66+ import urllib2
67+ import urlparse
68+ import ConfigParser
69+ import xmlrpclib
70+ import httplib
71+ def b (s ):
72+ return s
73+ def u (s ):
74+ return s
75+ string_types = (basestring ,)
76+ reduce = reduce
77+ cmp = cmp
78+ raw_input = raw_input
79+
80+ try :
81+ from email .parser import FeedParser
82+ except ImportError :
83+ # python lesser than 2.5
84+ from email .FeedParser import FeedParser
85+
86+ from distutils .sysconfig import get_python_lib , get_python_version
3587
3688def copytree (src , dst ):
3789 if sys .version_info < (2 , 5 ):
@@ -47,7 +99,7 @@ def copytree(src, dst):
4799def product (* args , ** kwds ):
48100 # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
49101 # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111
50- pools = map (tuple , args ) * kwds .get ('repeat' , 1 )
102+ pools = list ( map (tuple , args ) ) * kwds .get ('repeat' , 1 )
51103 result = [[]]
52104 for pool in pools :
53105 result = [x + [y ] for x in result for y in pool ]
0 commit comments