FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux General Discussion

 
 
LinkBack Thread Tools
 
Old 08-17-2012, 10:42 PM
Ben Booth
 
Default simple trick to make dealing with python 2/3 scripts easier

Damjan wrote:

>> The only problem with
>> this approach is that /usr/bin/python is owned by the python package, so
>> if you upgrade the python package it might create problems. Any one know
>> of some way to work around this problem?
>
> Just put your script in /usr/local/bin

But then some scripts use #!/usr/bin/python. Putting it in /usr/local/bin
would only work if the script uses #!/usr/local/bin/python or #!/usr/bin/env
python.
 
Old 08-17-2012, 10:44 PM
Ben Booth
 
Default simple trick to make dealing with python 2/3 scripts easier

Ben Booth wrote:

> Damjan wrote:
>
>>> The only problem with
>>> this approach is that /usr/bin/python is owned by the python package, so
>>> if you upgrade the python package it might create problems. Any one know
>>> of some way to work around this problem?
>>
>> Just put your script in /usr/local/bin
>
> But then some scripts use #!/usr/bin/python. Putting it in /usr/local/bin
> would only work if the script uses #!/usr/local/bin/python or
> #!/usr/bin/env python.

Maybe I'll submit a feature request to the python package maintainer to see
if they think it's a good idea.
 
Old 08-17-2012, 11:14 PM
Ben Booth
 
Default simple trick to make dealing with python 2/3 scripts easier

Ben Booth wrote:

>
> Maybe I'll submit a feature request to the python package maintainer to
> see if they think it's a good idea.

I submitted a feature request in case anyone's interested:

https://bugs.archlinux.org/index.php?do=details&action=details.addvote&task_i d=31179
 
Old 08-18-2012, 04:24 AM
Anthony 'Ishpeck' Tedjamulia
 
Default simple trick to make dealing with python 2/3 scripts easier

On Fri, Aug 17, 2012 at 11:09:06AM -0700, Ben Booth wrote:
> remove the /usr/bin/python symlink and replace with this shell script:
>
> #!/usr/bin/env bash
> exec /usr/bin/"${PYTHON:-python3}" "$@"

Bravo! I approve.

This solution is 0.99 times as good as the option to just not
have Python 3
 
Old 08-19-2012, 02:43 AM
Ben Booth
 
Default simple trick to make dealing with python 2/3 scripts easier

Matthew Monaco <dgbaley27@0x01b.net> wrote:

> On 08/17/2012 04:14 PM, Ben Booth wrote:
>
> Don't know if you did this by accident -- and not a huge deal -- but you
> shouldn't have included the vote action in the link.
>

Oops, my mistake. In any case, the request was rejected.
 
Old 08-23-2012, 08:24 PM
Ben Booth
 
Default simple trick to make dealing with python 2/3 scripts easier

In case anyone's still interested in this, I found a pacman.conf option
called NoExtract, which lets you tell pacman not to overwrite certain files
and directories in the filesystem. So you could add the following line to
/etc/pacman.conf:

NoExtract = /usr/bin/python

which would prevent pacman from overwriting the custom /usr/bin/python
script. Here is the most recent version of the /usr/bin/python script:

#!/usr/bin/env bash
test "$PYTHON" != "python2" -a "$PYTHON" != "python3" && unset PYTHON
exec /usr/bin/"${PYTHON:-python3}" "$@"

This version does some input checking to make sure the only valid options
for the PYTHON environment variable are "python2" or "python3".

Ben
 
Old 08-23-2012, 08:32 PM
Ben Booth
 
Default simple trick to make dealing with python 2/3 scripts easier

Ben Booth wrote:

> In case anyone's still interested in this, I found a pacman.conf option
> called NoExtract, which lets you tell pacman not to overwrite certain
> files and directories in the filesystem. So you could add the following
> line to /etc/pacman.conf:
>
> NoExtract = /usr/bin/python

Actually it should be

NoExtract = usr/bin/python

without the root slash. sorry for the typo.

Ben
 

Thread Tools




All times are GMT. The time now is 01:24 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org