diff --git a/Aliases/python b/Aliases/python index a5dfdd3cfd76..dd83cc1dfc3e 120000 --- a/Aliases/python +++ b/Aliases/python @@ -1 +1 @@ -../Formula/python@3.10.rb \ No newline at end of file +../Formula/python@3.11.rb \ No newline at end of file diff --git a/Aliases/python-tk b/Aliases/python-tk index c46ab5447731..0a1dd488a989 120000 --- a/Aliases/python-tk +++ b/Aliases/python-tk @@ -1 +1 @@ -../Formula/python-tk@3.10.rb \ No newline at end of file +../Formula/python-tk@3.11.rb \ No newline at end of file diff --git a/Aliases/python3 b/Aliases/python3 index a5dfdd3cfd76..dd83cc1dfc3e 120000 --- a/Aliases/python3 +++ b/Aliases/python3 @@ -1 +1 @@ -../Formula/python@3.10.rb \ No newline at end of file +../Formula/python@3.11.rb \ No newline at end of file diff --git a/Aliases/python@3 b/Aliases/python@3 index a5dfdd3cfd76..dd83cc1dfc3e 120000 --- a/Aliases/python@3 +++ b/Aliases/python@3 @@ -1 +1 @@ -../Formula/python@3.10.rb \ No newline at end of file +../Formula/python@3.11.rb \ No newline at end of file diff --git a/Formula/python@3.10.rb b/Formula/python@3.10.rb index 9adf73b0881b..472ae5a3a659 100644 --- a/Formula/python@3.10.rb +++ b/Formula/python@3.10.rb @@ -48,22 +48,6 @@ class PythonAT310 < Formula skip_clean "bin/easy_install3", "bin/easy_install-3.4", "bin/easy_install-3.5", "bin/easy_install-3.6", "bin/easy_install-3.7", "bin/easy_install-3.8", "bin/easy_install-3.9" - link_overwrite "bin/2to3" - link_overwrite "bin/idle3" - link_overwrite "bin/pip3" - link_overwrite "bin/pydoc3" - link_overwrite "bin/python3" - link_overwrite "bin/python3-config" - link_overwrite "bin/wheel3" - link_overwrite "share/man/man1/python3.1" - link_overwrite "lib/libpython3.so" - link_overwrite "lib/pkgconfig/python3.pc" - link_overwrite "lib/pkgconfig/python3-embed.pc" - 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" - # Always update to latest release resource "setuptools" do url "https://files.pythonhosted.org/packages/5f/36/7374297692bb9dbd7569a0f84887c7e5e314c41d5d9518cb76fbb130620d/setuptools-67.2.0.tar.gz" @@ -226,8 +210,12 @@ def install system "make" ENV.deparallelize do + # The `altinstall` target prevents the installation of files with only Python's major + # version in its name. This allows us to link multiple versioned Python formulae. + # https://github.com/python/cpython#installing-multiple-versions + # # Tell Python not to install into /Applications (default for framework builds) - system "make", "install", "PYTHONAPPSDIR=#{prefix}" + system "make", "altinstall", "PYTHONAPPSDIR=#{prefix}" system "make", "frameworkinstallextras", "PYTHONAPPSDIR=#{pkgshare}" if OS.mac? end @@ -253,10 +241,16 @@ def install /^LINKFORSHARED=(.*)PYTHONFRAMEWORKDIR(.*)/, "LINKFORSHARED=\\1PYTHONFRAMEWORKINSTALLDIR\\2" + # Symlink the pkgconfig files into HOMEBREW_PREFIX so they're accessible. + (lib/"pkgconfig").install_symlink pc_dir.children + # Fix for https://github.com/Homebrew/homebrew-core/issues/21212 inreplace lib_cellar/"_sysconfigdata__darwin_darwin.py", %r{('LINKFORSHARED': .*?)'(Python.framework/Versions/3.\d+/Python)'}m, "\\1'#{opt_prefix}/Frameworks/\\2'" + + # Remove symlinks that conflict with the main Python formula. + rm %w[Headers Python Resources Versions/Current].map { |subdir| frameworks/"Python.framework"/subdir } else # Prevent third-party packages from building against fragile Cellar paths inreplace Dir[lib_cellar/"**/_sysconfigdata_*linux_x86_64-*.py", @@ -268,6 +262,9 @@ def install inreplace bin/"python#{version.major_minor}-config", 'prefix_real=$(installed_prefix "$0")', "prefix_real=#{opt_prefix}" + + # Remove symlinks that conflict with the main Python formula. + rm lib/"libpython3.so" end # Remove the site-packages that Python created in its Cellar. @@ -309,12 +306,16 @@ def install # Write out sitecustomize.py (lib_cellar/"sitecustomize.py").atomic_write(sitecustomize) - # Install unversioned symlinks in libexec/bin. + # Install unversioned and major-versioned symlinks in libexec/bin. { - "idle" => "idle#{version.major_minor}", - "pydoc" => "pydoc#{version.major_minor}", - "python" => "python#{version.major_minor}", - "python-config" => "python#{version.major_minor}-config", + "idle" => "idle#{version.major_minor}", + "idle3" => "idle#{version.major_minor}", + "pydoc" => "pydoc#{version.major_minor}", + "pydoc3" => "pydoc#{version.major_minor}", + "python" => "python#{version.major_minor}", + "python3" => "python#{version.major_minor}", + "python-config" => "python#{version.major_minor}-config", + "python3-config" => "python#{version.major_minor}-config", }.each do |short_name, long_name| (libexec/"bin").install_symlink (bin/long_name).realpath => short_name end @@ -368,20 +369,21 @@ def post_install mv (site_packages/"bin").children, bin rmdir site_packages/"bin" - rm_rf bin/"pip" + rm_rf bin.glob("pip{,3}") mv bin/"wheel", bin/"wheel#{version.major_minor}" - bin.install_symlink "wheel#{version.major_minor}" => "wheel3" - # Install unversioned symlinks in libexec/bin. + # Install unversioned and major-versioned symlinks in libexec/bin. { - "pip" => "pip#{version.major_minor}", - "wheel" => "wheel#{version.major_minor}", + "pip" => "pip#{version.major_minor}", + "pip3" => "pip#{version.major_minor}", + "wheel" => "wheel#{version.major_minor}", + "wheel3" => "wheel#{version.major_minor}", }.each do |short_name, long_name| (libexec/"bin").install_symlink (bin/long_name).realpath => short_name end # post_install happens after link - %W[wheel3 pip3 wheel#{version.major_minor} pip#{version.major_minor}].each do |e| + %W[wheel#{version.major_minor} pip#{version.major_minor}].each do |e| (HOMEBREW_PREFIX/"bin").install_symlink bin/e end end @@ -445,20 +447,23 @@ def sitecustomize def caveats <<~EOS Python has been installed as - #{HOMEBREW_PREFIX}/bin/python3 + #{HOMEBREW_PREFIX}/bin/python#{version.major_minor} - Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to - `python3`, `python3-config`, `pip3` etc., respectively, have been installed into + Unversioned and major-versioned symlinks `python`, `python3`, `python-config`, `python3-config`, `pip`, `pip3`, etc. pointing to + `python#{version.major_minor}`, `python#{version.major_minor}-config`, `pip#{version.major_minor}` etc., respectively, have been installed into #{opt_libexec}/bin You can install Python packages with - pip3 install + pip#{version.major_minor} install They will install into the site-package directory #{HOMEBREW_PREFIX}/lib/python#{version.major_minor}/site-packages tkinter is no longer included with this formula, but it is available separately: brew install python-tk@#{version.major_minor} + If you do not need a specific version of Python, and always want Homebrew's `python3` in your PATH: + brew install python3 + See: https://docs.brew.sh/Homebrew-and-Python EOS end diff --git a/Formula/python@3.11.rb b/Formula/python@3.11.rb index 605d8dcdb487..4371f6b4f0e7 100644 --- a/Formula/python@3.11.rb +++ b/Formula/python@3.11.rb @@ -49,6 +49,22 @@ class PythonAT311 < Formula skip_clean "bin/easy_install3", "bin/easy_install-3.4", "bin/easy_install-3.5", "bin/easy_install-3.6", "bin/easy_install-3.7", "bin/easy_install-3.8", "bin/easy_install-3.9", "bin/easy_install-3.10" + link_overwrite "bin/2to3" + link_overwrite "bin/idle3" + link_overwrite "bin/pip3" + link_overwrite "bin/pydoc3" + link_overwrite "bin/python3" + link_overwrite "bin/python3-config" + link_overwrite "bin/wheel3" + link_overwrite "share/man/man1/python3.1" + link_overwrite "lib/libpython3.so" + link_overwrite "lib/pkgconfig/python3.pc" + link_overwrite "lib/pkgconfig/python3-embed.pc" + 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" + # Always update to latest release resource "setuptools" do url "https://files.pythonhosted.org/packages/b6/21/cb9a8d0b2c8597c83fce8e9c02884bce3d4951e41e807fc35791c6b23d9a/setuptools-65.6.3.tar.gz" @@ -213,12 +229,8 @@ def install system "make" ENV.deparallelize do - # The `altinstall` target prevents the installation of files with only Python's major - # version in its name. This allows us to link multiple versioned Python formulae. - # https://github.com/python/cpython#installing-multiple-versions - # # Tell Python not to install into /Applications (default for framework builds) - system "make", "altinstall", "PYTHONAPPSDIR=#{prefix}" + system "make", "install", "PYTHONAPPSDIR=#{prefix}" system "make", "frameworkinstallextras", "PYTHONAPPSDIR=#{pkgshare}" if OS.mac? end @@ -251,9 +263,6 @@ def install inreplace lib_cellar/"_sysconfigdata__darwin_darwin.py", %r{('LINKFORSHARED': .*?)'(Python.framework/Versions/3.\d+/Python)'}m, "\\1'#{opt_prefix}/Frameworks/\\2'" - - # Remove symlinks that conflict with the main Python formula. - rm %w[Headers Python Resources Versions/Current].map { |subdir| frameworks/"Python.framework"/subdir } else # Prevent third-party packages from building against fragile Cellar paths inreplace Dir[lib_cellar/"**/_sysconfigdata_*linux_x86_64-*.py", @@ -265,9 +274,6 @@ def install inreplace bin/"python#{version.major_minor}-config", 'prefix_real=$(installed_prefix "$0")', "prefix_real=#{opt_prefix}" - - # Remove symlinks that conflict with the main Python formula. - rm lib/"libpython3.so" end # Remove the site-packages that Python created in its Cellar. @@ -309,16 +315,12 @@ def install # Write out sitecustomize.py (lib_cellar/"sitecustomize.py").atomic_write(sitecustomize) - # Install unversioned and major-versioned symlinks in libexec/bin. + # Install unversioned symlinks in libexec/bin. { - "idle" => "idle#{version.major_minor}", - "idle3" => "idle#{version.major_minor}", - "pydoc" => "pydoc#{version.major_minor}", - "pydoc3" => "pydoc#{version.major_minor}", - "python" => "python#{version.major_minor}", - "python3" => "python#{version.major_minor}", - "python-config" => "python#{version.major_minor}-config", - "python3-config" => "python#{version.major_minor}-config", + "idle" => "idle#{version.major_minor}", + "pydoc" => "pydoc#{version.major_minor}", + "python" => "python#{version.major_minor}", + "python-config" => "python#{version.major_minor}-config", }.each do |short_name, long_name| (libexec/"bin").install_symlink (bin/long_name).realpath => short_name end @@ -372,21 +374,20 @@ def post_install mv (site_packages/"bin").children, bin rmdir site_packages/"bin" - rm_rf bin.glob("pip{,3}") + rm_rf bin/"pip" mv bin/"wheel", bin/"wheel#{version.major_minor}" + bin.install_symlink "wheel#{version.major_minor}" => "wheel3" - # Install unversioned and major-versioned symlinks in libexec/bin. + # Install unversioned symlinks in libexec/bin. { - "pip" => "pip#{version.major_minor}", - "pip3" => "pip#{version.major_minor}", - "wheel" => "wheel#{version.major_minor}", - "wheel3" => "wheel#{version.major_minor}", + "pip" => "pip#{version.major_minor}", + "wheel" => "wheel#{version.major_minor}", }.each do |short_name, long_name| (libexec/"bin").install_symlink (bin/long_name).realpath => short_name end # post_install happens after link - %W[wheel#{version.major_minor} pip#{version.major_minor}].each do |e| + %W[wheel3 pip3 wheel#{version.major_minor} pip#{version.major_minor}].each do |e| (HOMEBREW_PREFIX/"bin").install_symlink bin/e end end @@ -451,17 +452,14 @@ def sitecustomize def caveats <<~EOS Python has been installed as - #{HOMEBREW_PREFIX}/bin/python#{version.major_minor} + #{HOMEBREW_PREFIX}/bin/python3 - Unversioned and major-versioned symlinks `python`, `python3`, `python-config`, `python3-config`, `pip`, `pip3`, etc. pointing to - `python#{version.major_minor}`, `python#{version.major_minor}-config`, `pip#{version.major_minor}` etc., respectively, have been installed into + Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to + `python3`, `python3-config`, `pip3` etc., respectively, have been installed into #{opt_libexec}/bin - If you do not need a specific version of Python, and always want Homebrew's `python3` in your PATH: - brew install python3 - You can install Python packages with - pip#{version.major_minor} install + pip3 install They will install into the site-package directory #{HOMEBREW_PREFIX}/lib/python#{version.major_minor}/site-packages