From 4d9601ecba04db23e8779d5a741fd07d2b34da5b Mon Sep 17 00:00:00 2001 From: Lex Date: Sun, 24 Mar 2024 22:13:45 +1000 Subject: [PATCH] Revert "Let Flask-Session be installed with optional dependencies." --- CONTRIBUTING.rst | 14 ++++---- CONTRIBUTORS.md | 1 - docs/installation.rst | 61 ++++++++++------------------------- docs/usage.rst | 26 +-------------- pyproject.toml | 8 ----- src/flask_session/__init__.py | 2 +- 6 files changed, 26 insertions(+), 86 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index f2f7cf0b..d9b7f0c7 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -8,7 +8,7 @@ Navigate to the project directory and run the following commands: Create and activate a virtual environment .. code-block:: bash - + $ python -m venv .venv $ source .venv/bin/activate @@ -16,7 +16,7 @@ Install dependencies .. code-block:: bash - $ pip install -r requirements/dev.txt + $ pip install -r requirements/dev.in $ pip install -r requirements/docs.in Install the package in editable mode @@ -47,11 +47,11 @@ or Run the tests together or individually .. code-block:: bash - + $ pytest tests $ pytest tests/test_basic.py -For easier startup and teardown of storage for testing you may use +For easier startup and teardown of storage for testing you may use .. code-block:: bash @@ -62,13 +62,13 @@ Using rye ~~~~~~~~~~~ .. code-block:: bash - + $ rye pin 3.11 $ rye sync .. code-block:: bash - + $ rye run python examples/hello.py @@ -76,4 +76,4 @@ etc. Pull requests -------------- -Please check previous pull requests before submitting a new one. +Please check previous pull requests before submitting a new one. \ No newline at end of file diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 07122b42..f8aafac8 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,6 +1,5 @@ ## Contributors -- [eiriklid](https://github.com/eiriklid) - [nebolax](https://github.com/nebolax) - [Taragolis](https://github.com/Taragolis) - [Lxstr](https://github.com/Lxstr) diff --git a/docs/installation.rst b/docs/installation.rst index 99313035..1bf19d40 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -8,14 +8,13 @@ Install from PyPI using an installer such as pip: $ pip install Flask-Session -Flask-Session's only required dependency is msgspec for serialization, which has no sub-dependencies. +Flask-Session's only required dependency is msgspec for serialization, which has no sub-dependencies. -However, you also need to choose a storage type and install an appropriate client library so the app can communicate with storage. -For example, if you want to use Redis as your storage, you will need to install the redis-py_ library either directly or as an optional dependency like below: +However, you also need to choose a storage type and install an appropriate client library so the app can communicate with storage. For example, if you want to use Redis as your storage, you will need to install the redis-py client library: .. code-block:: bash - $ pip install Flask-Session[redis] + $ pip install redis Redis is the recommended storage type for Flask-Session, as it has the most complete support for the features of Flask-Session with minimal configuration. @@ -24,58 +23,32 @@ Redis is the recommended storage type for Flask-Session, as it has the most comp Flask-Session versions below 1.0.0 (not yet released), use pickle_ as the default serializer, which may have security implications in production if your storage is ever compromised. -Available storage options -^^^^^^^^^^^^^^^^^^^^^^^^^ - -To install Flask-Session with support for a specific storage backend, use the following command, replacing ```` with your chosen backend from the list below: - -.. code-block:: bash - - pip install Flask-Session[] - -Available storage options and their corresponding ```` values are: +Direct support +--------------- +Flask-Session has an increasing number of directly supported storage and client libraries. .. list-table:: :header-rows: 1 :align: left * - Storage - - - - Default client library - - Alternative client libraries - * - **Redis** - - ``redis`` + - Client Library + * - Redis - redis-py_ - - - * - **Memcached** - - ``memcached`` - - pymemcache_ - - pylibmc_, python-memcached_, libmc_ - * - **MongoDB** - - ``mongodb`` + * - Memcached + - pylibmc_, python-memcached_, libmc_ or pymemcache_ + * - MongoDB - pymongo_ - - - * - **CacheLib** - - ``cachelib`` - - cachelib_ - - - * - **SQLAlchemy** - - ``sqlalchemy`` + * - SQL Alchemy - flask-sqlalchemy_ - - - * - **DynamoDB** - - ``dynamodb`` - - boto3_ - - -Other storage backends might be compatible with Flask-Session as long as they adhere to the command interfaces used by the libraries listed above. +Other libraries may work if they use the same commands as the ones listed above. Cachelib -------- -Flask-Session also indirectly supports storage and client libraries via cachelib_, which is a wrapper around various cache libraries. -You must also install cachelib_ itselfand the relevant client library to use these. +Flask-Session also indirectly supports storage and client libraries via cachelib_, which is a wrapper around various cache libraries. You must also install cachelib_ itself to use these. .. list-table:: :header-rows: 1 @@ -97,7 +70,7 @@ You must also install cachelib_ itselfand the relevant client library to use the - pymongo_ * - DynamoDB - boto3_ - + .. warning:: @@ -109,10 +82,10 @@ You must also install cachelib_ itselfand the relevant client library to use the .. _python-memcached: https://github.com/linsomniac/python-memcached .. _pymemcache: https://github.com/pinterest/pymemcache .. _pymongo: https://pymongo.readthedocs.io/en/stable -.. _flask-sqlalchemy: https://github.com/pallets-eco/flask-sqlalchemy +.. _Flask-SQLAlchemy: https://github.com/pallets-eco/flask-sqlalchemy .. _cachelib: https://cachelib.readthedocs.io/en/stable/ .. _google.appengine.api.memcached: https://cloud.google.com/appengine/docs/legacy/standard/python/memcache .. _boto3: https://boto3.amazonaws.com/v1/documentation/api/latest/index.html .. _libmc: https://github.com/douban/libmc .. _uwsgi: https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html -.. _pickle: https://docs.python.org/3/library/pickle.html +.. _pickle: https://docs.python.org/3/library/pickle.html \ No newline at end of file diff --git a/docs/usage.rst b/docs/usage.rst index 675d9e9e..ce389615 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -62,28 +62,4 @@ Or, if you prefer to directly set parameters rather than using the configuration app = Flask(__name__) redis = Redis(host='localhost', port=6379) - app.session_interface = RedisSessionInterface(client=redis) - - -Using CacheLib as a session backend ------------------------------------- - -.. note:: - - FileSystemSession was recently deprecated in favor of CacheLib, which is what is was using under the hood. - -The following example demonstrates how to use CacheLib as a session backend with the file system cache. This might be useful for rapid development or testing. - -.. code-block:: python - - from flask import Flask, session - from flask_session import Session - from cachelib.file import FileSystemCache - - app = Flask(__name__) - - SESSION_TYPE = 'cachelib' - SESSION_SERIALIZATION_FORMAT = 'json' - SESSION_CACHELIB = FileSystemCache(threshold=500, cache_dir="/sessions"), - app.config.from_object(__name__) - Session(app) \ No newline at end of file + app.session_interface = RedisSessionInterface(client=redis) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 4c828700..b31e38f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,14 +25,6 @@ dependencies = [ ] dynamic = ["version"] -[project.optional-dependencies] -cachelib = ["cachelib>=0.10.2"] -memcached = ["pymemcache"] -mongodb = ["pymongo>=4.6.2"] -redis = ["redis>=5.0.3"] -sqlalchemy = ["flask-sqlalchemy>=3.0.5"] -all = ["Flask-Session[cachelib, memcached, mongodb, redis, sqlalchemy]"] - [project.urls] Documentation = "https://flask-session.readthedocs.io" Changes = "https://flask-session.readthedocs.io/changes.html" diff --git a/src/flask_session/__init__.py b/src/flask_session/__init__.py index f8f1d6a6..b1abf810 100644 --- a/src/flask_session/__init__.py +++ b/src/flask_session/__init__.py @@ -1,6 +1,6 @@ from .defaults import Defaults -__version__ = "0.8.0" +__version__ = "0.7.0" class Session: