Moved the use of the ``__file__`` attribute at the base of the Alembic
package into the one place that it is specifically needed, which is when
the config attempts to locate the template directory. This helps to allow
Alembic to be fully importable in environments that are using Python
memory-only import schemes. Pull request courtesy layday.
Partially-fixes: #648
Closes: #651
Pull-request: https://github.com/sqlalchemy/alembic/pull/651
Pull-request-sha:
c30299dbc3499c59e81602d91deb3b03166b4583
Change-Id: I2607031d80c418ce4d7e779eeb42c57a53a72ce0
-from os import path
import sys
from . import context # noqa
__version__ = '1.3.4'
-package_dir = path.abspath(path.dirname(__file__))
-
sys.modules["alembic.migration"] = migration
sys.modules["alembic.environment"] = environment
import sys
from . import command
-from . import package_dir
from . import util
from .util import compat
from .util.compat import SafeConfigParser
commands.
"""
+ import alembic
+
+ package_dir = os.path.abspath(os.path.dirname(alembic.__file__))
return os.path.join(package_dir, "templates")
def get_section(self, name, default=None):
--- /dev/null
+.. change::
+ :tags: usecase, environment
+ :tickets: 648
+
+ Moved the use of the ``__file__`` attribute at the base of the Alembic
+ package into the one place that it is specifically needed, which is when
+ the config attempts to locate the template directory. This helps to allow
+ Alembic to be fully importable in environments that are using Python
+ memory-only import schemes. Pull request courtesy layday.