From 7bd5ef80016257ea56a1d10f917a361a13b6aad9 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Thu, 27 Jul 2017 15:56:06 -0700 Subject: [PATCH] Remove the Flask-Script dependency in setup.py --- flask_migrate/__init__.py | 16 ++++++++++++++-- setup.py | 4 +++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/flask_migrate/__init__.py b/flask_migrate/__init__.py index 1d9db2e..d7be2c1 100755 --- a/flask_migrate/__init__.py +++ b/flask_migrate/__init__.py @@ -1,7 +1,10 @@ import os import argparse from flask import current_app -from flask_script import Manager +try: + from flask_script import Manager +except ImportError: + Manager = None from alembic import __version__ as __alembic_version__ from alembic.config import Config as AlembicConfig from alembic import command @@ -81,7 +84,16 @@ def get_config(self, directory, x_arg=None, opts=None): return self.call_configure_callbacks(config) -MigrateCommand = Manager(usage='Perform database migrations') +if Manager is not None: + MigrateCommand = Manager(usage='Perform database migrations') +else: + class FakeCommand(object): + def option(self, *args, **kwargs): + def decorator(f): + return f + return decorator + + MigrateCommand = FakeCommand() @MigrateCommand.option('-d', '--directory', dest='directory', default=None, diff --git a/setup.py b/setup.py index 4514206..0589217 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,9 @@ install_requires=[ 'Flask>=0.9', 'Flask-SQLAlchemy>=1.0', - 'alembic>=0.6', + 'alembic>=0.6' + ], + tests_require=[ 'Flask-Script>=0.6' ], entry_points={