agronholm/sqlacodegen

Entry point documentation

robcresswell opened this issue · 0 comments

Things to check first

  • I have searched the existing issues and didn't find my feature already requested there

Feature description

Would it be possible to elaborate on, or provide an example of entry point usage with an external package? I've been quite keen to extend sqlacodegen but cannot get a working setup with the entry points; any generator I write simply doesn't show up in the list of valid generators when I try to use it with --generator.

I've currently got sqlcodegen working well in one project and generating as I'd expect. In a neighbouring directory I've got

./gen
├── README.md
├── poetry.lock
├── pyproject.toml
└── src
    └── gen
        ├── __init__.py
        └── generator.py

where the contents of the pyproject.toml are

[project]
name = "gen"

[project.entry-points."sqlacodegen.generators"]
api = "gen.generator:Generator"

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

[tool.poetry]
name = "gen"
version = "0.1.0"
description = ""
authors = ["Rob Cresswell <robcresswell@users.noreply.github.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
sqlacodegen = "^3.0.0rc3"

and the contents of generator.py are

from sqlacodegen.generators import CodeGenerator


class Generator(CodeGenerator):
    def generate(self) -> str:
        print(">>> Generating! <<<")

        return ""

I'm aware this is entirely my fault, but I've really no idea how I could make this more simple, and my Google-fu is failing to give me any simple way to debug this part of the Python toolchain

Use case

Same as above