2

According to the docs, alembic's template can be specified as alembic init --template pylons ./scripts. But alembic searches for templates in only one folder in its root (python_path/lib/python2.7/site-packages/alembic/templates).

Is there any way to run custom templates? The idea of the question - automatization of project setup e.g. avoiding any handmade changes (like editing env.py file).

AlexanderLedovsky
  • 727
  • 1
  • 6
  • 18

1 Answers1

3

As I can see in Alembic sources there is no way to customize template directory location. Template directory is gotten by Config.get_template_directory() and is used by list_templates().

Although you can try to use monkey patch:

from alembic.config import Config

def get_template_directory(self):
    return "my/custom/template/directory"

Config.get_template_directory = get_template_directory

# Invoke Alembic code

P.S. I wonder why Alembic doesn't use entry points for collecting available templates.

Dmitry Vakhrushev
  • 1,382
  • 8
  • 12