Skip to content

Commit d9e12b7

Browse files
committed
Check for dependencies at install time
1 parent c5a4553 commit d9e12b7

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

setup.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Michael Waskom <[email protected]>
55
# Scott Burns <[email protected]>
66

7-
descr = """PySurfer: Python / FreeSurfer / Mayavi2 for brain imaging"""
7+
descr = """PySurfer: cortical surface visualization using Python."""
88

99
import os
1010
# deal with MPL sandbox violations during easy_install
@@ -30,12 +30,40 @@
3030
DOWNLOAD_URL = 'https://github.com/nipy/PySurfer'
3131
VERSION = version
3232

33+
def check_dependencies():
34+
35+
needed_deps = ["IPython",
36+
"numpy", "scipy", "matplotlib",
37+
"nibabel",
38+
"mayavi",
39+
]
40+
missing_deps = []
41+
for dep in needed_deps:
42+
try:
43+
__import__(dep)
44+
except ImportError:
45+
missing_deps.append(dep)
46+
47+
if missing_deps:
48+
missing = ", ".join(missing_deps)
49+
raise ImportError("Missing dependencies: %s" % missing)
50+
51+
3352
from setuptools import setup
3453

3554
if __name__ == "__main__":
3655
if os.path.exists('MANIFEST'):
3756
os.remove('MANIFEST')
3857

58+
import sys
59+
if not (len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or
60+
sys.argv[1] in ('--help-commands',
61+
'--version',
62+
'egg_info',
63+
'clean'))):
64+
check_dependencies()
65+
66+
3967
setup(name=DISTNAME,
4068
maintainer=MAINTAINER,
4169
include_package_data=True,

0 commit comments

Comments
 (0)