Py2exe and sqlalchemy-migrate

I am using python 2.6, sqlalchemy 0.6 for a tiny desktop application. I also use py2exe and sqlalchemy-migrate, and I'm trying to integrate migration inside exe. Thus, when the user starts the application, the database is automatically updated.

If I try to use migrate in my eclipse project, it works well, but I want to release the project itself in exe using py2exe. Unfortunately, when I run exe, I got an error:

Traceback (most recent call last):
File "sagra.py", line 7, in <module>
File "guiutil.pyc", line 3, in <module>
File "bo.pyc", line 4, in <module>
File "database.pyc", line 26, in <module>
File "<string>", line 2, in version_control
File "migrate\versioning\util\__init__.pyc", line 160, in with_engine
File "migrate\versioning\api.pyc", line 248, in version_control
File "migrate\versioning\schema.pyc", line 128, in create
File "migrate\versioning\repository.pyc", line 76, in __init__
File "migrate\versioning\repository.pyc", line 97, in verify
migrate.versioning.exceptions.InvalidRepositoryError: db_repository

but the db_repository directory and migration scripts are correctly located in the library.zip file used by py2exe to include all the python resources used by my software.

It seems sqlalchemy-migrate is not doing a zip search for the repository directory.

Here's the problem (repository.py):

def verify(cls, path):
"""
Ensure the target path is a valid repository.

:raises: :exc:`InvalidRepositoryError <migrate.versioning.exceptions.InvalidRepositoryError>`
"""
# Ensure the existence of required files
try:
    cls.require_found(path)
    cls.require_found(os.path.join(path, cls._config))
    cls.require_found(os.path.join(path, cls._versions))
except exceptions.PathNotFoundError, e:
    raise exceptions.InvalidRepositoryError(path) 

zip? -, ( ) sqlalchemy-migrate exe, py2exe?

+3

Source: https://habr.com/ru/post/1785675/


All Articles