From a33bf5baca961a2b13d330fb905de11802fbc50b Mon Sep 17 00:00:00 2001 From: Steven Hiscocks Date: Tue, 9 Apr 2013 19:40:54 +0100 Subject: [PATCH] ENH: setup.py now automatically runs 2to3 for python3.x --- setup.py | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/setup.py b/setup.py index 784999a2..8aca6852 100755 --- a/setup.py +++ b/setup.py @@ -23,9 +23,18 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" from distutils.core import setup +try: + # python 3.x + from distutils.command.build_py import build_py_2to3 as build_py + from distutils.command.build_scripts \ + import build_scripts_2to3 as build_scripts +except ImportError: + # python 2.x + from distutils.command.build_py import build_py + from distutils.command.build_scripts import build_scripts from common.version import version from os.path import isfile, join, isdir -from sys import argv +import sys from glob import glob longdesc = ''' @@ -45,6 +54,7 @@ setup( url = "http://www.fail2ban.org", license = "GPL", platforms = "Posix", + cmdclass = {'build_py': build_py, 'build_scripts': build_scripts}, scripts = [ 'fail2ban-client', 'fail2ban-server', @@ -100,25 +110,26 @@ for directory in elements: obsoleteFiles.append(path) if obsoleteFiles: - print - print "Obsolete files from previous Fail2Ban versions were found on " \ - "your system." - print "Please delete them:" - print + sys.stdout.write("\n") + sys.stdout.write("Obsolete files from previous Fail2Ban versions " \ + "were found on your system.\n") + sys.stdout.write("Please delete them:\n") + sys.stdout.write("\n") for f in obsoleteFiles: - print "\t" + f - print + sys.stdout.write("\t" + f) + sys.stdout.write("\n") if isdir("/usr/lib/fail2ban"): - print - print "Fail2ban is not installed under /usr/lib anymore. The new " \ - "location is under /usr/share. Please remove the directory " \ - "/usr/lib/fail2ban and everything under this directory." - print + sys.stdout.write("\n") + sys.stdout.write("Fail2ban is not installed under /usr/lib anymore. " \ + "The new location is under /usr/share. Please remove the " \ + "directory /usr/lib/fail2ban and everything under this directory.\n") + sys.stdout.write("\n") # Update config file -if argv[1] == "install": - print - print "Please do not forget to update your configuration files." - print "They are in /etc/fail2ban/." - print +if sys.argv[1] == "install": + sys.stdout.write("\n") + sys.stdout.write("Please do not forget to update your configuration " + "files.\n") + sys.stdout.write("They are in /etc/fail2ban/.\n") + sys.stdout.write("\n")