Hi there~

I was wondering if there are known issues with pyinstaller and sqlalchemy, 
or I've encountered a new (reoccuring?) bug?

I saw this ticket:
http://www.pyinstaller.org/ticket/397 (marked fixed)

and this one:
http://www.pyinstaller.org/ticket/408 (marked fixed)

..but I'm unable to use pyinstaller on an application that uses sqlalchemy.
Any attempt results in:

6911 INFO: Analyzing main2.py
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named sqlalchemy.databases
Traceback (most recent call last):
  File "./bin/pyinstaller", line 14, in <module>
    sys.exit(PyInstaller.main.run())
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/main.py",
 
line 88, in run
    run_build(opts, spec_file, pyi_config)
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/main.py",
 
line 46, in run_build
    PyInstaller.build.main(pyi_config, spec_file, **opts.__dict__)
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/build.py",
 
line 1924, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), 
kw.get('clean_build'))
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/build.py",
 
line 1873, in build
    execfile(spec)
  File "/Users/doug/projects/kivy/junk/main2.spec", line 6, in <module>
    runtime_hooks=None)
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/build.py",
 
line 446, in __init__
    self.__postinit__()
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/build.py",
 
line 309, in __postinit__
    self.assemble()
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/build.py",
 
line 599, in assemble
    importTracker.analyze_script(script)
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/depend/imptracker.py",
 
line 273, in analyze_script
    return self.analyze_r('__main__')
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/depend/imptracker.py",
 
line 166, in analyze_r
    newnms = self.analyze_one(name, nm, imptyp, level)
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/depend/imptracker.py",
 
line 227, in analyze_one
    mod = self.doimport(nm, ctx, fqname)
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/depend/imptracker.py",
 
line 325, in doimport
    hook = imp.load_module('PyInstaller.hooks.' + hookmodnm, *m)
  File 
"/Users/doug/projects/kivy/junk/eggs/PyInstaller-2.1-py2.7.egg/PyInstaller/hooks/hook-sqlalchemy.py",
 
line 20, in <module>
    databases = eval(databases.strip())
  File "<string>", line 0

    ^

This trivial app:

import sqlalchemy
print sqlalchemy 

Compiles and runs fine.

However, this trivial app that actually uses sqlalchemy fails, both on win7 
and osx for me:

from __future__ import absolute_import
from os.path import exists
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy import Integer, Column
from sqlalchemy.orm import relationship

# Configuration constants
DATABASE_FILE = 'db.sqlite3'
DATABASE = 'sqlite:///{0}'.format(DATABASE_FILE)
DEBUG = True

def session(self):
    if self.engine is None:
        self.session_maker, self.engine = self.connect()
    if self.db is None:
        self.db = self.session_maker()
    return self.db

def rebuild(self):
    Session, engine = self.connect()
    Base.metadata.create_all(engine)

# Orm base
Base = declarative_base()

# Orm instance
orm = Orm()

# Orm class example
class Record(Base):
  __tablename__ = 'records'

  id = Column(Integer, primary_key=True)
  blah = Column(Integer, nullable=False)

# If we ever get here and the database doesn't exist, create it.
if not exists(DATABASE_FILE):
  orm.rebuild()

# Main~
if __name__ == '__main__':
  session = orm.session
  records = session.query(Record).all()
  for r in records:
    print(r)

Anyone else seeing this issue with 2.1?

Typically advice here seems to be; its broken? Try the dev version.
So I tried, but that didn't work either:

Traceback (most recent call last):
  File "./py/bin/pyinstaller", line 9, in <module>
    load_entry_point('PyInstaller==2.1', 'console_scripts', 'pyinstaller')()
  File 
"/Users/doug/projects/kivy/junk2/py/lib/python2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/main.py",
 
line 88, in run
    run_build(opts, spec_file, pyi_config)
  File 
"/Users/doug/projects/kivy/junk2/py/lib/python2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/main.py",
 
line 46, in run_build
    PyInstaller.build.main(pyi_config, spec_file, **opts.__dict__)
  File 
"/Users/doug/projects/kivy/junk2/py/lib/python2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/build.py",
 
line 1928, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), 
kw.get('clean_build'))
  File 
"/Users/doug/projects/kivy/junk2/py/lib/python2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/build.py",
 
line 1877, in build
    execfile(spec)
  File "/Users/doug/projects/kivy/junk2/main2.spec", line 6, in <module>
    runtime_hooks=None)
  File 
"/Users/doug/projects/kivy/junk2/py/lib/python2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/build.py",
 
line 446, in __init__
    self.__postinit__()
  File 
"/Users/doug/projects/kivy/junk2/py/lib/python2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/build.py",
 
line 309, in __postinit__
    self.assemble()
  File 
"/Users/doug/projects/kivy/junk2/py/lib/python2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/build.py",
 
line 700, in assemble
    for ln in importTracker.getwarnings():
  File 
"/Users/doug/projects/kivy/junk2/py/lib/python2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/depend/imptracker.py",
 
line 381, in getwarnings
    for w in mod.warnings:
TypeError: iteration over non-sequence

Ah, the (still) broken iteration of mod.warnings. Ok, well, patch the 
source for that... and then, it builds~!

...

5936 INFO: Analyzing main2.py
6277 INFO: Processing hook hook-sqlalchemy
6577 INFO: Processing hook hook-distutils
6590 INFO: Processing hook hook-parser
6601 INFO: Processing hook hook-sysconfig
6679 INFO: Processing hook hook-xml
6703 INFO: Processing hook hook-xml.sax
6742 INFO: Processing hook hook-pyexpat
7109 INFO: Processing hook hook-sqlite3
7547 INFO: Hidden import 'codecs' has been found otherwise
7547 INFO: Hidden import 'encodings' has been found otherwise
7547 INFO: Looking for run-time hooks
7548 INFO: Analyzing rthook 
/Users/doug/projects/kivy/junk2/py/lib/python2.7/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/loader/rthooks/pyi_rth_pkgres.py
7771 INFO: Using Python library 
/Users/doug/projects/kivy/junk2/py/lib/libpython2.7.dylib
7798 INFO: Warnings written to 
/Users/doug/projects/kivy/junk2/build/main2/warnmain2.txt
7811 INFO: checking PYZ
7812 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
7812 INFO: building PYZ (ZlibArchive) out00-PYZ.toc
9428 INFO: checking PKG
9429 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
9429 INFO: building PKG (CArchive) out00-PKG.pkg
12071 INFO: checking EXE
12071 INFO: rebuilding out00-EXE.toc because main2 missing
12071 INFO: building EXE from out00-EXE.toc
12073 INFO: Appending archive to EXE 
/Users/doug/projects/kivy/junk2/dist/main2
doug:junk2 doug$ ./dist/main2
Traceback (most recent call last):
  File "<string>", line 29, in <module>
NameError: name 'Orm' is not defined <---- Wat. 

So... head seems like it maybe fixes the issue with importing sqlalchemy, 
but it's broken anyway.

Anyone managed to get some success packaging sqlalchemy recently?

Cheers,
Doug.

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to