From b731ffd0ca8d83259369a1af8f9955a528d2f8d2 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 7 Nov 2014 09:50:11 -0700 Subject: [PATCH] make setup.py run on python3 --- setup.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 4ff23624368..18ce1b0521b 100755 --- a/setup.py +++ b/setup.py @@ -4,6 +4,8 @@ The setup script for salt ''' +from __future__ import absolute_import + # pylint: disable=C0111,E1101,E1103,F0401,W0611,W0201,W0232,R0201,R0902,R0903 # For Python 2.5. A no-op on 2.6 and above. @@ -12,7 +14,10 @@ from __future__ import print_function, with_statement import os import sys import glob -import urllib2 +try: + from urllib2 import urlopen +except ImportError: + from urllib.request import urlopen from datetime import datetime # pylint: disable=E0611 import distutils.dist @@ -270,7 +275,7 @@ class CloudSdist(Sdist): ) ) except ImportError: - req = urllib2.urlopen(url) + req = urlopen(url) if req.getcode() == 200: script_contents = req.read() @@ -489,7 +494,7 @@ class InstallLib(install_lib): chmod.append(idx) for idx in chmod: filename = out[idx] - os.chmod(filename, 0755) + os.chmod(filename, 0o755) # <---- Custom Distutils/Setuptools Commands -------------------------------------------------------------------------