开发者

Making exe using py2exe + sqlalchemy + mssql

I have a problem with making exe using py2exe. In my project i'm using sqlalchemy with mssql module. My setup.py script looks like:

from distutils.core import setup
import py2exe


setup(
  windows=[{"script" : "pyrmsutil.py"}],
  options={"pyrmsutil" : {
    "includes": ["sqlalchemy.dialects.mssql", "sqlalchemy"],
    "packages": ["sqlalchemy.databases.mssql", "sqlalchemy.cresultproxy"]
}})

But when i'm starting procedure like: python.exe setup.py py2exe

I'm receiving build log with following errors: The fo开发者_C百科llowing modules appear to be missing ['_scproxy', 'pkg_resources', 'sqlalchemy.cprocessors', 'sqlalchemy.cresultproxy']

And in "dist" folder i see my pyrmsutil.exe file, but when i'm running it nothing happens. I mean that executable file starts, but do nothing and ends immediately without any pyrmsutil.exe.log. It's very strange.

Can anybody help me with this error?


I know it's no an answer per se but have you tries pyInstaller? I used to use py2exe and found it tricky to get something truly distributable. pyInstaller requires a little more setup but the docs are good and the result seems better.

For solving this issue you could try searching for the mentioned dlls and placing them in the folder with the exe, or where you build it.


Looks like py2exe can't find sqlalchemy c extensions.

Why not just include the egg in the distribution, put sqlachemy in py2exe's excludes and load the egg on start?

I use this in the start script:

import sys
import path
import pkg_resources

APP_HOME = path.path(sys.executable).parent
SUPPORT = APP_HOME / 'support'

eggs = [egg for egg in SUPPORT.files('*.egg')]
reqs, errs = pkg_resources.working_set.find_plugins(
    pkg_resources.Environment(eggs)
)
map(pkg_resources.working_set.add, reqs)

sys.path.extend(SUPPORT.files('*.egg'))

i use Jason Orendorff's path module (http://pypi.python.org/pypi/path.py) but you can easily wipe it out if you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜