2019-05-21 18:40:04 +00:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
|
|
|
|
|
|
# This source code is licensed under the MIT license found in the
|
|
|
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
|
|
2017-02-22 23:59:43 +00:00
|
|
|
import os.path
|
2017-03-09 16:47:59 +00:00
|
|
|
import platform
|
2017-02-22 23:59:43 +00:00
|
|
|
import sys
|
2020-02-07 22:34:08 +00:00
|
|
|
import os
|
2017-02-22 23:59:43 +00:00
|
|
|
from pkg_resources import (
|
|
|
|
|
normalize_path,
|
|
|
|
|
working_set,
|
|
|
|
|
add_activation_listener,
|
|
|
|
|
require,
|
|
|
|
|
)
|
2018-12-21 02:15:07 +00:00
|
|
|
from setuptools import setup, find_packages
|
2017-02-22 23:59:43 +00:00
|
|
|
from setuptools.command.build_py import build_py
|
2017-03-16 15:49:02 +00:00
|
|
|
from setuptools.command.develop import develop
|
2017-02-22 23:59:43 +00:00
|
|
|
from setuptools.command.test import test as test_command
|
2020-02-07 22:34:08 +00:00
|
|
|
from typing import List
|
2017-03-16 15:49:02 +00:00
|
|
|
|
|
|
|
|
PLATFORM = 'unix'
|
|
|
|
|
if platform.platform().startswith('Win'):
|
|
|
|
|
PLATFORM = 'win'
|
|
|
|
|
|
2018-12-21 02:15:07 +00:00
|
|
|
MODEL_DIR = os.path.join('stan', PLATFORM)
|
2018-05-04 23:04:29 +00:00
|
|
|
MODEL_TARGET_DIR = os.path.join('fbprophet', 'stan_model')
|
2017-03-16 15:49:02 +00:00
|
|
|
|
|
|
|
|
|
2020-02-07 22:34:08 +00:00
|
|
|
def get_backends_from_env() -> List[str]:
|
2020-02-18 01:20:20 +00:00
|
|
|
from fbprophet.models import StanBackendEnum
|
2020-02-07 22:34:08 +00:00
|
|
|
return os.environ.get("STAN_BACKEND", StanBackendEnum.PYSTAN.name).split(",")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_models(target_dir):
|
2020-02-18 01:20:20 +00:00
|
|
|
from fbprophet.models import StanBackendEnum
|
2020-02-07 22:34:08 +00:00
|
|
|
for backend in get_backends_from_env():
|
|
|
|
|
StanBackendEnum.get_backend_class(backend).build_model(target_dir, MODEL_DIR)
|
2017-03-16 15:49:02 +00:00
|
|
|
|
|
|
|
|
|
2017-02-22 23:59:43 +00:00
|
|
|
class BuildPyCommand(build_py):
|
|
|
|
|
"""Custom build command to pre-compile Stan models."""
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
if not self.dry_run:
|
2018-05-04 23:04:29 +00:00
|
|
|
target_dir = os.path.join(self.build_lib, MODEL_TARGET_DIR)
|
2017-03-16 15:49:02 +00:00
|
|
|
self.mkpath(target_dir)
|
2020-02-07 22:34:08 +00:00
|
|
|
build_models(target_dir)
|
2017-02-22 23:59:43 +00:00
|
|
|
|
|
|
|
|
build_py.run(self)
|
|
|
|
|
|
|
|
|
|
|
2017-03-16 15:49:02 +00:00
|
|
|
class DevelopCommand(develop):
|
|
|
|
|
"""Custom develop command to pre-compile Stan models in-place."""
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
if not self.dry_run:
|
2018-05-04 23:04:29 +00:00
|
|
|
target_dir = os.path.join(self.setup_path, MODEL_TARGET_DIR)
|
2017-03-16 15:49:02 +00:00
|
|
|
self.mkpath(target_dir)
|
2020-02-07 22:34:08 +00:00
|
|
|
build_models(target_dir)
|
2017-03-16 15:49:02 +00:00
|
|
|
|
|
|
|
|
develop.run(self)
|
2017-03-09 16:47:59 +00:00
|
|
|
|
2017-02-22 23:59:43 +00:00
|
|
|
|
|
|
|
|
class TestCommand(test_command):
|
2020-02-07 22:34:08 +00:00
|
|
|
user_options = [
|
|
|
|
|
('test-module=', 'm', "Run 'test_suite' in specified module"),
|
|
|
|
|
('test-suite=', 's',
|
|
|
|
|
"Run single test, case or suite (e.g. 'module.test_suite')"),
|
|
|
|
|
('test-runner=', 'r', "Test runner to use"),
|
|
|
|
|
('test-slow', 'w', "Test slow suites (default off)"),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
|
super(TestCommand, self).initialize_options()
|
|
|
|
|
self.test_slow = False
|
|
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
|
super(TestCommand, self).finalize_options()
|
|
|
|
|
if self.test_slow is None:
|
|
|
|
|
self.test_slow = getattr(self.distribution, 'test_slow', False)
|
|
|
|
|
|
2017-02-22 23:59:43 +00:00
|
|
|
"""We must run tests on the build directory, not source."""
|
|
|
|
|
|
|
|
|
|
def with_project_on_sys_path(self, func):
|
|
|
|
|
# Ensure metadata is up-to-date
|
|
|
|
|
self.reinitialize_command('build_py', inplace=0)
|
|
|
|
|
self.run_command('build_py')
|
|
|
|
|
bpy_cmd = self.get_finalized_command("build_py")
|
|
|
|
|
build_path = normalize_path(bpy_cmd.build_lib)
|
|
|
|
|
|
|
|
|
|
# Build extensions
|
|
|
|
|
self.reinitialize_command('egg_info', egg_base=build_path)
|
|
|
|
|
self.run_command('egg_info')
|
|
|
|
|
|
|
|
|
|
self.reinitialize_command('build_ext', inplace=0)
|
|
|
|
|
self.run_command('build_ext')
|
|
|
|
|
|
|
|
|
|
ei_cmd = self.get_finalized_command("egg_info")
|
|
|
|
|
|
|
|
|
|
old_path = sys.path[:]
|
|
|
|
|
old_modules = sys.modules.copy()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
sys.path.insert(0, normalize_path(ei_cmd.egg_base))
|
|
|
|
|
working_set.__init__()
|
|
|
|
|
add_activation_listener(lambda dist: dist.activate())
|
|
|
|
|
require('%s==%s' % (ei_cmd.egg_name, ei_cmd.egg_version))
|
|
|
|
|
func()
|
|
|
|
|
finally:
|
|
|
|
|
sys.path[:] = old_path
|
|
|
|
|
sys.modules.clear()
|
|
|
|
|
sys.modules.update(old_modules)
|
|
|
|
|
working_set.__init__()
|
|
|
|
|
|
2020-02-07 22:34:08 +00:00
|
|
|
|
2018-02-03 01:10:44 +00:00
|
|
|
with open('requirements.txt', 'r') as f:
|
|
|
|
|
install_requires = f.read().splitlines()
|
2017-08-10 18:14:23 +00:00
|
|
|
|
2017-02-22 23:59:43 +00:00
|
|
|
setup(
|
|
|
|
|
name='fbprophet',
|
2020-04-04 15:28:22 +00:00
|
|
|
version='0.6.1.dev0',
|
2017-02-22 23:59:43 +00:00
|
|
|
description='Automatic Forecasting Procedure',
|
2018-12-21 02:15:07 +00:00
|
|
|
url='https://facebook.github.io/prophet/',
|
2019-05-14 06:00:12 +00:00
|
|
|
author='Sean J. Taylor <sjtz@pm.me>, Ben Letham <bletham@fb.com>',
|
|
|
|
|
author_email='sjtz@pm.me',
|
2019-05-21 18:40:04 +00:00
|
|
|
license='MIT',
|
2018-12-21 02:15:07 +00:00
|
|
|
packages=find_packages(),
|
2017-02-22 23:59:43 +00:00
|
|
|
setup_requires=[
|
|
|
|
|
],
|
2018-02-03 01:10:44 +00:00
|
|
|
install_requires=install_requires,
|
2020-05-14 19:16:34 +00:00
|
|
|
python_requires='>=3',
|
2017-02-22 23:59:43 +00:00
|
|
|
zip_safe=False,
|
2018-12-21 00:11:53 +00:00
|
|
|
include_package_data=True,
|
2017-02-22 23:59:43 +00:00
|
|
|
cmdclass={
|
|
|
|
|
'build_py': BuildPyCommand,
|
2017-03-16 15:49:02 +00:00
|
|
|
'develop': DevelopCommand,
|
2017-02-22 23:59:43 +00:00
|
|
|
'test': TestCommand,
|
|
|
|
|
},
|
2017-08-10 18:14:23 +00:00
|
|
|
test_suite='fbprophet.tests',
|
2019-07-25 23:20:21 +00:00
|
|
|
classifiers=[
|
|
|
|
|
'Programming Language :: Python',
|
|
|
|
|
'Programming Language :: Python :: 3',
|
|
|
|
|
'Programming Language :: Python :: 3.7',
|
2020-02-07 22:34:08 +00:00
|
|
|
],
|
2017-02-22 23:59:43 +00:00
|
|
|
long_description="""
|
2018-05-31 00:02:47 +00:00
|
|
|
Implements a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. It works best with time series that have strong seasonal effects and several seasons of historical data. Prophet is robust to missing data and shifts in the trend, and typically handles outliers well.
|
2017-02-22 23:59:43 +00:00
|
|
|
"""
|
|
|
|
|
)
|