Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplify the dependency checking code since we only care about NumPy,…
… and when NumPy is missing and we seem to be running in an automated setup tool just abort instead of prompting (Bug 2889)
  • Loading branch information
peterc committed Jul 29, 2009
1 parent eb94db8 commit 7452113
Showing 1 changed file with 19 additions and 40 deletions.
59 changes: 19 additions & 40 deletions setup.py
Expand Up @@ -73,46 +73,25 @@ def check_dependencies():
# --force option that gets saved in self.user_options. It # --force option that gets saved in self.user_options. It
# means overwrite previous installations. If the user has # means overwrite previous installations. If the user has
# forced an installation, should we also ignore dependencies? # forced an installation, should we also ignore dependencies?


#This is a list of tuples, containing: # We only check for NumPy, as this is a compile time dependency
# - package name, string if is_Numpy_installed() : return True
# - is packaged installed, boolean print """
# - is packaged required, boolean Numerical Python (NumPy) is not installed.
# - package website, string
dependencies = [
("Numerical Python (NumPy)", is_Numpy_installed, 0,
"http://numpy.scipy.org/"),
]

for name, is_installed_fn, is_required, url in dependencies:
if is_installed_fn():
continue

print "*** %s *** is either not installed or out of date." % name
if is_required:

print """
This package is required for many Biopython features. Please install This package is required for many Biopython features. Please install
it before you install Biopython.""" it before you install Biopython. You can install Biopython anyway, but
default = 0 anything dependent on NumPy will not work. If you do this, and later
else: install NumPy, you should then re-install Biopython.
print """
This package is optional, which means it is only used in a few You can find NumPy at http://numpy.scipy.org
specialized modules in Biopython. You probably don't need this if you """
are unsure. You can ignore this requirement, and install it later if # exit automatically if running as part of some script
you see ImportErrors.""" # (e.g. PyPM, ActiveState's Python Package Manager)
default = 1 if not sys.stdout.isatty() :
print "You can find %s at %s." % (name, url) sys.exit(-1)
print # We can ask the user
# exit automatically if required packages not installed return get_yes_or_no("Do you want to continue this installation?", False)
if not(default):
sys.exit(-1)

if not get_yes_or_no(
"Do you want to continue this installation?", default):
return 0

return 1


class install_biopython(install): class install_biopython(install):
"""Override the standard install to check for dependencies. """Override the standard install to check for dependencies.
Expand Down Expand Up @@ -204,7 +183,7 @@ def can_import(module_name):
return None return None


def is_Numpy_installed(): def is_Numpy_installed():
return can_import("numpy") return bool(can_import("numpy"))


# --- set up the packages we are going to install # --- set up the packages we are going to install
# standard biopython packages # standard biopython packages
Expand Down

0 comments on commit 7452113

Please sign in to comment.