0

I have initialized poetry in my project. Add some libs and got this pyproject.toml:

[tool.poetry]
name = "dataapi"
version = "0.1.0"
description = "API for service."
authors = ["Claus Stolz"]

[tool.poetry.dependencies]
python = "^3.8"
gino = "^1.0.1"
fastapi = "^0.63.0"
uvicorn = "^0.13.3"
gunicorn = "^20.0.4"
alembic = "^1.5.2"
psycopg2 = "^2.8.6"
gino-starlette = "^0.1.1"

[tool.poetry.dev-dependencies]
pytest = "^6.2.1"
requests = "^2.25.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Now i try to add in pyproject.toml my own plugin to use it like entry points in code:

[tool.poetry.plugins."dataapi.modules"]
users = "dataapi.app.api.v1.endpoints.users"

Then try to use poetry install, but it give me message:

Installing dependencies from lock file

No dependencies to install or update

I try another methods of poetry: update,lock, but nothing happened. I tried to delete the lock file and then run poetry install - but it gave no results either.

I run my service to check and it give me an error:

for ep in entry_points()["dataapi.modules"]:
KeyError: 'dataapi.modules'

Method where i try to got entry points:

import logging
from importlib.metadata import entry_points

logger = logging.getLogger(__name__)

def load_modules(app=None):
    for ep in entry_points()["dataapi.modules"]:
        logger.info("Loading module: %s", ep.name)
        mod = ep.load()
        if app:
            init_app = getattr(mod, "init_app", None)
            if init_app:
                init_app(app)

I really don't understood how add plugin in poetry and need help...

Claus Stolz
  • 358
  • 4
  • 18
  • It might be a bug... What happens if you recreate the virtual environment from scratch. Or if you bump the version number? – sinoroc Jan 22 '21 at 18:28
  • Also I noticed you are missing the name of a function. The notation is `entry_point_name = top_level_package.package:function`. Instead of `function` I guess it could also be a class, or a variable, but I am pretty sure there should be a `:` and something else after. – sinoroc Jan 22 '21 at 18:35
  • If i recreate or change version number - nothing happens. – Claus Stolz Jan 22 '21 at 18:48
  • About The notation is `entry_point_name = top_level_package.package:function.`. I guess that this is not the problem. Because I want to get exactly the whole module, and not a special class or variable. – Claus Stolz Jan 22 '21 at 18:55
  • I see... -- Different approach: If you build a _sdist_ and open it, is there a `setup.py` file in the _sdist_ and how does it look like? – sinoroc Jan 22 '21 at 19:35

0 Answers0