simple trick to make dealing with python 2/3 scripts easier
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 -- -- дамјан |
simple trick to make dealing with python 2/3 scripts easier
genius! :)
maybe a cronjob? (every 24 hours overwrite the script) (silly one) maybe a startup overwrite? or an aur package? (with interactive question if PYTHON is not set!) -- (\_ /) copy the bunny to your profile (0.o ) to help him achieve world domination. (> <) come join the dark side. /_|_ (we have cookies.) On Fri, Aug 17, 2012 at 9:09 PM, Ben Booth <benwbooth@gmail.com> wrote: > Lots of python scripts still use #!/usr/bin/python instead of explicitly > stating which version of python to use. Here's quick trick to make running > various python version 2 or 3 scripts easier: > > remove the /usr/bin/python symlink and replace with this shell script: > > #!/usr/bin/env bash > exec /usr/bin/"${PYTHON:-python3}" "$@" > > Now you can set the PYTHON environment variable to be either python2 or > python3, depending on which version of python the script expects. Just > don't > set PYTHON=python, or you'll get a recursive loop! 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? > > |
simple trick to make dealing with python 2/3 scripts easier
but which of is going to be executed?
/usr/bin or /usr/local/bin? -- (\_ /) copy the bunny to your profile (0.o ) to help him achieve world domination. (> <) come join the dark side. /_|_ (we have cookies.) On Fri, Aug 17, 2012 at 9:09 PM, Ben Booth <benwbooth@gmail.com> wrote: > Lots of python scripts still use #!/usr/bin/python instead of explicitly >> stating which version of python to use. Here's quick trick to make running >> various python version 2 or 3 scripts easier: >> >> remove the /usr/bin/python symlink and replace with this shell script: >> >> #!/usr/bin/env bash >> exec /usr/bin/"${PYTHON:-python3}" "$@" >> >> Now you can set the PYTHON environment variable to be either python2 or >> python3, depending on which version of python the script expects. Just >> don't >> set PYTHON=python, or you'll get a recursive loop! 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? >> >> > |
simple trick to make dealing with python 2/3 scripts easier
but which of is going to be executed?
/usr/bin or /usr/local/bin? /usr/local/bin is before /usr/bin in your PATH environment variable, so the shell will first look there for programs. Check "echo $PATH" to see what your path is. -- дамјан |
simple trick to make dealing with python 2/3 scripts easier
well, you're right... :P
so, no cronjobs XD -- (\_ /) copy the bunny to your profile (0.o ) to help him achieve world domination. (> <) come join the dark side. /_|_ (we have cookies.) On Sat, Aug 18, 2012 at 1:36 AM, Damjan <gdamjan@gmail.com> wrote: > but which of is going to be executed? >> /usr/bin or /usr/local/bin? >> > > /usr/local/bin is before /usr/bin in your PATH environment variable, so > the shell will first look there for programs. Check "echo $PATH" to see > what your path is. > > -- > дамјан > |
simple trick to make dealing with python 2/3 scripts easier
On 08/17/2012 04:14 PM, Ben Booth wrote:
> 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 > > > 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. |
simple trick to make dealing with python 2/3 scripts easier
On 2012/8/17 Ben Booth <benwbooth@gmail.com> wrote:
> Lots of python scripts still use #!/usr/bin/python instead of explicitly > stating which version of python to use. Here's quick trick to make running > various python version 2 or 3 scripts easier: > > remove the /usr/bin/python symlink and replace with this shell script: > > #!/usr/bin/env bash > exec /usr/bin/"${PYTHON:-python3}" "$@" > > Now you can set the PYTHON environment variable to be either python2 or > python3, depending on which version of python the script expects. Just don't > set PYTHON=python, or you'll get a recursive loop! 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? Run your scripts using "python2 script.py" or use setuptools that rewrites shebang automatically. Rmy. |
simple trick to make dealing with python 2/3 scripts easier
Thank you Ben, people who follow up on an issue they have found a solution
for are good people. On Aug 23, 2012 1:35 PM, "Ben Booth" <bwbooth@lbl.gov> wrote: > 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 > > |
| All times are GMT. The time now is 01:37 AM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.