python-gino / gino

GINO Is Not ORM - a Python asyncio ORM on SQLAlchemy core.
https://python-gino.org/
Other
2.67k stars 150 forks source link

Following the tutorial 'Build a FastAPI Server' fails at the second step... #802

Open coredevel opened 2 years ago

coredevel commented 2 years ago

Able to setup a new poetry project and install gino[starlette] but then following the next step to install fastapi, uvicorn & gunicorn results in an error:


$ poetry add gino[starlette]
Using version ^1.0.1 for gino

Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Package operations: 8 installs, 0 updates, 0 removals

  • Installing idna (3.3)
  • Installing sniffio (1.2.0)
  • Installing anyio (3.5.0)
  • Installing gino (1.0.1)
  • Installing starlette (0.16.0)
  • Installing asyncpg (0.25.0)
  • Installing gino-starlette (0.1.3)
  • Installing sqlalchemy (1.3.24)

$ poetry add fastapi uvicorn gunicorn
Using version ^0.73.0 for fastapi
Using version ^0.17.4 for uvicorn
Using version ^20.1.0 for gunicorn

Updating dependencies
Resolving dependencies... (0.1s)

  SolverProblemError

  Because no versions of gino-starlette match >0.1.1,<0.1.2 || >0.1.2,<0.1.3 || >0.1.3,<0.2.0
   and gino-starlette (0.1.1) depends on starlette (>=0.13.0,<0.14.0), gino-starlette (>=0.1.1,<0.1.2 || >0.1.2,<0.1.3 || >0.1.3,<0.2.0) requires starlette (>=0.13.0,<0.14.0).
  And because gino-starlette (0.1.2) depends on starlette (>=0.13.0,<0.15.0)
   and gino-starlette (0.1.3) depends on starlette (>=0.16,<0.17), gino-starlette (>=0.1.1,<0.2.0) requires starlette (>=0.13.0,<0.15.0 || >=0.16,<0.17).
  Because no versions of fastapi match >0.73.0,<0.74.0
   and fastapi (0.73.0) depends on starlette (0.17.1), fastapi (>=0.73.0,<0.74.0) requires starlette (0.17.1).
  Thus, fastapi (>=0.73.0,<0.74.0) is incompatible with gino-starlette (>=0.1.1,<0.2.0).
  And because gino (1.0.1) depends on gino-starlette (>=0.1.1,<0.2.0)
   and no versions of gino match >1.0.1,<2.0.0, fastapi (>=0.73.0,<0.74.0) is incompatible with gino (>=1.0.1,<2.0.0).
  So, because gino-fastapi-demo depends on both gino (^1.0.1) and fastapi (^0.73.0), version solving failed.

  at ~/.poetry/lib/poetry/puzzle/solver.py:241 in _solve
      237│             packages = result.packages
      238│         except OverrideNeeded as e:
      239│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      240│         except SolveFailure as e:
    → 241│             raise SolverProblemError(e)
      242│ 
      243│         results = dict(
      244│             depth_first_search(
      245│                 PackageNode(self._package, packages), aggregate_package_nodes
dzerrenner commented 2 years ago

I was able to confirm that. As a wirkaround, pinning fastapi to an older version, i.e. poetry add "fastapi<0.71" proceeds with the install. The resulting part of pyproject.toml (ignore psycopg2-binary, i was too lazy to install build tools just for testing...)

[tool.poetry.dependencies]
python = "^3.10"
gino = {extras = ["starlette"], version = "^1.0.1"}
fastapi = "<0.71"
uvicorn = "^0.17.5"
alembic = "^1.7.6"
psycopg2-binary = "^2.9.3"

This takes me at least to the tutorial step where the server starts with no operations. Implications of using an older fastapi version apply.