LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   two pythons (https://www.linuxquestions.org/questions/linux-from-scratch-13/two-pythons-4175606312/)

jr_bob_dobbs 05-19-2017 07:51 PM

two pythons
 
So two pythons walk into a bar ...



just kidding. ;)

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. :o

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?

Luridis 05-19-2017 10:45 PM

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)

jr_bob_dobbs 05-20-2017 10:08 AM

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?

Luridis 05-20-2017 08:34 PM

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.

jr_bob_dobbs 05-22-2017 12:44 PM

I think I understand better now. Thank you.

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.

On to Xorg, I guess, once backups are done. :)

Luridis 05-22-2017 02:09 PM

Don't forget the python3 link to the actual executable, or programs that need 3 won't find it.

Luridis 05-22-2017 02:11 PM

Oh, and the differences inside the files are likely explicit specifications of Python3 instead of just Python.

jr_bob_dobbs 05-23-2017 11:02 PM

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.

Terry Coats 05-23-2017 11:55 PM

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.


All times are GMT -5. The time now is 05:02 PM.