Repository: litestar-org/litestar

Issue:
Bug: Running `starlite run` after installing starlite[cli] gives error about missing cryptography package
The error is here:
```
Traceback (most recent call last):
  File "C:\Users\hanne\Documents\Programme\analyze-wiktionary\.venv\lib\site-packages\starlite\middleware\session\cookie_backend.py", line 20, 
in <module>
    from cryptography.exceptions import InvalidTag
ModuleNotFoundError: No module named 'cryptography'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\hanne\Documents\Programme\analyze-wiktionary\.venv\Scripts\starlite.exe\__main__.py", line 4, in <module>
  File "C:\Users\hanne\Documents\Programme\analyze-wiktionary\.venv\lib\site-packages\starlite\cli.py", line 41, in <module>
    from starlite.middleware.session import SessionMiddleware
  File "C:\Users\hanne\Documents\Programme\analyze-wiktionary\.venv\lib\site-packages\starlite\middleware\session\__init__.py", line 2, in <module>
    from .cookie_backend import (
  File "C:\Users\hanne\Documents\Programme\analyze-wiktionary\.venv\lib\site-packages\starlite\middleware\session\cookie_backend.py", line 23, 
in <module>
    raise MissingDependencyException("cryptography is not installed") from e
starlite.exceptions.base_exceptions.MissingDependencyException: cryptography is not installed
```

I thought it might be a good idea to install the package automatically with the CLI extra. (Or to update the [docs](https://starlite-api.github.io/starlite/usage/19-cli/?h=uvicorn) if I'm missing something).

My versions: Windows, Python 3.10, starlite 1.46.0 

PS: Thank you all for the great amount of effort you spend on this project!


Discussion:
Adding to this, when installing `starlite[standard]`, rich and click are not installed, because Poetry doesn't support referencing the other definitions in the extras section: https://github.com/python-poetry/poetry/issues/5471.
>  I thought it might be a good idea to install the package automatically with the CLI extra

No, it's not actually required by the CLI. The CLI is just using a wrong import (that's on me) that should have been properly marked as deprecated (also on me :upside_down_face:). I'll fix that and make it proper.



Resolving patch:
diff --git a/starlite/middleware/session/__init__.py b/starlite/middleware/session/__init__.py
--- a/starlite/middleware/session/__init__.py
+++ b/starlite/middleware/session/__init__.py
@@ -1,9 +1,27 @@
+from typing import Any
+
+from starlite.utils import warn_deprecation
+
 from .base import SessionMiddleware
-from .cookie_backend import (
-    CookieBackendConfig as SessionCookieConfig,  # backwards compatible export
-)
-
-__all__ = [
-    "SessionMiddleware",
-    "SessionCookieConfig",
-]
+
+
+def __getattr__(name: str) -> Any:
+    """Provide lazy importing as per https://peps.python.org/pep-0562/"""
+
+    if name != "SessionCookieConfig":
+        raise AttributeError(f"Module {__package__} has no attribute {name}")
+
+    from .cookie_backend import CookieBackendConfig
+
+    warn_deprecation(
+        deprecated_name=f"{name} from {__package__}",
+        kind="import",
+        alternative="'from startlite.middleware.sessions.cookie_backend import CookieBackendConfig'",
+        version="1.47.0",
+    )
+
+    globals()[name] = CookieBackendConfig
+    return CookieBackendConfig
+
+
+__all__ = ["SessionMiddleware"]


Test patch: