diff --git a/moto/moto_server/werkzeug_app.py b/moto/moto_server/werkzeug_app.py index 8d9c3bc77..107eae0b1 100644 --- a/moto/moto_server/werkzeug_app.py +++ b/moto/moto_server/werkzeug_app.py @@ -3,8 +3,16 @@ import os import os.path from threading import Lock -from flask import Flask -from flask_cors import CORS +try: + from flask import Flask + from flask_cors import CORS +except ImportError: + import warnings + + warnings.warn( + "When using MotoServer, ensure that you install moto[server] to have all dependencies!\n" + ) + raise import moto.backends as backends import moto.backend_index as backend_index diff --git a/setup.py b/setup.py index 11b9e9f22..0b201fb3c 100755 --- a/setup.py +++ b/setup.py @@ -39,8 +39,6 @@ install_requires = [ "MarkupSafe!=2.0.0a1", # This is a Jinja2 dependency, 2.0.0a1 currently seems broken "Jinja2>=2.10.1", "importlib_metadata ; python_version < '3.8'", - "flask<2.2.0", # Required for the ThreadedMotoServer - "flask-cors" ] _dep_PyYAML = "PyYAML>=5.1" @@ -75,7 +73,7 @@ all_extra_deps = [ _dep_openapi, _setuptools, ] -all_server_deps = all_extra_deps +all_server_deps = all_extra_deps + ["flask<2.2.0", "flask-cors"] extras_per_service = {} for service_name in [