Skip to content

Commit

Permalink
Merge pull request #300 from jseabold/dependencies-middle-ground
Browse files Browse the repository at this point in the history
Determine install_requires from missing packages at install-time
  • Loading branch information
mwaskom committed Sep 24, 2014
2 parents 34957a5 + 8c38c46 commit 4cbbdfd
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions setup.py
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

0 comments on commit 4cbbdfd

Please sign in to comment.