Skip to content

Commit

Permalink
add installation check script
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevdp committed Jul 29, 2013
1 parent 2d3d462 commit 22f70fd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*~

*.py[cod]

# C extensions
Expand Down
55 changes: 55 additions & 0 deletions scripts/check_installation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import warnings
import sys
import os
from distutils.version import StrictVersion

def warn(msg):
print msg
warnings.warn(msg)
warn.count += 1
warn.count = 0


def check_import(package_name, version=None):
try:
pkg = __import__(package_name)
except ImportError:
warn("Package {0} is not available".format(package_name))
return

if version:
pkg_version = pkg.__version__.rstrip('git').rstrip('-')

if StrictVersion(str(pkg_version)) < str(version):
warn("Package {0} is version {1}; "
"{2} or greater is recommended".format(pkg, pkg.__version__,
version))


# check Python version
if not (2, 6) <= sys.version_info[:2] <= (2, 7):
warn("Python 2.6 - 2.7 recommended")


# check package versions
check_import('numpy', '1.5')
check_import('scipy', '0.11')
check_import('IPython', '0.13')
check_import('matplotlib', '1.0')
check_import('sklearn', '0.12')
check_import('nose')


if warn.count > 0:
print(" - warning count: {0}.".format(warn_count))
print(" Consider upgrading your Python install:")
print(" Anaconda is a good all-in-one option: ")
print(" https://store.continuum.io/".format(warn.count))
else:
print(" - no warnings: Congratulations! ")
print(" Your Python installation appears up-to-date!")
print(" - please confirm that typing ``ipython notebook`` at your terminal")
print(" launches a browser window to the IPython dashboard. If not,")
print(" then there are other packages which must be installed. For")
print(" an easy all-in-one installation, try Anaconda:")
print(" https://store.continuum.io/")

0 comments on commit 22f70fd

Please sign in to comment.