Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Avanov committed Apr 10, 2020
1 parent 20696f4 commit 5678ca7
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -12,6 +12,9 @@ dist/
*.egg-info/
.DS_Store

.venv/
.local/

docs/_build

*nose*
Expand Down
3 changes: 2 additions & 1 deletion requirements/local.txt
@@ -1,4 +1,5 @@
Sphinx>=2.1.2,<2.2
invoke==1.2.0
wheel>=0.33.1,<0.34
piprot==0.9.10
piprot==0.9.10
Nuitka>=0.6.7,<0.7
12 changes: 6 additions & 6 deletions requirements/minimal.txt
@@ -1,16 +1,16 @@
uvicorn==0.8.4
uvloop>=0.12.2,<0.13.0
httpx>=0.6.8,<0.7
uvicorn==0.11.3
uvloop>=0.14,<0.15.0
httpx>=0.12.1,<0.13
aiopg==0.16.0
hiredis==1.0.0
aioredis==1.2.0
aioredis>=1.3.1,<1.4
psycopg2>=2.8.3,<2.9
sqlalchemy>=1.3.5,<1.4
alembic>=1.0.11,<1.1
pyyaml>=5.1,<6.0
ramlfications==0.1.9
venusian==1.2.0
# for the parser
inflection==0.3.1
typeit==0.17.0
inflection>=0.4,<0.5
typeit==0.22.0
routes==2.4.1
2 changes: 1 addition & 1 deletion requirements/test.txt
@@ -1,7 +1,7 @@
pytest>=5.0.1,<5.1
coverage>=4.5.3,<4.6
pytest-cov>=2.7.1,<2.8
mypy==0.720
mypy==0.770
docker>=4.0.2,<4.1
faker>=2.0.0,<2.1
redis>=3.3.3,<3.4
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -13,7 +13,7 @@
requires = []
for row in rows:
row = row.strip()
if row and not (row.startswith('#') or row.startswith('http')):
if row and not (row.startswith('#') or row.startswith('https')):
requires.append(row)


Expand Down
63 changes: 63 additions & 0 deletions shell.nix
@@ -0,0 +1,63 @@
with (import (builtins.fetchTarball {
# Descriptive name to make the store path easier to identify
name = "solo-python38";
# Commit hash for nixos-unstable as of 2019-10-27
url = https://github.com/NixOS/nixpkgs-channels/archive/f601ab37c2fb7e5f65989a92df383bcd6942567a.tar.gz;
# Hash obtained using `nix-prefetch-url --unpack <url>`
sha256 = "0ikhcmcc29iiaqjv5r91ncgxny2z67bjzkppd3wr1yx44sv7v69s";
}) {});

let macOsDeps = with pkgs; stdenv.lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreServices
darwin.apple_sdk.frameworks.ApplicationServices
];

in

# Make a new "derivation" that represents our shell
stdenv.mkDerivation {
name = "solo38";

# The packages in the `buildInputs` list will be added to the PATH in our shell
# Python-specific guide:
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md
buildInputs = [
# see https://nixos.org/nixos/packages.html
# Python distribution
python38Full
python38Packages.virtualenv
python38Packages.wheel
python38Packages.twine
taglib
ncurses
libxml2
libxslt
libzip
zlib
libressl

libuv
postgresql
# root CA certificates
cacert
which
] ++ macOsDeps;
shellHook = ''
# set SOURCE_DATE_EPOCH so that we can use python wheels
export SOURCE_DATE_EPOCH=$(date +%s)
VENV_DIR=$PWD/.venv
export PATH=$VENV_DIR/bin:$PATH
export PYTHONPATH=""
export LANG=en_US.UTF-8
# https://python-poetry.org/docs/configuration/
export PIP_CACHE_DIR=$PWD/.local/pip-cache
# Setup virtualenv
if [ ! -d $VENV_DIR ]; then
virtualenv $PWD/.venv
fi
'';
}
5 changes: 3 additions & 2 deletions solo/server/app.py
Expand Up @@ -5,12 +5,13 @@
import aioredis

from solo.server.db import SQLEngine
from solo.types import IO

logger = logging.getLogger(__name__)


class App(NamedTuple):
route_map: routes.Mapper
url_gen: routes.URLGenerator
dbengine: Awaitable[SQLEngine]
memstore: Awaitable[aioredis.commands.Redis]
dbengine: IO[SQLEngine]
memstore: IO[aioredis.commands.Redis]
4 changes: 2 additions & 2 deletions solo/server/db/__init__.py
Expand Up @@ -6,13 +6,13 @@

from solo.config.app import Config
from .types import SQLEngine

from ...types import IO

log = logging.getLogger(__name__)


def setup_database(loop: asyncio.AbstractEventLoop,
config: Config) -> Awaitable[SQLEngine]:
config: Config) -> IO[SQLEngine]:
""" Configure and return sqlalchemy's Engine instance with a
built-in connection pool.
"""
Expand Down
5 changes: 3 additions & 2 deletions solo/server/handler/http_handler.py
Expand Up @@ -13,6 +13,7 @@
from ..request import Request
from ..definitions import HttpMethod, ScopeType, ScopeScheme, ScopeServer, Scope
from solo.server.runtime.dependencies import Runtime
from ...types import IO

logger = logging.getLogger(__name__)

Expand All @@ -21,8 +22,8 @@ async def handle_request(
runtime: Runtime,
route_map: routes.Mapper,
scope: Mapping[str, Any],
receive: Callable[[], Awaitable],
send: Callable[[Mapping[str, Any]], Awaitable]
receive: Callable[[], IO],
send: Callable[[Mapping[str, Any]], IO]
) -> None:
scope_ = Scope(
type=ScopeType(scope['type']),
Expand Down
9 changes: 5 additions & 4 deletions solo/server/io_manager.py
@@ -1,6 +1,7 @@
import logging
from typing import NamedTuple, Optional, Mapping, Awaitable, Callable, TypeVar, Any

from solo.types import IO
from solo.vendor.old_session.old_session import SessionStore

from solo.configurator.registry import Registry
Expand All @@ -26,7 +27,7 @@ def __init__(self,
self.loop = loop
self.server = None
self.runtime: Optional[Runtime] = None
self.do_io: Callable[[Awaitable[T]], T] = self.loop.run_until_complete
self.do_io: Callable[[IO[T]], T] = self.loop.run_until_complete

def create_server(self, ssl: Optional[bool] = None):
log.debug('Creating a new web server...')
Expand Down Expand Up @@ -93,9 +94,9 @@ def __exit__(self, exc_type, exc_val, exc_tb) -> None:

async def __call__(self,
scope: Mapping[str, str],
receive: Callable[[], Awaitable],
send: Callable[[Mapping[str, Any]], Awaitable]
) -> Awaitable:
receive: Callable[[], IO],
send: Callable[[Mapping[str, Any]], IO]
) -> IO:
return await handle_request ( runtime = self.runtime
, route_map = self.app.route_map
, scope = scope
Expand Down
4 changes: 2 additions & 2 deletions solo/server/memstore.py
@@ -1,13 +1,13 @@
import asyncio
from typing import Awaitable

import aioredis

from ..config.app import Config
from ..types import IO


def init_pool(loop: asyncio.AbstractEventLoop,
config: Config) -> Awaitable[aioredis.commands.Redis]:
config: Config) -> IO[aioredis.commands.Redis]:
c = config.redis
address = (c.host, c.port)
pool = aioredis.create_redis_pool(
Expand Down
3 changes: 2 additions & 1 deletion solo/server/runtime/dependencies.py
Expand Up @@ -6,6 +6,7 @@
from solo.configurator.registry import Registry
from solo.server.db.types import SQLEngine
from solo.server.request import Request
from solo.types import IO
from solo.vendor.old_session.old_session import Session, SessionStore


Expand All @@ -20,7 +21,7 @@ def get_handler_deps(
runtime: Runtime,
handler: Callable,
request: Request,
) -> Tuple[Mapping[str, Awaitable], Mapping[str, Any]]:
) -> Tuple[Mapping[str, IO], Mapping[str, Any]]:
""" Returns a tuple of awaitable coroutine dependencies and rest dependencies.
"""
hints = get_type_hints(handler)
Expand Down
3 changes: 2 additions & 1 deletion solo/testutils.py
Expand Up @@ -5,6 +5,7 @@

from solo.server.io_manager import AIOManager
from.server.definitions import HttpMethod
from .types import IO


class TestClient:
Expand All @@ -14,7 +15,7 @@ def __init__(self, app_manager: AIOManager, pool=lowhaio.Pool):

def get(self, url: str,
headers: Mapping[str, str] = pmap({}),
payload: Optional[Type] = None) -> Awaitable[Tuple[int, Mapping, Iterator]]:
payload: Optional[Type] = None) -> IO[Tuple[int, Mapping, Iterator]]:
return self.make_request(
url=url,
method=HttpMethod.GET,
Expand Down
3 changes: 3 additions & 0 deletions solo/types.py
@@ -0,0 +1,3 @@
from typing import Awaitable

IO = Awaitable
3 changes: 2 additions & 1 deletion solo/vendor/old_session/old_session.py
Expand Up @@ -16,6 +16,7 @@
from solo.server.request import Request
from solo.server.response import Response
from solo.server.statuses import HttpStatus
from solo.types import IO


class Session(MutableMapping):
Expand Down Expand Up @@ -149,7 +150,7 @@ async def new_session(request: Request):
return session


def setup(storage: 'SessionStore') -> Callable[[Request], Awaitable[Session]]:
def setup(storage: 'SessionStore') -> Callable[[Request], IO[Session]]:
async def factory(request: Request):
request[STORAGE_KEY] = storage
raise_response = False
Expand Down

0 comments on commit 5678ca7

Please sign in to comment.