sqlalchemy-migrate and py2exe

130 views
Skip to first unread message

Emanuele Gesuato

unread,
Jul 17, 2010, 7:12:44 AM7/17/10
to migrate-users
Hi there,

I'm using python 2.5, sqlachemy 0.5 and sqlalchemy-migrate 0.6.
I'm trying to add the migration facility to desktop program that i
want to deliver as exe so i'm using py2exe and i'm having trouble
integrating migrate to py2exe.

The exe seems to be created correctly but when i start it i got the
error
Traceback (most recent call last):
File "sagra.py", line 8, in <module>
File "amministrazione.pyc", line 7, in <module>
File "bo.pyc", line 4, in <module>
File "database.pyc", line 22, in <module>
File "<string>", line 2, in create
File "migrate\versioning\util\__init__.pyc", line 90, in
catch_known_errors
File "migrate\versioning\api.pyc", line 94, in create
File "migrate\versioning\repository.pyc", line 134, in create
File "migrate\versioning\template.pyc", line 45, in __new__
File "migrate\versioning\template.pyc", line 63, in _find_path
File "pkg_resources.pyc", line 841, in resource_filename
File "pkg_resources.pyc", line 1303, in get_resource_filename
NotImplementedError: resource_filename() only supported for .egg,
not .zip


In "template.py" at row 63 there is the line
return resource_filename(tmp_pkg[0], tmp_pkg[1])

and it seems that it cannot create the repository (a directory) from a
zip file.
The error is when i try to do this:
migrate.versioning.api.create('db_repository', 'db_repository')

If i run the same piece of code from shell it runs fine, but it seems
having problems on .exe.

How should i fix that ?

Thanks for any help


Domen Kožar

unread,
Aug 6, 2010, 9:44:05 AM8/6/10
to migrate-users
Hey,

setuptools provides tools like resource_filename which finds filename
you are looking for in your package (which might be an egg - basically
zip). I have no idea how py2exe works, but here is some information
about the issue:

http://old.nabble.com/resource_filename()-breaks-cxfreeze-(py2exe-)-td1104344.html

If you provide a patch with tests I'm willing to improve codebase on
that level.

Domen

On Jul 17, 1:12 pm, Emanuele Gesuato <emanuele.gesu...@gmail.com>
wrote:

Emanuele Gesuato

unread,
Jan 16, 2011, 9:11:53 AM1/16/11
to migrat...@googlegroups.com
Hi there,

I'm sorry to revive this thread after several time but i've got busy
months ago.

py2exe simply "packs" all the python resources inside a zip file
called "library.zip" that you have to redistribute with your exe.
Inside this zip there are the pyc of sqlalchemy and obviously
sqlalchemy-migrate.

Right now i've added in the zip the repository with the migration
scripts used to migrate my application. When i start the application
and "upgrade" gets executed
i got the following error:
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

obviously it doesn't search inside the "library.zip" for the
repository.
The code that gets the error is the following (in 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)

and i don't know how to change this for searching the repository
inside the zip generated by library.zip.

Thanks for any help.


---------- Forwarded message ----------
From: Domen Kožar <ielect...@gmail.com>
Date: 6 Ago 2010, 14:44
Subject: sqlalchemy-migrate and py2exe
To: migrate-users


Hey,

setuptools provides tools like resource_filename which finds filename
you are looking for in your package (which might be an egg - basically

zip). I have no idea howpy2exeworks, but here is some information
about the issue:

http://old.nabble.com/resource_filename()-breaks-cxfreeze-(py2exe-)-t...

If you provide a patch with tests I'm willing to improve codebase on
that level.

Domen

On Jul 17, 1:12 pm, Emanuele Gesuato <emanuele.gesu...@gmail.com>
wrote:

> Hi there,

> I'm using python 2.5, sqlachemy 0.5 and sqlalchemy-migrate 0.6.
> I'm trying to add the migration facility to desktop program that i

> want to deliver as exe so i'm usingpy2exeand i'm having trouble

Reply all
Reply to author
Forward
0 new messages