aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/upload_docs.py
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/command/upload_docs.py')
-rw-r--r--setuptools/command/upload_docs.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py
index e961a0df..213f7b58 100644
--- a/setuptools/command/upload_docs.py
+++ b/setuptools/command/upload_docs.py
@@ -12,10 +12,17 @@ import httplib
import base64
import urlparse
import tempfile
+import sys
from distutils import log
from distutils.errors import DistutilsOptionError
-from distutils.command.upload import upload
+
+try:
+ from distutils.command.upload import upload
+except ImportError:
+ from setuptools.command.upload import upload
+
+_IS_PYTHON3 = sys.version > '3'
try:
bytes
@@ -89,10 +96,10 @@ class upload_docs(upload):
}
# set up the authentication
credentials = self.username + ':' + self.password
- try: # base64 only works with bytes in Python 3.
+ if _IS_PYTHON3: # base64 only works with bytes in Python 3.
encoded_creds = base64.encodebytes(credentials.encode('utf8'))
- auth = b"Basic "
- except AttributeError:
+ auth = bytes("Basic ")
+ else:
encoded_creds = base64.encodestring(credentials)
auth = "Basic "
auth += encoded_creds.strip()