[Pythonmac-SIG] Installing modules with py2app

2011-01-15 Thread Mier, Alejandro
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

I tried explicitly including distutils when building the .app bundle, with 
python setup.py py2app --packages distutils (and several variations of 
--includes), but then I get this error:

error: invalid command 'install'

What do I need to do to make this work on mac?

Thanks!
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Installing modules with py2app

2011-01-18 Thread Chris Weisiger
Did you build the app bundle with the Python that came with OSX, or did you
install a separate Python install from python.org and use that? You have to
do the latter; py2app's not allowed to include components of the operating
system in the apps it generates. Windows gets around this problem by not
having a standard Python install.

HTH

-Chris

On Tue, Jan 11, 2011 at 9:42 AM, Mier, Alejandro  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
>
> I tried explicitly including distutils when building the .app bundle, with
> python setup.py py2app --packages distutils (and several variations of
> --includes), but then I get this error:
>
> error: invalid command 'install'
>
> What do I need to do to make this work on mac?
>
> Thanks!
> ___
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
>
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Installing modules with py2app

2011-01-18 Thread Mier, Alejandro
Hi

I am using a separate Python install (ActivePython 2.6 ), so that's not it

Thanks

--
Alejandro Mier y Concha

From: pythonmac-sig-bounces+alejandro=ti@python.org 
[mailto:pythonmac-sig-bounces+alejandro=ti@python.org] On Behalf Of Chris 
Weisiger
Sent: Tuesday, January 18, 2011 10:08 AM
Cc: pythonmac-sig@python.org
Subject: Re: [Pythonmac-SIG] Installing modules with py2app

Did you build the app bundle with the Python that came with OSX, or did you 
install a separate Python install from python.org<http://python.org> and use 
that? You have to do the latter; py2app's not allowed to include components of 
the operating system in the apps it generates. Windows gets around this problem 
by not having a standard Python install.

HTH

-Chris
On Tue, Jan 11, 2011 at 9:42 AM, Mier, Alejandro 
mailto: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

I tried explicitly including distutils when building the .app bundle, with 
python setup.py py2app --packages distutils (and several variations of 
--includes), but then I get this error:

error: invalid command 'install'

What do I need to do to make this work on mac?

Thanks!
___
Pythonmac-SIG maillist  -  
Pythonmac-SIG@python.org<mailto:Pythonmac-SIG@python.org>
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

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


Re: [Pythonmac-SIG] Installing modules with py2app

2011-01-18 Thread João Vale
Do you have distutils installed? It usually doesn't come bundled with
Python. It can be installed with easy_install:

easy_install distutils


Cheers,
João



On Tue, Jan 18, 2011 at 4:27 PM, Mier, Alejandro  wrote:
> Hi
>
>
>
> I am using a separate Python install (ActivePython 2.6 ), so that’s not it
>
>
>
> Thanks
>
>
>
> --
>
> Alejandro Mier y Concha
>
>
>
> From: pythonmac-sig-bounces+alejandro=ti@python.org
> [mailto:pythonmac-sig-bounces+alejandro=ti@python.org] On Behalf Of
> Chris Weisiger
> Sent: Tuesday, January 18, 2011 10:08 AM
> Cc: pythonmac-sig@python.org
> Subject: Re: [Pythonmac-SIG] Installing modules with py2app
>
>
>
> Did you build the app bundle with the Python that came with OSX, or did you
> install a separate Python install from python.org and use that? You have to
> do the latter; py2app's not allowed to include components of the operating
> system in the apps it generates. Windows gets around this problem by not
> having a standard Python install.
>
> HTH
>
> -Chris
>
> On Tue, Jan 11, 2011 at 9:42 AM, Mier, Alejandro  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
>
> I tried explicitly including distutils when building the .app bundle, with
> python setup.py py2app --packages distutils (and several variations of
> --includes), but then I get this error:
>
> error: invalid command 'install'
>
> What do I need to do to make this work on mac?
>
> Thanks!
> ___
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
>
>
>
> ___
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
>
>
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Installing modules with py2app

2011-01-18 Thread Sridhar Ratnakumar
On Tue, Jan 11, 2011 at 9:42 AM, Mier, Alejandro  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


Re: [Pythonmac-SIG] Installing modules with py2app

2011-01-18 Thread Mier, Alejandro
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 
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  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


Re: [Pythonmac-SIG] Installing modules with py2app

2011-01-18 Thread Christopher Barker

On 1/18/11 9:05 AM, João Vale wrote:

Do you have distutils installed? It usually doesn't come bundled with
Python.


huh? Sure it does -- distutils has been standard in Python for many many 
years.


So that's not it.

Besides, if you can run it unbundled, you have the packages you need, 
the question is how to get them properly into the py2app bundle.


-Chris


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Installing modules with py2app

2011-01-18 Thread Christopher Barker

On 1/18/11 2:47 PM, Mier, Alejandro wrote:

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
 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.


I don't think it's a bug -- you may have some problems with this. I'm 
not sure I quite get what distutils is doing with USER_BASE and 
USER_SITE, but I suspect that they are using them to figure out where to 
install stuff. That should be a function of the python you are 
installing to. A py2app bundle isn't usually installing stuff into itself.


How are you using distutils in this case? Are you installing stuff into 
the app bundle? Or into a system python? If a system python, you should 
probably use the system python's distutils (and thus its site.py) to do 
the work.


If you are installing into the app bundle (cool idea!), then you'll need 
to make sure that USER_BASE and USER_SITE are set correctly at run time 
for where the user happens to have put the py2app bundle.


-Chris







--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Installing modules with py2app

2011-01-20 Thread Mier, Alejandro
Hi Chris

> How are you using distutils in this case? Are you installing stuff into 
> the app bundle? Or into a system python? If a system python, you should 
> probably use the system python's distutils (and thus its site.py) to do 
> the work.

I am trying to install modules into the system python.

The problem with my solution (which I hadn't notice); is that modules are 
getting installed into the .app bundle instead.

The problem is that, even though subprocess.call("python setup.py install") 
picks up the system python (sys.executable has the expected value), it still 
loads the modules from the site-packages.zip in the .app bundle.

How can I make this new python process load the modules from system 
site-packages folder?

Thanks

--
Alejandro Mier y Concha


-Original Message-
From: pythonmac-sig-bounces+alejandro=ti@python.org 
[mailto:pythonmac-sig-bounces+alejandro=ti@python.org] On Behalf Of 
Christopher Barker
Sent: Tuesday, January 18, 2011 6:02 PM
To: pythonmac-sig@python.org
Subject: Re: [Pythonmac-SIG] Installing modules with py2app

On 1/18/11 2:47 PM, Mier, Alejandro wrote:
> 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
>  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.

I don't think it's a bug -- you may have some problems with this. I'm 
not sure I quite get what distutils is doing with USER_BASE and 
USER_SITE, but I suspect that they are using them to figure out where to 
install stuff. That should be a function of the python you are 
installing to. A py2app bundle isn't usually installing stuff into itself.

How are you using distutils in this case? Are you installing stuff into 
the app bundle? Or into a system python? If a system python, you should 
probably use the system python's distutils (and thus its site.py) to do 
the work.

If you are installing into the app bundle (cool idea!), then you'll need 
to make sure that USER_BASE and USER_SITE are set correctly at run time 
for where the user happens to have put the py2app bundle.

-Chris







-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Installing modules with py2app

2011-01-20 Thread Christopher Barker

On 1/20/11 2:10 PM, Mier, Alejandro wrote:

The problem is that, even though subprocess.call("python setup.py install") 
picks up the system python
(sys.executable has the expected value), it still loads the modules from the 
site-packages.zip in the .app bundle.


I suspect that you are getting environment variables set by py2app, 
rather that the user's raw environment.


Maybe it shouldn't be a subprocess -- what happens if you do a simple:

os.system("python setup.py install")

 you also may need to make sure the working dir is correct:

os.system("cd the/full/path/to/setup; python setup.py install)



-Chris



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Installing modules with py2app

2011-02-06 Thread Michael Rans
Try putting env={} in subprocess

For MacOS (and probably Linux if it were running through Freeze or the like), 
you need to pass env as an empty dict. For Windows and py2exe, you pass env as 
None.


I don't know if this post will get through as I'm not intending to subscribe to 
this list, but I thought I'd try sending an answer as I came across your post.

Cheers,
Mike

On Tue, Jan 11, 2011 at 9:42 AM, Mier, Alejandro  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
>
> I tried explicitly including distutils when building the .app bundle, with
> python setup.py py2app --packages distutils (and several variations of
> --includes), but then I get this error:
>
> error: invalid command 'install'
>
> What do I need to do to make this work on mac?
>
> Thanks!
> ___
> Pythonmac-SIG maillist  -  pyth...@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
>


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