Hello giovanni,

Please see attached a small patch about myopen function.
(added line 36 cast to string)
I had freezed my application but the .exe crashed while the normal python
program did not.
In fact the issue was that I was passing a QString to open.
While it was working with classical python, it was not after freezing
because QString does not have endswith method.
So to keep same behavior as classical python program I casted fn parameter
to string...
(I'm not saying that giving a Qstring to open is a good idea, just the
behavior is different :) )

What do you think about it?

Thx
Laurent  
# Copyright (C) 2005, Giovanni Bajo
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# In addition to the permissions in the GNU General Public License, the
# authors give you unlimited permission to link or embed the compiled
# version of this file into combinations with other programs, and to
# distribute those combinations without any restriction coming from the
# use of this file. (The General Public License restrictions do apply in
# other respects; for example, they cover modification of the file, and
# distribution when not linked into a combine executable.)
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA

# PyOpenGL (specifically, OpenGL.__init__) reads a "version" text file
# containing the version number to export it as OpenGL.__version__. When
# packaging with PyInstaller, the 'version' file does not exist, and importing
# PyOpenGL results in an IOError.
# The (convoluted) solution is to override Python's builtin "open" with our
# own function which detects when "version" is opened and returns some fake
# content stream (through cStringIO).

__realopen__ = open

def myopen(fn, *args):
    fn = str(fn)
    if fn.endswith("version") and ".pyz" in fn:
        # Restore original open, since we're almost done
        __builtins__.__dict__["open"] = __realopen__
        # Report a fake revision number. Anything would do since it's not
        # used by the library, but it needs to be made of four numbers
        # separated by dots.
        import cStringIO
        return cStringIO.StringIO("0.0.0.0")
    return __realopen__(fn, *args)

__builtins__.__dict__["open"] = myopen
-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyinstaller?hl=en.


Reply via email to