Skip to content

Commit

Permalink
BLD: Install dependencies if cannot be imported.
Browse files Browse the repository at this point in the history
  • Loading branch information
jseabold committed Sep 24, 2014
1 parent 34957a5 commit 8c38c46
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,30 @@
except ImportError:
from distutils.core import setup


def check_dependencies():
install_requires = []

# Just make sure dependencies exist, I haven't rigorously
# tested what the minimal versions that will work are
# (help on that would be awesome)
try:
import numpy
except ImportError:
raise ImportError("seaborn requires numpy")
install_requires.append('numpy')
try:
import scipy
except ImportError:
raise ImportError("seaborn requires scipy")
install_requires.append('scipy')
try:
import matplotlib
except ImportError:
raise ImportError("seaborn requires matplotlib")
install_requires.append('matplotlib')
try:
import pandas
except ImportError:
raise ImportError("seaborn requires pandas")
install_requires.append('pandas')

return install_requires

if __name__ == "__main__":
import os
Expand All @@ -62,7 +64,9 @@ def check_dependencies():
if not (len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or
sys.argv[1] in ('--help-commands', 'egg_info', '--version',
'clean'))):
check_dependencies()
install_requires = check_dependencies()
else:
install_requires = []

setup(name=DISTNAME,
maintainer=MAINTAINER,
Expand All @@ -73,6 +77,7 @@ def check_dependencies():
url=URL,
version=VERSION,
download_url=DOWNLOAD_URL,
install_requires=install_requires,
packages=['seaborn', 'seaborn.external', 'seaborn.tests'],
classifiers=[
'Intended Audience :: Science/Research',
Expand Down

1 comment on commit 8c38c46

@megies
Copy link
Contributor

@megies megies commented on 8c38c46 Sep 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply put all the dependencies statically in install_requires??

Edit: OK, nevermind.. I saw there's some issues mentioning pip problems with order of install and somesuch..

Please sign in to comment.