Enable linking multiple Python formulae#107517
Enable linking multiple Python formulae#107517carlocab wants to merge 10 commits intoHomebrew:masterfrom
Conversation
a56c57e to
6598029
Compare
b19b708 to
5a5f61a
Compare
This comment was marked as resolved.
This comment was marked as resolved.
5a5f61a to
e0a4730
Compare
Rylan12
left a comment
There was a problem hiding this comment.
Doesn't this mean that if you run brew install python@3.9 (no alias so no auto upgrade to python@3.10) and then have a script that relies on /opt/homebrew/bin/python3 it will no longer work unless you manually install python@3.10?
Yes. But the same thing happens whenever we make |
e0a4730 to
7472b2d
Compare
Formula/python@3.9.rb
Outdated
There was a problem hiding this comment.
@Rylan12 this should help a bit with users who really just want python3 (of whatever version) but did brew install python@3.9.
It won't make it go away, since not everyone reads the caveats, but it should help a bit.
|
https://github.com/Homebrew/homebrew-core/runs/7748711279?check_suite_focus=true#step:10:6888 Seems unrelated to Python, but not certain. Any ideas, @Bo98? |
|
Probably a bad file in that machine's module cache. That's annoying. It shouldn't affect ephemeral at least. I do pass a custom Before the SwiftPM test, try |
|
I plan to rebase, update |
This makes sure that Python does not install major-versioned files (e.g. `python3`, `python3-config`) and instead only installs files with both a major and minor version (e.g. `python3.9`, `python3.9-config`). This will allow us to have multiple versions of Python linked into `HOMEBREW_PREFIX` without conflicts. If users want to call `python3.9` as `python3`, then they can add `libexec/"bin"` to their `PATH`. Going forward, this will help simplify migrating to newer versions of Python, since we will not need to make the newer version keg-only while dependent formulae are migrated. See discussion at Homebrew/discussions#2776, and documentation at https://github.com/python/cpython#installing-multiple-versions Closes Homebrew#87075.
The previous commit minimises the conflict between `python@3.9` and `python@3.10`. The rest is handled by the `link_overwrite` lines.
Previous changes allow Python 3.9 and Python 3.10 to be linked at the same time.
Co-authored-by: XuehaiPan <XuehaiPan@pku.edu.cn>
Co-authored-by: XuehaiPan <XuehaiPan@pku.edu.cn>
|
This is ready for review. Some dependents will still fail, but all failures should have fixes in progress. See #107517 (comment). I hope to be able to merge this once CI completes. |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Makes sense to me. One small question.
| link_overwrite "Frameworks/Python.framework/Headers" | ||
| link_overwrite "Frameworks/Python.framework/Python" | ||
| link_overwrite "Frameworks/Python.framework/Resources" | ||
| link_overwrite "Frameworks/Python.framework/Versions/Current" |
There was a problem hiding this comment.
Does this mean whichever version is linked last will be Current?
There was a problem hiding this comment.
I contemplated that, but found it too confusing, so decided against it.
In this PR, only the newest Python in Homebrew/core (i.e. python@3.10) will have these symlinks.
I would like to find a way to do it so that the newest Python you have installed will have these symlinks, so that the behaviour is consistent and predictable, but im punting on that for now.
There was a problem hiding this comment.
I contemplated that, but found it too confusing, so decided against it.
Agreed, I think it's better this way.
In this PR, only the newest Python in Homebrew/core (i.e.
python@3.10) will have these symlinks.
How do we ensure these get updated/migrated on a new Python version? Audit? Could do something like fail if the alias doesn't point to python.
There was a problem hiding this comment.
How do we ensure these get updated/migrated on a new Python version? Audit? Could do something like fail if the alias doesn't point to
python.
Yup, we should add an audit for this. Will look at one soon.
There was a problem hiding this comment.
@carlocab Sounds great, doesn't need to block this PR 👍🏻
altinstalltargetHOMEBREW_PREFIXThe primary change (see first commit) uses the
altinstalltarget in the PythonMakefileto make sure that Python3.9 only installs files that contain Python's major and minor version. That is,python@3.9will now install onlypython3.9,python3.9-config, etc., instead ofpython3andpython3-config.This will allow users to have both
python@3.9andpython@3.10linked intoHOMEBREW_PREFIXsimultaneously. Users who wish to callpython3.9aspython3can addlibexec/"bin"to theirPATH.Going forward, I believe this will help simplify migrating to newer Python versions, since there will be no need to make the newer version keg-only while most dependent formulae still depend on the older version of Python.
I've made a lot of changes here. For ease of review, I placed substantive changes in the first two commits. The third and fourth commits are refactoring, and the
last twofifth and sixth update non-formula files.I have not tested this on Linux. This may require a few more adjustments there.
See discussion at Homebrew/discussions#2776 and documentation at https://github.com/python/cpython#installing-multiple-versions.
Closes #87075.
brew install --build-from-source <formula>, where<formula>is the name of the formula you're submitting?brew test <formula>, where<formula>is the name of the formula you're submitting?brew audit --strict <formula>(after doingbrew install --build-from-source <formula>)? If this is a new formula, does it passbrew audit --new <formula>?