From 7f9e4b80c1b082fd221d6e189c3938ff31ce74c1 Mon Sep 17 00:00:00 2001 From: Ben Letham Date: Fri, 2 Feb 2018 17:10:44 -0800 Subject: [PATCH] Read install_requires from requirements.txt, and make things work without matplotlib installed --- python/fbprophet/forecaster.py | 10 +++++++--- python/setup.py | 8 +++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/python/fbprophet/forecaster.py b/python/fbprophet/forecaster.py index 4c361df..88866ca 100644 --- a/python/fbprophet/forecaster.py +++ b/python/fbprophet/forecaster.py @@ -15,11 +15,15 @@ from copy import deepcopy from datetime import timedelta import logging +logging.basicConfig() logger = logging.getLogger(__name__) -from matplotlib import pyplot as plt -from matplotlib.dates import MonthLocator, num2date -from matplotlib.ticker import FuncFormatter +try: + from matplotlib import pyplot as plt + from matplotlib.dates import MonthLocator, num2date + from matplotlib.ticker import FuncFormatter +except ImportError: + logger.exception('Importing matplotlib failed. Plotting will not work.') import numpy as np import pandas as pd diff --git a/python/setup.py b/python/setup.py index 29275cd..d528ced 100644 --- a/python/setup.py +++ b/python/setup.py @@ -94,6 +94,8 @@ class TestCommand(test_command): sys.modules.update(old_modules) working_set.__init__() +with open('requirements.txt', 'r') as f: + install_requires = f.read().splitlines() setup( name='fbprophet', @@ -106,11 +108,7 @@ setup( packages=['fbprophet', 'fbprophet.tests'], setup_requires=[ ], - install_requires=[ - 'matplotlib', - 'pandas>=0.18.1', - 'pystan>=2.14', - ], + install_requires=install_requires, zip_safe=False, include_package_data=True, # For Python 3, Will enforce that tests are run after a build.