[Pythonmac-SIG] Error with modulegraph when using python script without knowed python extensions

Olivier Hervieu olivier.hervieu at wallix.com
Tue Jan 27 18:02:00 CET 2009


Hi all.

I've got a python module who looks like this :

MY_PYTHON_MODULE:
  |_ setup.py
  |_ PYTHON_SOURCE/
      |_lots_of.py
  |_ PYTHON_SCRIPTS/
      |_MyScript


with setuptools a "python setup.py install" install the PYTHON_SOURCE in 
site-package of my python installation, and PYTHON_SCRIPTS are installed 
in the "install_prefix/bin".

So MyScript is already in the path, and is saw, by the user, as a 
"binary". There's a lots of python programs installed like this (like 
"spe", the python editor) on Linux.

I want now to have a Mac Port of my program. So i try py2app!

My application is, indeed, "MyScript"

But, when i run "python setup.py py2app", i have the following error 
from the find_modules.py of modulegraph tool:

line 86, in parse_mf_results
>>     raise TypeError("Don't know how to handle '%s'" % repr(src))


After a look in find_modules.py, i see that a PY_SUFFIXES list is used 
to determine which is python code and wich is not... And unfortunately, 
with a python script with no extension, it raise the previous error.

I think that, for files without extension, a detection based on 
mimetypes will be helpfull...

so, in find_modules.py, by adding


type, encoding =mimetypes.guess_type(__MY_FILE__)
if encoding == 'text/x-python':
    py_files.append(item)

will fix this problem. What did you think about that?

I have contacted the developer of modulegraph before.. but it seems that 
the support of this module is provide by people on this mailing list.



Regards,

Olivier.


More information about the Pythonmac-SIG mailing list