Why is python@2 keg-only?


(Frédéric Devernay) #1

Python 2 and Python 3 can easily coexist on the same filesystem (every linux distrib has both python versions installed in the standard PATH). So why is this (new) formula keg-only?
IMHO “python2” should by default (without modifying the bash_profile) be homebrew’s python2 if python@2 is installed, not the old macOS python2…
All we need is to have the proper binaries at the default location. This should at least be an option (without brew link --froce python@2)
cd /usr/local/bin
ln -s …/opt/python2/bin/2 .


Getmail throws warnings since python (2 -> 3) changes [solved]
(Mike McQuaid) #2

Versioned (i.e. @) formulae are keg-only. As mentioned: you can brew link --force if desired.


#3

But can you link both python & python@2?


(Mike McQuaid) #4

Yep, you can link both at once.


(Frédéric Devernay) #5

but if you link both, the link order is important, because both provide “bin/python”. What would be nice is to always link the non-common paths (eg bin/python2 from python@2), but the common paths (eg bin/python) would come from python3.
Is that possible?


(David Woods) #6

So the original question wasn’t answered, why is python 2 now keg only?
This is the second time in a year that brew has completely changed the flow for using python 2 breaking all active scripts. I’m currently looking at a situation where any developer that updates their brew will no longer be able to run any scripts, once again.

In 2017 brew install python2 placed python2 ahead of /usr/bin/python to be python. After that it was brew install python2 gave us python2 like linux and brew install python3 gave us python3 with python being the system default of /usr/bin/python. Now the installing python3 replaces the default python and installing python2 doesn’t not link python2. So my python brew_update.py script now gets run in python2 the first time and python3 the second time.

I guess if brew is going to upgrade without concern for how things are in linux, and with no consideration for backward compatibility is given. What are my options to replace brew? Should I just fork and self host? Because I’m already doing that for android-sdk, and android-ndk. Since brew doesn’t understand that people need support for more than the last two versions.


(Jacob Ledbetter) #7

Because of the python project has announced that python2 will be deprecated in 2 years.
https://pythonclock.org


(Mike McQuaid) #10

Whatever they may be this forum is not the place for that discussion.


(Mike McQuaid) #11

brew link python@2 will not provide python. You can read brew info python@2 for how to do that.


(David Woods) #12

That’s two years away. And the link for python2 should have been added on install.


(David Woods) #13

Actually a products forum is the perfect place to add a tongue-and-cheek complaint about a decision the product has made.


(Mike McQuaid) #14

We disagree. You have the entire internet in which to make your voice heard.


(Frédéric Devernay) #15

actually it’s brew link --force python@2, but nevermind.
It still totally escapes me why python2 is keg-only:
do we really prefer the macOS python2 to the homebrew python2?
python2 still has two years to live, so does it mean we should use the even older python2 from macOS ? Note that it’s still python 2.6.1 on Snow Leopard, which I’m using.
Why not just make a python2 recipe, instead of python@2, and make it not keg-only? This would totally make sense.
Just every linux distribution still has python 2 in the standard path, although everyone knows it will be dead in 2 years, 1 month, etc.


(Mike McQuaid) #16

It is deprecated now. It has two more years before it’s unmaintained. You may be happy waiting right until that deadline but we are not.

https://docs.brew.sh/Versions explains how and why our versioned formulae work the way they do.

Arch Linux does not.


(Frédéric Devernay) #17

huh? https://www.archlinux.org/packages/extra/x86_64/python2/
note that python2 is in /usr/bin

I wouldn’t consider a software released 6 months ago as deprecated/unmaintained. 2.7.14 was released 2017-09-16, that’s not two years ago.

Note that many commercial software, such as those distributed by Autodesk or the Foundry, are still using python 2.7 for scripting (that includes Maya, Flame, Nuke, and many other). They plan on moving to python 3 in 2019, but there is no strong commitment, since it breaks a lot of scripting code produced by the users/clients. Reference: http://www.vfxplatform.com/


(Dirk Jonker) #18

On Arch, /usr/bin/python will start Python 3. Python 2 (when installed) is located at /usr/bin/python2
This is similar to Homebrew.

Fedora is also switching to Python 3 as a default: https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3

Currently, Fedora (27) comes with only Python 3, but is located at /usr/bin/python3
Python 2 has to be explicitly installed and will then still be available at /usr/bin/python. They plan to change this behavior, but not until ~ Fedora 32 (to be released in 2020).

I guess it’s a matter of how fast you want to move and how much you care about backward compatibility.


(Frédéric Devernay) #19

This is not similiar:
homebrew’s python2 is not in the standard path. That’s the whole point of this discussion (see the title).

It is very good that “python” is python 3 by default, I do not deny that.

But homebrew’s python 2 should be available by default in the default path, if installed, under the names "python2 and “python2.7”, without having to “brew link --force python@2” (with “–force” implying that we are doing something wrong).

If the homebrew versioning system prevents that, then why not move python@2 to a “python2” package instead.

Once again, all Linux distribs have python2 and python3 in the standard path, when both are installed. This is just how it should be on homebrew, and it prevents using the macOS python2 executables.


(Mike McQuaid) #20

This is their Python package: https://www.archlinux.org/packages/extra/x86_64/python/

No other package manager has the concept of keg_only and Homebrew doesn’t put anything in /usr/bin.


(Dirk Jonker) #21

You are absolutely right. Sorry, I must have mixed it up editing the sentence. I meant to say that the arch Python 3 behavior is similar to Homebrew, i.e. it installs Python3 at PATH/python by default etc.


(Mike McQuaid) #22

This conversation is going around in circles. We have heard the feedback.