Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Actually, this is a serious question. I noticed that the BLFS book has instructions for installing two versions of python. When I first encountered a package that required Python, it listed either as a dependency. As I know nothing about Python, it seemed best to just use the newer one, so I picked the three version over the two version. Things went for days to weeks without a problem.
The past two days or so I've been going through the Xorg parts of the book, writing down dependencies and notes on paper, getting ready to install Xorg. Note: I've not started work on that, I'm in the planning phase.
The Mesa package lists python 2, not 3, as a dependency. Oh.
Is it possible to install 2 alongside of 3 so that the things I've already compiled that need 3 can still use it correctly?
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616
Rep:
At the end for Python2, do...
make install
At the end for Python3, do...
make altinstall
cd /bin
ln -sv python3.61 python3
or ln -sv python3.6 python3, I can't remember the actual executable name ATM.
Be aware that some packages will install Python components and choose 2 or 3 based upon finding python2 or python3, usually preferring python3. However, sometimes this isn't ideal, because dependent packages, on the package that was used and built an FFI for python3, but the dependent package hasn't yet been updated to Python3. Also, if you need to install a python package dependency like say LXML for CMake (or maybe its actually libarchive), be sure to use pip2 or pip3 appropriately in these cases.
The bottom line is that not everything is Python3 ready yet and, regardless of the Python developer's arm twisting, it will be years before everything is moved over. Sometimes, in order to build a required python2 interface you must remove the python3 symlink to get that to happen. (Policy Kit, for example.) Personally, I don't install python3 until the shell is finished, though that keeps me on Gperf-3.04 & Systemd-232. (with BLFS packages)
So I made a package for the 2 version. This way, I was then able to see what files it was putting where, yet without actually installing it and risking a trashing of anything.
piped directory listings to files, sorted them, ran "comm -12" on them.
The results were surprising. No common files. No common directories, save for /usr/share/man1 and /usr/bin. Wow. This may be because I did not install the documention. Anyway, this means that neither python will stomp on anything from the other python!
In view of that datum, I wonder if I should still do a "altinstall" rebuild/reinstall of 3?
Last edited by jr_bob_dobbs; 05-20-2017 at 10:10 AM.
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616
Rep:
My recommendation was based upon what I read on the official Python website when I researched this very problem. I've run into issues using "make install" on both that using altinstall solved. In any case, programs that use Python don't seem to care how it is installed as long as it can find the python2 or python3 link when they go looking. The hardest part is remembering to use pip2 or pip3 when installing python packages needed by another program.
I've since made packages for 3 and, alt 3 (same source, just using "altinstall" option). I've compared the resultant directory trees. Both have the exact same files in the same arrangement, but diff reveals many differences between the contents of those files. Aha, OK.
I've removed 3, installed 2 and then installed the altinstall version of 3. So far, no problems have emerged.
So this is what is in my /usr/bin directory, python-wise:
Code:
bob@artemis:~/xc/xcb-proto-1.12 $ ls -la /usr/bin/*py*
-rwxr-xr-x 1 root root 36995 May 18 22:35 /usr/bin/a2x.py
-rwxr-xr-x 1 root root 254202 May 18 22:35 /usr/bin/asciidoc.py
-rwxr-xr-x 1 root root 139520 May 14 15:35 /usr/bin/copydatabase
-rwxr-xr-x 1 root root 55635 May 15 21:39 /usr/bin/event_rpcgen.py
-rwxr-xr-x 1 root root 34941 May 16 10:49 /usr/bin/mysqlhotcopy
-rwxr-xr-x 1 root root 224312 Apr 24 22:16 /usr/bin/objcopy
-rwxr-xr-x 1 root root 78 May 20 09:47 /usr/bin/pydoc
-rwxr-xr-x 1 root root 78 May 21 08:06 /usr/bin/pydoc3.6
lrwxrwxrwx 1 root root 7 May 21 08:27 /usr/bin/python -> python2
lrwxrwxrwx 1 root root 9 May 21 08:27 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 6120 May 20 09:48 /usr/bin/python2.7
-rwxr-xr-x 1 root root 1681 May 20 09:47 /usr/bin/python2.7-config
lrwxrwxrwx 1 root root 16 May 21 08:27 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 9 May 23 21:08 /usr/bin/python3 -> python3.6
-rwxr-xr-x 2 root root 10280 May 21 08:06 /usr/bin/python3.6
-rwxr-xr-x 2 root root 10280 May 21 08:06 /usr/bin/python3.6m
-rwxr-xr-x 1 root root 3083 May 21 08:06 /usr/bin/python3.6m-config
lrwxrwxrwx 1 root root 14 May 21 08:27 /usr/bin/python-config -> python2-config
-rwxr-xr-x 1 root root 435 May 21 08:06 /usr/bin/pyvenv-3.6
-rwxr-xr-x 1 root root 18541 May 20 09:47 /usr/bin/smtpd.py
bob@artemis:~/xc/xcb-proto-1.12 $
What concerns me is the "python" that is a symlink to python 2. Should I shift that link to python three? The reason I ask is, I just did a configure & make of a program (xcb-proto for xorg) and it was clearly linking to old python, despite a patch to make said program use python three. needless to say, I stopped at that point and did not install the program.
I have both pythons installed and both python2 and python3 modules installed.
The book says both can exist side-by-side. I haven't had any problems. I suggest
not straying from the book. The writers know more than we do.
Don't know why the patch to python3 didn't work.
I did some work and found an answer. Here's a configure command that works:
PYTHON=/usr/bin/python3 ./configure $XORG_CONFIG
It configured ok and pulled in python3.
Anyway, test it out and see what you think.
You should still apply the patch first. It maybe necessary for this to work. I did.
Last edited by Terry Coats; 05-24-2017 at 12:24 AM.
Reason: did some tests
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.