Running bindepend.py and 'utils' scripts - broken in current trunk

30 views
Skip to first unread message

Florian Höch

unread,
Feb 28, 2011, 11:42:09 AM2/28/11
to pyins...@googlegroups.com
I noticed that running bindepend.py or the scripts in 'utils' is broken
in the current trunk, it fails with an ImportError 'No module named
PyInstaller' (for now, I hacked around this in my local copy by fudging
with sys.path).

Regards
--
Florian Höch

Hartmut Goebel

unread,
Feb 28, 2011, 2:32:45 PM2/28/11
to pyins...@googlegroups.com
The script in utils are meant to be run from the PyInstaller main
directory. This should work, if the current directory is on your
$PYTHONPATH.

Changing the scripts and hacking sys.path is not a good idea. You should
use $PYTHONPATH for this. This is what it is meant for.

--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/
Goebel Consult mit Mitglied bei http://www.7-it.de


Florian Höch

unread,
Feb 28, 2011, 2:54:04 PM2/28/11
to pyins...@googlegroups.com
Am 28.02.2011 20:32, schrieb Hartmut Goebel:
> Am 28.02.2011 17:42, schrieb Florian Höch:
>> I noticed that running bindepend.py or the scripts in 'utils' is
>> broken in the current trunk, it fails with an ImportError 'No module
>> named PyInstaller' (for now, I hacked around this in my local copy by
>> fudging with sys.path).
> The script in utils are meant to be run from the PyInstaller main
> directory. This should work, if the current directory is on your
> $PYTHONPATH.

Yes, adding it to PYTHONPATH works, but isn't very intuitive imho. Maybe
adding some other options to pyinstaller.py could be another
possibility? E.g.

pyinstaller.py --bindepend <binary>
pyinstaller.py --viewarchive <binary>
etc.

> Changing the scripts and hacking sys.path is not a good idea. You should
> use $PYTHONPATH for this. This is what it is meant for.

That's why I called it a hack :) I think I'd prefer something like my
above suggestion.

Regards
--
Florian Höch

Hartmut Goebel

unread,
Feb 28, 2011, 3:36:47 PM2/28/11
to pyins...@googlegroups.com
Am 28.02.2011 20:54, schrieb Florian Höch:
> Yes, adding it to PYTHONPATH works, but isn't very intuitive imho.
> Maybe adding some other options to pyinstaller.py could be another
> possibility? E.g.
>
> pyinstaller.py --bindepend <binary>
> pyinstaller.py --viewarchive <binary>
> etc.
Now this is a real hack!

The problem is you are running on Windows, from the "wrong" directory.
Are you using the GUI (Windows explorer), or are you working from
command line?

So one solution could be adding a .bat file. But this would require a
.bat for each of the files in utils. So the better solution is to just
run from the PyInstaller main directory like this:

python utils\bindepend.py

BTW: pyinstaller.py does not use any any "binary", but uses modules
imported from package PyInstaller (which is located in directory
PyInstaller)

Florian Höch

unread,
Feb 28, 2011, 4:06:53 PM2/28/11
to pyins...@googlegroups.com
Am 28.02.2011 21:36, schrieb Hartmut Goebel:
> Am 28.02.2011 20:54, schrieb Florian Höch:
>> Yes, adding it to PYTHONPATH works, but isn't very intuitive imho.
>> Maybe adding some other options to pyinstaller.py could be another
>> possibility? E.g.
>>
>> pyinstaller.py --bindepend<binary>
>> pyinstaller.py --viewarchive<binary>
>> etc.
> Now this is a real hack!

I guess the list got rid of the spaces that were originally there. It
should read like this (hope the list won't mangle it again):

pyinstaller.py --bindepend binary
pyinstaller.py --viewarchive binary

(there should now hopefully be spaces between the option and the 'binary')

> The problem is you are running on Windows, from the "wrong" directory.
> Are you using the GUI (Windows explorer), or are you working from
> command line?

Command line, from the 'root' pyinstaller directory (not the
'PyInstaller' module subdirectory).

> So one solution could be adding a .bat file. But this would require a
> .bat for each of the files in utils. So the better solution is to just
> run from the PyInstaller main directory like this:
>
> python utils\bindepend.py

Yes, but this only works if the pyinstaller root directory is on
PYTHONPATH. Not a big problem of course, but personally I do not often
(have to) change PYTHONPATH and have a tendency to forget about it after
a while when I do, which then leads to certain things working for me but
not for others etc. pp. That's why I don't really like changing it, but
it's only personal preference.

> BTW: pyinstaller.py does not use any any "binary", but uses modules
> imported from package PyInstaller (which is located in directory
> PyInstaller)

Sure, but how does that relate to my suggestion? Sorry I don't understand.

Regards
--
Florian Höch

Hartmut Goebel

unread,
Mar 1, 2011, 6:56:26 AM3/1/11
to pyins...@googlegroups.com
Am 28.02.2011 22:06, schrieb Florian Höch:
> Command line, from the 'root' pyinstaller directory (not the
> 'PyInstaller' module subdirectory).
IC, But I do not understand what is happening here.

No, stop, *aaaaaahhhhhh* It's Windows! Windows ignores case in filenames
*aaahhhh*

The scripts in utils try to import e.g. PyInstaller.bindepend. But since
Windows uses case-insensitive filenames, the file pyinstaller.py gets
loaded instead of PyInstaller/__init__.py (and further on
PyInstaller/bindepend.py)

Please run
python -v -c 'import PyInstaller.bindepend'

and post the relevant lines (after the Python interactive startup
message) here.

On my machine this looks like:

Python 2.6.5 (r265:79063, Oct 29 2010, 14:35:07)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import PyInstaller # directory PyInstaller
import PyInstaller # from PyInstaller/__init__.py
import PyInstaller.bindepend # from PyInstaller/bindepend.py

--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen

http://www.goebel-consult.de/blog

Monatliche Kolumne: http://www.cissp-gefluester.de/aktuelle

Florian Höch

unread,
Mar 1, 2011, 7:14:24 AM3/1/11
to pyins...@googlegroups.com
Am 01.03.2011 12:56, schrieb Hartmut Goebel:
> Am 28.02.2011 22:06, schrieb Florian Höch:
>> Command line, from the 'root' pyinstaller directory (not the
>> 'PyInstaller' module subdirectory).
> IC, But I do not understand what is happening here.
>
> No, stop, *aaaaaahhhhhh* It's Windows! Windows ignores case in filenames
> *aaahhhh*
>
> The scripts in utils try to import e.g. PyInstaller.bindepend. But since
> Windows uses case-insensitive filenames, the file pyinstaller.py gets
> loaded instead of PyInstaller/__init__.py (and further on
> PyInstaller/bindepend.py)
>
> Please run
> python -v -c 'import PyInstaller.bindepend'
>
> and post the relevant lines (after the Python interactive startup
> message) here.
>
> On my machine this looks like:
>
> Python 2.6.5 (r265:79063, Oct 29 2010, 14:35:07)
> [GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> import PyInstaller # directory PyInstaller
> import PyInstaller # from PyInstaller/__init__.py
> import PyInstaller.bindepend # from PyInstaller/bindepend.py

Ok, I get:

Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit
(Intel)] on win32


Type "help", "copyright", "credits" or "license" for more information.
import PyInstaller # directory PyInstaller

# PyInstaller\__init__.pyc matches PyInstaller\__init__.py
import PyInstaller # precompiled from PyInstaller\__init__.pyc
# PyInstaller\bindepend.pyc matches PyInstaller\bindepend.py
import PyInstaller.bindepend # precompiled from PyInstaller\bindepend.pyc

Regards
--
Florian Höch

Hartmut Goebel

unread,
Mar 1, 2011, 9:43:35 AM3/1/11
to pyins...@googlegroups.com
Am 01.03.2011 13:14, schrieb Florian Höch:
> Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> import PyInstaller # directory PyInstaller
> # PyInstaller\__init__.pyc matches PyInstaller\__init__.py
> import PyInstaller # precompiled from PyInstaller\__init__.pyc
> # PyInstaller\bindepend.pyc matches PyInstaller\bindepend.py
> import PyInstaller.bindepend # precompiled from PyInstaller\bindepend.pyc
This looks okay.

What is the output if you are running python -v utils\bindepend.py

--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen

http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/

Florian Höch

unread,
Mar 1, 2011, 1:30:16 PM3/1/11
to pyins...@googlegroups.com
Am 01.03.2011 15:43, schrieb Hartmut Goebel:
> What is the output if you are running python -v utils\bindepend.py

(Should that file exist there? In my local copy and also in SVN, it's in
PyInstaller)

python -v PyInstaller\bindepend.py

Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import time # builtin
# C:\Python26\lib\string.pyc matches C:\Python26\lib\string.py
import string # precompiled from C:\Python26\lib\string.pyc
import strop # builtin
# C:\Python26\lib\glob.pyc matches C:\Python26\lib\glob.py
import glob # precompiled from C:\Python26\lib\glob.pyc
# C:\Python26\lib\fnmatch.pyc matches C:\Python26\lib\fnmatch.py
import fnmatch # precompiled from C:\Python26\lib\fnmatch.pyc
# C:\Python26\lib\traceback.pyc matches C:\Python26\lib\traceback.py
import traceback # precompiled from C:\Python26\lib\traceback.pyc
Traceback (most recent call last):
File "PyInstaller\bindepend.py", line 42, in <module>
from PyInstaller import is_win, is_cygwin, is_darwin, is_py26


ImportError: No module named PyInstaller

Regards
--
Florian Höch

Hartmut Goebel

unread,
Mar 1, 2011, 2:09:34 PM3/1/11
to pyins...@googlegroups.com
Am 01.03.2011 19:30, schrieb Florian Höch:
> Am 01.03.2011 15:43, schrieb Hartmut Goebel:
>> What is the output if you are running python -v utils\bindepend.py
>
> (Should that file exist there? In my local copy and also in SVN, it's
> in PyInstaller)

Sorry, this should have been on of the scripts, e.g.:

python -v utils\Build.py

Florian Höch

unread,
Mar 1, 2011, 2:22:28 PM3/1/11
to pyins...@googlegroups.com
Am 01.03.2011 20:09, schrieb Hartmut Goebel:
> Am 01.03.2011 19:30, schrieb Florian Höch:
>> Am 01.03.2011 15:43, schrieb Hartmut Goebel:
>>> What is the output if you are running python -v utils\bindepend.py
>>
>> (Should that file exist there? In my local copy and also in SVN, it's
>> in PyInstaller)
>
> Sorry, this should have been on of the scripts, e.g.:
>
> python -v utils\Build.py

Ah, ok.

Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.

Traceback (most recent call last):

File "utils\Build.py", line 22, in <module>
import PyInstaller.build
ImportError: No module named PyInstaller.build

Regards
--
Florian Höch

Hartmut Goebel

unread,
Mar 1, 2011, 3:17:02 PM3/1/11
to pyins...@googlegroups.com
Am 01.03.2011 20:22, schrieb Florian Höch:
>> python -v utils\Build.py
>
> Ah, ok.
Please mind the -v switch. I want to see, where your python looks for
PyInstaller.build.

Florian Höch

unread,
Mar 1, 2011, 6:17:31 PM3/1/11
to pyins...@googlegroups.com
Am 01.03.2011 21:17, schrieb Hartmut Goebel:
> Am 01.03.2011 20:22, schrieb Florian Höch:
>>> python -v utils\Build.py
>>
>> Ah, ok.
> Please mind the -v switch. I want to see, where your python looks for
> PyInstaller.build.

Ok, here is the complete output:

python -v utils\Build.py
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# C:\Python26\lib\site.pyc matches C:\Python26\lib\site.py
import site # precompiled from C:\Python26\lib\site.pyc
# C:\Python26\lib\os.pyc matches C:\Python26\lib\os.py
import os # precompiled from C:\Python26\lib\os.pyc
import errno # builtin
import nt # builtin
# C:\Python26\lib\ntpath.pyc matches C:\Python26\lib\ntpath.py
import ntpath # precompiled from C:\Python26\lib\ntpath.pyc
# C:\Python26\lib\stat.pyc matches C:\Python26\lib\stat.py
import stat # precompiled from C:\Python26\lib\stat.pyc
# C:\Python26\lib\genericpath.pyc matches C:\Python26\lib\genericpath.py
import genericpath # precompiled from C:\Python26\lib\genericpath.pyc
# C:\Python26\lib\warnings.pyc matches C:\Python26\lib\warnings.py
import warnings # precompiled from C:\Python26\lib\warnings.pyc
# C:\Python26\lib\linecache.pyc matches C:\Python26\lib\linecache.py
import linecache # precompiled from C:\Python26\lib\linecache.pyc
# C:\Python26\lib\types.pyc matches C:\Python26\lib\types.py
import types # precompiled from C:\Python26\lib\types.pyc
# C:\Python26\lib\UserDict.pyc matches C:\Python26\lib\UserDict.py
import UserDict # precompiled from C:\Python26\lib\UserDict.pyc
# C:\Python26\lib\_abcoll.pyc matches C:\Python26\lib\_abcoll.py
import _abcoll # precompiled from C:\Python26\lib\_abcoll.pyc
# C:\Python26\lib\abc.pyc matches C:\Python26\lib\abc.py
import abc # precompiled from C:\Python26\lib\abc.pyc
# C:\Python26\lib\copy_reg.pyc matches C:\Python26\lib\copy_reg.py
import copy_reg # precompiled from C:\Python26\lib\copy_reg.pyc
# zipimport: found 78 names in
C:\Python26\lib\site-packages\setuptools-0.6c11-py2.6.egg
# zipimport: found 9 names in
C:\Python26\lib\site-packages\pefile-1.2.10_63-py2.6.egg
# zipimport: found 21 names in
C:\Python26\lib\site-packages\altgraph-0.6.7-py2.6.egg
# zipimport: found 90 names in
C:\Python26\lib\site-packages\pycrypto-2.0.1-py2.6-win32.egg
# zipimport: found 60 names in
C:\Python26\lib\site-packages\mechanize-0.1.11-py2.6.egg
# zipimport: found 7 names in
C:\Python26\lib\site-packages\clientform-0.2.10-py2.6.egg
# zipimport: found 14 names in
C:\Python26\lib\site-packages\modulegraph-0.7.3-py2.6.egg
# C:\Python26\lib\locale.pyc matches C:\Python26\lib\locale.py
import locale # precompiled from C:\Python26\lib\locale.pyc
import encodings # directory C:\Python26\lib\encodings
# C:\Python26\lib\encodings\__init__.pyc matches
C:\Python26\lib\encodings\__init__.py
import encodings # precompiled from C:\Python26\lib\encodings\__init__.pyc
# C:\Python26\lib\codecs.pyc matches C:\Python26\lib\codecs.py
import codecs # precompiled from C:\Python26\lib\codecs.pyc
import _codecs # builtin
# C:\Python26\lib\encodings\aliases.pyc matches
C:\Python26\lib\encodings\aliases.py
import encodings.aliases # precompiled from
C:\Python26\lib\encodings\aliases.pyc
# C:\Python26\lib\functools.pyc matches C:\Python26\lib\functools.py
import functools # precompiled from C:\Python26\lib\functools.pyc
import _functools # builtin
import _locale # builtin
# C:\Python26\lib\re.pyc matches C:\Python26\lib\re.py
import re # precompiled from C:\Python26\lib\re.pyc
# C:\Python26\lib\sre_compile.pyc matches C:\Python26\lib\sre_compile.py
import sre_compile # precompiled from C:\Python26\lib\sre_compile.pyc
import _sre # builtin
# C:\Python26\lib\sre_parse.pyc matches C:\Python26\lib\sre_parse.py
import sre_parse # precompiled from C:\Python26\lib\sre_parse.pyc
# C:\Python26\lib\sre_constants.pyc matches C:\Python26\lib\sre_constants.py
import sre_constants # precompiled from C:\Python26\lib\sre_constants.pyc
import operator # builtin
# C:\Python26\lib\encodings\cp1252.pyc matches
C:\Python26\lib\encodings\cp1252.py
import encodings.cp1252 # precompiled from
C:\Python26\lib\encodings\cp1252.pyc


Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
File "utils\Build.py", line 22, in <module>
import PyInstaller.build
ImportError: No module named PyInstaller.build

# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# clear sys.flags
# clear sys.float_info
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] locale
# cleanup[1] functools
# cleanup[1] encodings
# cleanup[1] site
# cleanup[1] operator
# cleanup[1] abc
# cleanup[1] sre_constants
# cleanup[1] re
# cleanup[1] _codecs
# cleanup[1] nt
# cleanup[1] _warnings
# cleanup[1] zipimport
# cleanup[1] encodings.cp1252
# cleanup[1] codecs
# cleanup[1] _functools
# cleanup[1] _locale
# cleanup[1] signal
# cleanup[1] encodings.aliases
# cleanup[1] exceptions
# cleanup[1] sre_compile
# cleanup[1] _sre
# cleanup[1] sre_parse
# cleanup[2] copy_reg
# cleanup[2] types
# cleanup[2] errno
# cleanup[2] _abcoll
# cleanup[2] ntpath
# cleanup[2] genericpath
# cleanup[2] stat
# cleanup[2] warnings
# cleanup[2] UserDict
# cleanup[2] os.path
# cleanup[2] linecache
# cleanup[2] os
# cleanup sys
# cleanup __builtin__
# cleanup ints: 1635 unfreed ints
# cleanup floats

Regards
--
Florian Höch

Hartmut Goebel

unread,
Mar 2, 2011, 5:12:03 AM3/2/11
to pyins...@googlegroups.com
Am 02.03.2011 00:17, schrieb Florian Höch:
Am 01.03.2011 21:17, schrieb Hartmut Goebel:
Am 01.03.2011 20:22, schrieb Florian Höch:
python -v utils\Build.py

Ah, ok.
Please mind the -v switch. I want to see, where your python looks for
PyInstaller.build.

Ok, here is the complete output:
Thanks. Unfortunately this doe not give any useful information to me. Even more, it continues to confuse me. Especially since

python -v -c 'import PyInstaller.bindepend' 
works, but
python -v utils\Build.py
does not. According to <http://docs.python.org/tutorial/modules.html#the-module-search-path> this should work.

So I can only imagine, either the current dir is different or sys.path is different.

Please temporary add these lines to the top of utils\Build.py:
import sys, os
print os.getcwd()
print sys.path
and start it using the switches -s and -S (do avoid loading site.py):
python -sS utils\Build.py
You may also check the output of
python -sSc 'import sys; print sys.path'
Anything helpful there?

Hartmut Goebel

unread,
Mar 2, 2011, 5:26:42 AM3/2/11
to pyins...@googlegroups.com
Am -10.01.-28163 20:59, schrieb Hartmut Goebel:

So I can only imagine, either the current dir is different or sys.path is different.
Okay, I think, I found the reason: <http://bytes.com/topic/python/answers/608227-2-4-2-5-current-directory-change> Explains it well.

This works fine here, since I have the current dir on PYTHONPATH and by tests were wrong:
PYTHONPATH= python -sS  utils/Build.py
works, but this put "" (the current dir) on sys.path
$ PYTHONPATH=/tmp python -sS  utils/Build.py
Traceback (most recent call last):
  File "utils/Build.py", line 22, in <module>
    import PyInstaller.build
ImportError: No module named PyInstaller.build
Now this fails as you experienced.

So first of all I'm change all my startup scripts to not pout an empty component into PYTHONPATH

Then we'll think about a  solution :-)

Hartmut Goebel

unread,
Mar 2, 2011, 5:53:38 AM3/2/11
to pyins...@googlegroups.com
Am 02.03.2011 11:26, schrieb Hartmut Goebel:
Then we'll think about a  solution :-)
Florian,

I think I have a quite proper solution: Please add these lines to the top of Build.py and try again:
try:
    import PyInstaller
except ImportError:
    import imp, os
    imp.load_module('PyInstaller', *imp.find_module('PyInstaller', ["."]))
    imp.load_module('hooks', *imp.find_module('hooks', ["."]))
(The 'hooks' line is required since 'hooks' are imported, too :-(

Florian Höch

unread,
Mar 2, 2011, 10:37:15 AM3/2/11
to pyins...@googlegroups.com
Am 02.03.2011 11:53, schrieb Hartmut Goebel:
> Am 02.03.2011 11:26, schrieb Hartmut Goebel:
>> Then we'll think about a solution :-)
> Florian,
>
> I think I have a quite proper solution: Please add these lines to the
> top of Build.py and try again:
>
> try:
> import PyInstaller
> except ImportError:
> import imp, os
> imp.load_module('PyInstaller', *imp.find_module('PyInstaller', ["."]))
> imp.load_module('hooks', *imp.find_module('hooks', ["."]))
>
> (The 'hooks' line is required since 'hooks' are imported, too :-(

Yes, it's working now :)

Regards
--
Florian Höch

Hartmut Goebel

unread,
Mar 2, 2011, 10:45:00 AM3/2/11
to pyins...@googlegroups.com
Am 02.03.2011 16:37, schrieb Florian Höch:
>
> Yes, it's working now :)
Glad am I :-) I'll be implementing such in all the scripts the next days.
Reply all
Reply to author
Forward
0 new messages