Permalink
Browse files

setup.py is now Python 3 aware

  • Loading branch information...
tiagoantao committed Jul 16, 2010
1 parent df05b99 commit 942ef84302791423282f84fe01ef33a78704dcab
Showing with 32 additions and 23 deletions.
  1. +32 −23 setup.py
View
@@ -24,24 +24,6 @@
import sys
import os
-# Make sure I have the right Python version.
-if sys.version_info[:2] < (2, 4):
- print "Biopython requires Python 2.4 or better (but not Python 3 " \
- + "yet). Python %d.%d detected" % sys.version_info[:2]
- sys.exit(-1)
-elif sys.version_info[:2] == (2,4):
- print "Warning - we are phasing out support for Python 2.4"
-elif sys.version_info[0] == 3:
- print "Biopython does not yet officially support Python 3, but you"
- print "can try it by first using the 2to3 script on our source code."
-
-from distutils.core import setup
-from distutils.core import Command
-from distutils.command.install import install
-from distutils.command.build_py import build_py
-from distutils.command.build_ext import build_ext
-from distutils.extension import Extension
-
def get_yes_or_no(question, default):
if default:
option_str = "(Y/n)"
@@ -51,15 +33,42 @@ def get_yes_or_no(question, default):
default_str = 'n'
while True:
- print "%s %s " % (question, option_str),
- response = raw_input().lower()
+ print ("%s %s " % (question, option_str),)
+ if sys.version_info[0] == 3:
+ response = input().lower()
+ else:
+ response = raw_input().lower()
if not response:
response = default_str
if response[0] in ['y', 'n']:
break
- print "Please answer y or n."
+ print ("Please answer y or n.")
return response[0] == 'y'
+# Make sure I have the right Python version.
+if sys.version_info[:2] < (2, 4):
+ print ("Biopython requires Python 2.4 or better (but not Python 3 " \
+ + "yet). Python %d.%d detected" % sys.version_info[:2])
+ sys.exit(-1)
+elif sys.version_info[:2] == (2,4):
+ print ("Warning - we are phasing out support for Python 2.4")
+elif sys.version_info[0] == 3:
+ print("Biopython does not yet officially support Python 3, but you")
+ print("can try it by first using the 2to3 script on our source code.")
+ print("For details on how to use 2to3 with Biopython see README.")
+ print("If you still haven't applied 2to3 to Biopython please abort now.")
+ cont = get_yes_or_no("Do you want to continue this installation?", False)
+ if not cont:
+ sys.exit(-1)
+
+from distutils.core import setup
+from distutils.core import Command
+from distutils.command.install import install
+from distutils.command.build_py import build_py
+from distutils.command.build_ext import build_ext
+from distutils.extension import Extension
+
+
_CHECKED = None
def check_dependencies_once():
# Call check_dependencies, but cache the result for subsequent
@@ -85,7 +94,7 @@ def check_dependencies():
if os.name=='java':
return True #NumPy is not avaliable for Jython (for now)
- print """
+ print ("""
Numerical Python (NumPy) is not installed.
This package is required for many Biopython features. Please install
@@ -94,7 +103,7 @@ def check_dependencies():
install NumPy, you should then re-install Biopython.
You can find NumPy at http://numpy.scipy.org
-"""
+""")
# exit automatically if running as part of some script
# (e.g. PyPM, ActiveState's Python Package Manager)
if not sys.stdout.isatty() :

0 comments on commit 942ef84

Please sign in to comment.