Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-14 Thread Alan Gauld

On 14/11/11 13:40, learner404 wrote:


I will try to see if there's something like "inno setup" to make an
installer. If anyone have something to recommend for this i'm interested.


I'm no Mac/Python expert but I seem to recall the MacPython web page had 
info on how to create a Mac App bundle that avoided the need to
use AppleScript etc. It was all about the file structure and the config 
information.


But it was a wee while ago and I may be imagining it... :-)

Alan G

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-14 Thread Dario Lopez-Kästen
Try PyInstaller http://www.pyinstaller.org/

/dario


On Nov 14, 2011 2:43 PM, "learner404"  wrote:

>
> On Fri, Nov 11, 2011 at 12:02 AM, Prasad, Ramit  > wrote:
>
>  It is probably easiest to keep myapp.py in the home directory (or
>> subdirectory of it) and say "python ~/myapp.py" (or "python
>> ~/.roadierich/myapp.py) from the applescript
>>
>>
> I will go with that for now. My python script is using a bunch of relative
> paths so I added this before the script:
>
> if sys.platform=="darwin":
>
> os.chdir(os.path.expanduser("~/myfolder/"))
> I will try to see if there's something like "inno setup" to make an
> installer. If anyone have something to recommend for this i'm interested.
>
> Thanks Ramit and all.
>
>
>>
>>
>> Ramit
>>
>>
>> Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
>> 712 Main Street | Houston, TX 77002
>> work phone: 713 - 216 - 5423
>>
>> --
>> This email is confidential and subject to important disclaimers and
>> conditions including on offers for the purchase or sale of
>> securities, accuracy and completeness of information, viruses,
>> confidentiality, legal privilege, and legal entity disclaimers,
>> available at http://www.jpmorgan.com/pages/disclosures/email.
>>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-14 Thread learner404
On Fri, Nov 11, 2011 at 12:02 AM, Prasad, Ramit
wrote:

 It is probably easiest to keep myapp.py in the home directory (or
> subdirectory of it) and say "python ~/myapp.py" (or "python
> ~/.roadierich/myapp.py) from the applescript
>
>
I will go with that for now. My python script is using a bunch of relative
paths so I added this before the script:

if sys.platform=="darwin":

os.chdir(os.path.expanduser("~/myfolder/"))
I will try to see if there's something like "inno setup" to make an
installer. If anyone have something to recommend for this i'm interested.

Thanks Ramit and all.


>
>
> Ramit
>
>
> Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
> 712 Main Street | Houston, TX 77002
> work phone: 713 - 216 - 5423
>
> --
> This email is confidential and subject to important disclaimers and
> conditions including on offers for the purchase or sale of
> securities, accuracy and completeness of information, viruses,
> confidentiality, legal privilege, and legal entity disclaimers,
> available at http://www.jpmorgan.com/pages/disclosures/email.
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread Prasad, Ramit
From: tutor-bounces+ramit.prasad=jpmorgan@python.org 
[mailto:tutor-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of 
learner404
Sent: Thursday, November 10, 2011 10:44 AM
To: Rich Lovely
Cc: Tutor Python
Subject: Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)


On Thu, Nov 10, 2011 at 4:33 PM, Rich Lovely  wrote:

It looks like your script is being found fine, meaning the problem lies 
elsewhere - unless your actual app is called "avcOsxLinux.py, and you missed 
renaming it in the error message.  Try adding a print statement as the very 
first line - before any imports - to test this.

Sorry I missed replacing this one when I copy/pasted on the list;  
avcOsxLinux.py is "myapp.py" (I renamed it for clarity). Unfortunately the 
problem is still the same. 

$ python myapp.py
$ python: can't open file 'myapp.py': [Errno 2] No such file or directory


The only reference to that filename is a french audio-visual library, which 
might not be installed on your target system.

Rich "RoadieRich" Lovely

There are 10 types of people in the world:
Those who know binary,
Those who do not,
And those who are off by one.


You can try using locate or find, but any usage of this is probably system 
specific and prone to bugs. If you have the option to "install" something you 
can try setting an environment variable with the location of myapp.py. It is 
probably easiest to keep myapp.py in the home directory (or subdirectory of it) 
and say "python ~/myapp.py" (or "python ~/.roadierich/myapp.py) from the 
applescript



Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread learner404
On Thu, Nov 10, 2011 at 4:33 PM, Rich Lovely wrote:

>
> It looks like your script is being found fine, meaning the problem lies
> elsewhere - unless your actual app is called "avcOsxLinux.py, and you
> missed renaming it in the error message.  Try adding a print statement as
> the very first line - before any imports - to test this.
>

Sorry I missed replacing this one when I copy/pasted on the list;
 avcOsxLinux.py is "myapp.py" (I renamed it for clarity). Unfortunately the
problem is still the same.

$ python myapp.py
$ python: can't open file 'myapp.py': [Errno 2] No such file or directory


> The only reference to that filename is a french audio-visual library,
> which might not be installed on your target system.
>
> Rich "RoadieRich" Lovely
>
> There are 10 types of people in the world:
> Those who know binary,
> Those who do not,
> And those who are off by one.
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread Rich Lovely

On 10 Nov 2011, at 15:20, learner404 wrote:

> 
> 
> On Thu, Nov 10, 2011 at 2:14 PM, Steven D'Aprano  wrote:
> learner404 wrote:
> Hello list!
> 
> - myapp.py is in a "myfolder" folder that the "users" will be able to
> download and put anywhere on their Mac.
> [...]
> 
> In both cases OSX complains it can't find the file. 
> 
> Do you mean that AppleScript can't find the file, or that Python can't find 
> the file?
> 
> When I double click on the AppleScript the terminal opens with
> 
> $ python myapp.py
> $ python: can't open file 'avcOsxLinux.py': [Errno 2] No such file or 
> directory
>  
> myapp.py and the AppleScript are both in the same directory. If I open 
> manually a shell in this directory "python myapp.py" works.
> 
> It all seems like the Python invoked in the AppleScript have his current 
> directory in root (and not the folder where i'm executing the AppleScript). I 
> don't see how I can change this from the AppleScript or simply find a general 
> solution to execute a .py script on Mac within the constrains I mentioned 
> above. 
> 
> 
> Please don't summarize or paraphrase errors. Please copy and paste the EXACT 
> error message that is shown.
> 
> If this is a problem with AppleScript being unable to find the file, you will 
> be better off asking on an AppleScript mailing list.
> 
> In general, on Unix-like systems (and that includes Mac OS X), you can't 
> expect a command like:
> 
> python myapp.py
> 
> to work unless myapp.py is in the current directory.
> 
> 
> 
> -- 
> Steven
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

It looks like your script is being found fine, meaning the problem lies 
elsewhere - unless your actual app is called "avcOsxLinux.py, and you missed 
renaming it in the error message.  Try adding a print statement as the very 
first line - before any imports - to test this.

The only reference to that filename is a french audio-visual library, which 
might not be installed on your target system.

Rich "RoadieRich" Lovely

There are 10 types of people in the world:
Those who know binary,
Those who do not,
And those who are off by one.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread learner404
On Thu, Nov 10, 2011 at 2:14 PM, Steven D'Aprano wrote:

> learner404 wrote:
>
>> Hello list!
>>
>> - myapp.py is in a "myfolder" folder that the "users" will be able to
>> download and put anywhere on their Mac.
>>
> [...]
>
>  In both cases OSX complains it can't find the file.
>>
>
> Do you mean that AppleScript can't find the file, or that Python can't
> find the file?
>

When I double click on the AppleScript the terminal opens with

$ python myapp.py
$ python: can't open file 'avcOsxLinux.py': [Errno 2] No such file or
directory

myapp.py and the AppleScript are both in the same directory. If I open
manually a shell in this directory "python myapp.py" works.

It all seems like the Python invoked in the AppleScript have his current
directory in root (and not the folder where i'm executing the AppleScript).
I don't see how I can change this from the AppleScript or simply find a
general solution to execute a .py script on Mac within the constrains I
mentioned above.


> Please don't summarize or paraphrase errors. Please copy and paste the
> EXACT error message that is shown.
>
> If this is a problem with AppleScript being unable to find the file, you
> will be better off asking on an AppleScript mailing list.
>
> In general, on Unix-like systems (and that includes Mac OS X), you can't
> expect a command like:
>
> python myapp.py
>
> to work unless myapp.py is in the current directory.
>
>
>
> --
> Steven
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread Steven D'Aprano

learner404 wrote:

Hello list!

- myapp.py is in a "myfolder" folder that the "users" will be able to
download and put anywhere on their Mac.

[...]
In both cases OSX complains it can't find the file. 


Do you mean that AppleScript can't find the file, or that Python can't 
find the file?


Please don't summarize or paraphrase errors. Please copy and paste the 
EXACT error message that is shown.


If this is a problem with AppleScript being unable to find the file, you 
will be better off asking on an AppleScript mailing list.


In general, on Unix-like systems (and that includes Mac OS X), you can't 
expect a command like:


python myapp.py

to work unless myapp.py is in the current directory.



--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

2011-11-10 Thread learner404
Hello list!

- myapp.py is in a "myfolder" folder that the "users" will be able to
download and put anywhere on their Mac.

- users don't have any Python knowledge and I have no idea if there's a
python launcher on their mac

=> trying to make an applescript file in the folder right next to myapp.py

I tried and failed at :

*tell* *application* "Terminal"

*do script* "python myapp.py"# tried also with ./myapp.py

*end* *tell*

or

do shell script "python myapp.py" # tried also with ./myapp.py


In both cases OSX complains it can't find the file. It works though if I
give the full path but I can't do that since I have no idea where the
folder will be on their macs.

With Applescript how would write it  so that Python starts in the
application folder? (myapp.py & "myfolder")

Any other way to do it maybe knowing my constraints above? (I tried py2app
but it failed on wxpython on my Lion with Apple Python that I need to use)

Thanks!

francois
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor