View previous topic :: View next topic |
Author |
Message |
equaeghe l33t
Joined: 22 Feb 2005 Posts: 632
|
Posted: Tue Apr 09, 2013 2:03 pm Post subject: How to: python3 for user, python2 for system? |
|
|
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 |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Tue Apr 09, 2013 2:26 pm Post subject: |
|
|
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 |
|
|
equaeghe l33t
Joined: 22 Feb 2005 Posts: 632
|
Posted: Tue Apr 09, 2013 2:30 pm Post subject: |
|
|
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 |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Tue Apr 09, 2013 2:35 pm Post subject: |
|
|
python is script.
so (replace myapp with sphinx name)
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 |
|
|
equaeghe l33t
Joined: 22 Feb 2005 Posts: 632
|
Posted: Tue Apr 09, 2013 6:02 pm Post subject: |
|
|
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 |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Tue Apr 09, 2013 6:54 pm Post subject: |
|
|
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 |
|
|
|