Hi Sridhar

Your suggestion to debug this problem started me in the right path. I found a 
workaround for the issue.

First, I explicitly included distutils in my py2app bundle. With that, the 
error I get is:

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
    or: setup.py --help [cmd1 cmd2 ...]
    or: setup.py --help-commands
    or: setup.py cmd --help
    error: invalid command 'install'

I modified the included distutils files, and managed to get this stack trace

Traceback (most recent call last):
  File "distutils/dist.py", line 837, in get_command_class
    __import__ (module_name)
  File "distutils/command/install.py", line 21, in <module>
    from site import USER_BASE
cannot import name USER_BASE

The site.py included in the bundle has this comment: This is stripped down and 
customized for use in py2app applications

So apparently, py2app is removing USER_BASE and USER_SITE from site.py. I am 
not sure why it does that, but it is preventing the installation of modules 
with py2app.

I worked around it by modifying the included site.py to declare USER_BASE and 
USER_SITE after generating the .app bundle.

I think this might be a bug in py2app, but would like to know your input on 
this.

Regards,

------------------------------
Alejandro Mier y Concha


-----Original Message-----
From: Sridhar Ratnakumar [mailto:sridhar.ra...@gmail.com] 
Sent: Tuesday, January 18, 2011 11:43 AM
To: Mier, Alejandro
Cc: pythonmac-sig@python.org
Subject: Re: [Pythonmac-SIG] Installing modules with py2app

On Tue, Jan 11, 2011 at 9:42 AM, Mier, Alejandro <alejan...@ti.com> wrote:
> Hello
>
> I have a script that installs Python, and then installs some modules with:
>
> subprocess.call("python setup.py install")
>
> The script works on Windows with py2exe, but gives me this error when using 
> py2app:
>
> File setup.py
>    from distutils.core import setup
> ImportError: No module named distutils.core

Try debugging this issue by printing sys.path, and check if
distutils/core... exists in one of them:

    subprocess.call('python -c "import sys; print((sys.prefix, sys.path))"')

-srid
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

Reply via email to