Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to: python3 for user, python2 for system?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
equaeghe
l33t
l33t


Joined: 22 Feb 2005
Posts: 632

PostPosted: Tue Apr 09, 2013 2:03 pm    Post subject: How to: python3 for user, python2 for system? Reply with quote

Hi,


How do make it so that python3 is active for a specific user and python2 remains the system python? (eselect python seemingly only allows me to set it globally)

Underlying reason: I'd like to run sphinx with python3, because the code to document/doctest is python3-based.


TIA,

Erik
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Tue Apr 09, 2013 2:26 pm    Post subject: Reply with quote

gentoo aim python system by a python symlink in /usr/bin (so /usr/bin/python)
but also provide symlink for python version as /usr/bin/python3 /usr/bin/python2 that will point to your 3 and 2 version selected.

So just edit your python script to use /usr/bin/python3 instead of /usr/bin/python
Back to top
View user's profile Send private message
equaeghe
l33t
l33t


Joined: 22 Feb 2005
Posts: 632

PostPosted: Tue Apr 09, 2013 2:30 pm    Post subject: Reply with quote

krinn wrote:
So just edit your python script to use /usr/bin/python3 instead of /usr/bin/python


Thanks for the quick reaction. The problem is that I don't know how to let Sphinx (portage-installed package) know how to use 'python3' instead of 'python'. So this option is not straightforward...
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Tue Apr 09, 2013 2:35 pm    Post subject: Reply with quote

python is script.

so (replace myapp with sphinx name)
Code:
nano `which myapp`


Code:

more `which emerge`
#!/usr/bin/python
# Copyright 2006-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id: emerge 14291 2009-09-20 11:28:14Z arfrever $

see the first line ?
Back to top
View user's profile Send private message
equaeghe
l33t
l33t


Joined: 22 Feb 2005
Posts: 632

PostPosted: Tue Apr 09, 2013 6:02 pm    Post subject: Reply with quote

krinn wrote:
see the first line ?


Code:
$ head -1 /usr/bin/sphinx-build
#!/usr/bin/python-exec-c


and 'python-exec-c' is a binary file, 'a Gentoo tool to choose the correct Python script variant for currently selected Python implementation' and it is not clear to me how to go further...
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Tue Apr 09, 2013 6:54 pm    Post subject: Reply with quote

equaeghe wrote:

and 'python-exec-c' is a binary file, 'a Gentoo tool to choose the correct Python script variant for currently selected Python implementation' and it is not clear to me how to go further...


I don't know that tool, but it doesn't work it seems as you need to a way to choose the implementation yourself.

My idea is just that, maybe it wasn't clear because it's so simple that you were thinking something highly complex ?
Change it to have: (even i think it's harmless, it won't kill you to copy the file somewhere before altering it, just in case...)
Code:
$ head -1 /usr/bin/sphinx-build
#!/usr/bin/python3


So your program have no choice but running the python3 installed version currently selected as python3.
Now if you change system python to default to python2 the script will still run thru the python3 symlink and python3 variant so. See the logic ?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum