ENH: setup.py now automatically runs 2to3 for python3.x

pull/128/head
Steven Hiscocks 2013-04-09 19:40:54 +01:00
parent 77aa523f22
commit a33bf5baca
1 changed files with 29 additions and 18 deletions

View File

@ -23,9 +23,18 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL" __license__ = "GPL"
from distutils.core import setup 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 common.version import version
from os.path import isfile, join, isdir from os.path import isfile, join, isdir
from sys import argv import sys
from glob import glob from glob import glob
longdesc = ''' longdesc = '''
@ -45,6 +54,7 @@ setup(
url = "http://www.fail2ban.org", url = "http://www.fail2ban.org",
license = "GPL", license = "GPL",
platforms = "Posix", platforms = "Posix",
cmdclass = {'build_py': build_py, 'build_scripts': build_scripts},
scripts = [ scripts = [
'fail2ban-client', 'fail2ban-client',
'fail2ban-server', 'fail2ban-server',
@ -100,25 +110,26 @@ for directory in elements:
obsoleteFiles.append(path) obsoleteFiles.append(path)
if obsoleteFiles: if obsoleteFiles:
print sys.stdout.write("\n")
print "Obsolete files from previous Fail2Ban versions were found on " \ sys.stdout.write("Obsolete files from previous Fail2Ban versions " \
"your system." "were found on your system.\n")
print "Please delete them:" sys.stdout.write("Please delete them:\n")
print sys.stdout.write("\n")
for f in obsoleteFiles: for f in obsoleteFiles:
print "\t" + f sys.stdout.write("\t" + f)
print sys.stdout.write("\n")
if isdir("/usr/lib/fail2ban"): if isdir("/usr/lib/fail2ban"):
print sys.stdout.write("\n")
print "Fail2ban is not installed under /usr/lib anymore. The new " \ sys.stdout.write("Fail2ban is not installed under /usr/lib anymore. " \
"location is under /usr/share. Please remove the directory " \ "The new location is under /usr/share. Please remove the " \
"/usr/lib/fail2ban and everything under this directory." "directory /usr/lib/fail2ban and everything under this directory.\n")
print sys.stdout.write("\n")
# Update config file # Update config file
if argv[1] == "install": if sys.argv[1] == "install":
print sys.stdout.write("\n")
print "Please do not forget to update your configuration files." sys.stdout.write("Please do not forget to update your configuration "
print "They are in /etc/fail2ban/." "files.\n")
print sys.stdout.write("They are in /etc/fail2ban/.\n")
sys.stdout.write("\n")