]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Access `__file__` as part of generating template path 651/head
authorlayday <layday@protonmail.com>
Mon, 3 Feb 2020 02:09:03 +0000 (04:09 +0200)
committerlayday <layday@protonmail.com>
Mon, 3 Feb 2020 02:18:30 +0000 (04:18 +0200)
This allows importing Alembic in environments
that do not have `__file__` as discussed in #648.

Fixes: #648
alembic/__init__.py
alembic/config.py

index a63c0220b11cff9522a52442879a4ee70ab37394..4d4fbaa2134dd6067f48eddbec92437534bab4ff 100644 (file)
@@ -1,4 +1,3 @@
-from os import path
 import sys
 
 from . import context  # noqa
@@ -8,7 +7,5 @@ from .runtime import migration
 
 __version__ = '1.3.4'
 
-package_dir = path.abspath(path.dirname(__file__))
-
 sys.modules["alembic.migration"] = migration
 sys.modules["alembic.environment"] = environment
index 48c41cb861c0ffbd27973020f0aaae56323984eb..6648464422c314672317ec438bfedc02f5eb72d8 100644 (file)
@@ -4,7 +4,6 @@ import os
 import sys
 
 from . import command
-from . import package_dir
 from . import util
 from .util import compat
 from .util.compat import SafeConfigParser
@@ -210,6 +209,7 @@ class Config(object):
         commands.
 
         """
+        package_dir = os.path.abspath(os.path.dirname(__file__))
         return os.path.join(package_dir, "templates")
 
     def get_section(self, name, default=None):