Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python launcher (PEP 397) and emacs python-mode.el

Reply
Thread Tools

Python launcher (PEP 397) and emacs python-mode.el

 
 
Thomas Heller
Guest
Posts: n/a
 
      01-31-2013
Has someone managed to patch python-mode.el to use
the PEP 397 python launcher when you hit C-c C-c?

It seems that emacs should parse the shebang line in the edited
python script and pass the corresponding arguments to py.exe.

Thomas
 
Reply With Quote
 
 
 
 
Andreas Röhler
Guest
Posts: n/a
 
      01-31-2013
Am 31.01.2013 10:03, schrieb Thomas Heller:
> Has someone managed to patch python-mode.el to use
> the PEP 397 python launcher when you hit C-c C-c?
>
> It seems that emacs should parse the shebang line in the edited
> python script and pass the corresponding arguments to py.exe.
>


Yes, that's the way python-mode.el acts by default.

AFAIU that launcher is implemented in Python3.3 and should not need any patch at all.
Should it not work, please file a bug-report at

https://bugs.launchpad.net/python-mode

Andreas

> Thomas





 
Reply With Quote
 
 
 
 
Thomas Heller
Guest
Posts: n/a
 
      01-31-2013
Am 31.01.2013 12:05, schrieb Andreas Röhler:
> Am 31.01.2013 10:03, schrieb Thomas Heller:
>> Has someone managed to patch python-mode.el to use
>> the PEP 397 python launcher when you hit C-c C-c?
>>
>> It seems that emacs should parse the shebang line in the edited
>> python script and pass the corresponding arguments to py.exe.
>>

>
> Yes, that's the way python-mode.el acts by default.
>
> AFAIU that launcher is implemented in Python3.3 and should not need any
> patch at all.
> Should it not work, please file a bug-report at
>
> https://bugs.launchpad.net/python-mode


Well, let me make these remarks:

1. I'm on Windows, using gnu-emacs 24.2.1, and python-mode.el 6.1.0.
I do not understand how the shebang line is used by python-mode.el,
depending on what I write into it either 'python.exe' is started when
I hit C-c C-c, or I get 'Spawning child process: invalid argument'.
The latter occurs most often when the shebang string contains 'jython'.


2. I would like to use the PEP 397 python launcher to start the python
version that is specified in the shebang line.
The python launcher py.exe parses this line when I run 'py script.py',
and then starts the corresponding python interpreter version.
The launcher parses the shebang line by its own rules (see pep397 for
exact details). One example is this:

<script>
#!/usr/bin/python3.1-32
import sys; print(sys.version)
</script>

The python launcher starts 'c:\Python31\python.exe -3.1-32 script.py'.

I would like emacs to do the same; however this would require emacs
to do the same shebang line parsing as the launcher does.

Thomas
 
Reply With Quote
 
Vinay Sajip
Guest
Posts: n/a
 
      01-31-2013
Thomas Heller <theller <at> ctypes.org> writes:

> <script>
> #!/usr/bin/python3.1-32
> import sys; print(sys.version)
> </script>
>
> The python launcher starts 'c:\Python31\python.exe -3.1-32 script.py'.
>


That doesn't seem right, the launcher on my system launches using

c:\Python31\python.exe script.py

if I just run script.py, or if I invoke it as

py -3.1-32 script.py

it still launches using

c:\Python31\python.exe script.py

Regards,

Vinay Sajip

 
Reply With Quote
 
Andreas Röhler
Guest
Posts: n/a
 
      01-31-2013
Am 31.01.2013 17:35, schrieb Thomas Heller:
> Am 31.01.2013 12:05, schrieb Andreas Röhler:
>> Am 31.01.2013 10:03, schrieb Thomas Heller:
>>> Has someone managed to patch python-mode.el to use
>>> the PEP 397 python launcher when you hit C-c C-c?
>>>
>>> It seems that emacs should parse the shebang line in the edited
>>> python script and pass the corresponding arguments to py.exe.
>>>

>>
>> Yes, that's the way python-mode.el acts by default.
>>
>> AFAIU that launcher is implemented in Python3.3 and should not need any
>> patch at all.
>> Should it not work, please file a bug-report at
>>
>> https://bugs.launchpad.net/python-mode

>
> Well, let me make these remarks:
>
> 1. I'm on Windows, using gnu-emacs 24.2.1, and python-mode.el 6.1.0.
> I do not understand how the shebang line is used by python-mode.el,


it uses py-shebang-regexp to determine
- if a shebang is given
- if, yes, which interpreter to run

> depending on what I write into it either 'python.exe' is started when
> I hit C-c C-c, or I get 'Spawning child process: invalid argument'.
> The latter occurs most often when the shebang string contains 'jython'.


please file a bug-report giving some example script which triggers the bug

>
>
> 2. I would like to use the PEP 397 python launcher to start the python
> version that is specified in the shebang line.
> The python launcher py.exe parses this line when I run 'py script.py',
> and then starts the corresponding python interpreter version.
> The launcher parses the shebang line by its own rules (see pep397 for
> exact details). One example is this:
>
> <script>
> #!/usr/bin/python3.1-32
> import sys; print(sys.version)
> </script>
>
> The python launcher starts 'c:\Python31\python.exe -3.1-32 script.py'.
>


unfortunatly don't have a windows at my disposal.

At linux it would run exactly the interpreter specified. Might be okay for windows as shown.


> I would like emacs to do the same; however this would require emacs
> to do the same shebang line parsing as the launcher does.
>


So we do - looks like python-mode.el precedes PEP 397

Expecting the bug elsewhere.

> Thomas


 
Reply With Quote
 
Thomas Heller
Guest
Posts: n/a
 
      01-31-2013
Am 31.01.2013 19:26, schrieb Vinay Sajip:
> Thomas Heller <theller <at> ctypes.org> writes:
>
>> <script>
>> #!/usr/bin/python3.1-32
>> import sys; print(sys.version)
>> </script>
>>
>> The python launcher starts 'c:\Python31\python.exe -3.1-32 script.py'.
>>

>
> That doesn't seem right, the launcher on my system launches using
>
> c:\Python31\python.exe script.py
>
> if I just run script.py, or if I invoke it as
>
> py -3.1-32 script.py
>
> it still launches using
>
> c:\Python31\python.exe script.py


Sorry for the confusion that I am causing. Vinay, you are right of course.

What I meant to write is this:

when the shebang line in script.py contains this:
#!/usr/bin/python3.1-32
then emacs SHOULD run
py.exe -3.1-32 script.py
and the launcher runs
c:\Python31\python.exe script.py


Thomas

 
Reply With Quote
 
Vinay Sajip
Guest
Posts: n/a
 
      01-31-2013
Thomas Heller <theller <at> ctypes.org> writes:

> What I meant to write is this:
>
> when the shebang line in script.py contains this:
> #!/usr/bin/python3.1-32
> then emacs SHOULD run
> py.exe -3.1-32 script.py
> and the launcher runs
> c:\Python31\python.exe script.py


IMO it would be better for emacs to just run

py.exe script.py

and py.exe can read the shebang and do the right thing. This saves the emacs code
from having to duplicate the shebang line processing logic that py.exe uses
(which, as we know, is unusual. So for a cross-platform you can have a shebang
line of #!/usr/bin/python3.2, and on Windows it will still call the appropriate
Python 3.2 even if it's not in /usr/bin, as there's no /usr/bin )

Regards,

Vinay Sajip



 
Reply With Quote
 
Andreas Röhler
Guest
Posts: n/a
 
      02-01-2013
Am 01.02.2013 00:59, schrieb Vinay Sajip:
> Thomas Heller <theller <at> ctypes.org> writes:
>
>> What I meant to write is this:
>>
>> when the shebang line in script.py contains this:
>> #!/usr/bin/python3.1-32
>> then emacs SHOULD run
>> py.exe -3.1-32 script.py
>> and the launcher runs
>> c:\Python31\python.exe script.py

>
> IMO it would be better for emacs to just run
>
> py.exe script.py
>
> and py.exe can read the shebang and do the right thing. This saves the emacs code
> from having to duplicate the shebang line processing logic that py.exe uses
> (which, as we know, is unusual. So for a cross-platform you can have a shebang
> line of #!/usr/bin/python3.2, and on Windows it will still call the appropriate
> Python 3.2 even if it's not in /usr/bin, as there's no /usr/bin )
>
> Regards,
>
> Vinay Sajip
>
>
>


https://bugs.launchpad.net/python-mode/+bug/1112207
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: suggesting a launcher wrapper script for portable python Thomas Jollans Python 0 08-12-2012 07:05 PM
Executing Python Scripts on Mac using Python Launcher David Thomas Python 20 06-27-2012 09:33 PM
Python Launcher.app on OS X kpp9c Python 4 03-03-2009 09:44 PM
Python launcher not working on Mac after Leopard upgrade? =?iso-8859-1?B?QW5kcuk=?= Python 3 11-06-2007 09:02 PM
Trouble running Emacs-EPL (to run perl in emacs). Adam Funk Perl Misc 4 01-29-2007 10:42 AM



Advertisments