python3: version detection for --HEAD packages (#7654)
This commit is contained in:
parent
da518ad14f
commit
eec96a68d8
1 changed files with 16 additions and 21 deletions
|
@ -57,19 +57,6 @@ class Python3 < Formula
|
|||
# X11.
|
||||
patch :DATA if build.with? "tcl-tk"
|
||||
|
||||
def lib_cellar
|
||||
prefix/"Frameworks/Python.framework/Versions/#{xy}/lib/python#{xy}"
|
||||
end
|
||||
|
||||
def site_packages_cellar
|
||||
lib_cellar/"site-packages"
|
||||
end
|
||||
|
||||
# The HOMEBREW_PREFIX location of site-packages.
|
||||
def site_packages
|
||||
HOMEBREW_PREFIX/"lib/python#{xy}/site-packages"
|
||||
end
|
||||
|
||||
# setuptools remembers the build flags python is built with and uses them to
|
||||
# build packages later. Xcode-only systems need different flags.
|
||||
pour_bottle? do
|
||||
|
@ -89,6 +76,9 @@ class Python3 < Formula
|
|||
ENV["PYTHONHOME"] = nil
|
||||
ENV["PYTHONPATH"] = nil
|
||||
|
||||
xy = (buildpath/"configure.ac").read.slice(/PYTHON_VERSION, (3\.\d)/, 1)
|
||||
lib_cellar = prefix/"Frameworks/Python.framework/Versions/#{xy}/lib/python#{xy}"
|
||||
|
||||
args = %W[
|
||||
--prefix=#{prefix}
|
||||
--enable-ipv6
|
||||
|
@ -198,7 +188,7 @@ class Python3 < Formula
|
|||
rm bin/"2to3"
|
||||
|
||||
# Remove the site-packages that Python created in its Cellar.
|
||||
site_packages_cellar.rmtree
|
||||
(prefix/"Frameworks/Python.framework/Versions/#{xy}/lib/python#{xy}/site-packages").rmtree
|
||||
|
||||
%w[setuptools pip wheel].each do |r|
|
||||
(libexec/r).install resource(r)
|
||||
|
@ -213,6 +203,10 @@ class Python3 < Formula
|
|||
end
|
||||
|
||||
def post_install
|
||||
xy = (prefix/"Frameworks/Python.framework/Versions").children.first.basename.to_s
|
||||
site_packages = HOMEBREW_PREFIX/"lib/python#{xy}/site-packages"
|
||||
site_packages_cellar = prefix/"Frameworks/Python.framework/Versions/#{xy}/lib/python#{xy}/site-packages"
|
||||
|
||||
# Fix up the site-packages so that user-installed Python software survives
|
||||
# minor updates, such as going from 3.3.2 to 3.3.3:
|
||||
|
||||
|
@ -267,7 +261,8 @@ class Python3 < Formula
|
|||
library_dirs << Formula["homebrew/dupes/tcl-tk"].opt_lib
|
||||
end
|
||||
|
||||
cfg = lib_cellar/"distutils/distutils.cfg"
|
||||
cfg = prefix/"Frameworks/Python.framework/Versions/#{xy}/lib/python#{xy}/distutils/distutils.cfg"
|
||||
|
||||
cfg.atomic_write <<-EOF.undent
|
||||
[install]
|
||||
prefix=#{HOMEBREW_PREFIX}
|
||||
|
@ -278,11 +273,9 @@ class Python3 < Formula
|
|||
EOF
|
||||
end
|
||||
|
||||
def xy
|
||||
version.to_s.slice(/(3\.\d)/) || "3.6"
|
||||
end
|
||||
|
||||
def sitecustomize
|
||||
xy = (prefix/"Frameworks/Python.framework/Versions").children.first.basename.to_s
|
||||
|
||||
<<-EOF.undent
|
||||
# This file is created by Homebrew and is executed on each python startup.
|
||||
# Don't print from here, or else python command line scripts may fail!
|
||||
|
@ -313,7 +306,7 @@ class Python3 < Formula
|
|||
# the Cellar site-packages is a symlink to the HOMEBREW_PREFIX
|
||||
# site_packages; prefer the shorter paths
|
||||
long_prefix = re.compile(r'#{rack}/[0-9\._abrc]+/Frameworks/Python\.framework/Versions/#{xy}/lib/python#{xy}/site-packages')
|
||||
sys.path = [long_prefix.sub('#{site_packages}', p) for p in sys.path]
|
||||
sys.path = [long_prefix.sub('#{HOMEBREW_PREFIX/"lib/python#{xy}/site-packages"}', p) for p in sys.path]
|
||||
|
||||
# Set the sys.executable to use the opt_prefix
|
||||
sys.executable = '#{opt_bin}/python#{xy}'
|
||||
|
@ -321,6 +314,7 @@ class Python3 < Formula
|
|||
end
|
||||
|
||||
def caveats
|
||||
xy = (prefix/"Frameworks/Python.framework/Versions").children.first.basename.to_s
|
||||
text = <<-EOS.undent
|
||||
Pip, setuptools, and wheel have been installed. To update them
|
||||
pip3 install --upgrade pip setuptools wheel
|
||||
|
@ -329,7 +323,7 @@ class Python3 < Formula
|
|||
pip3 install <package>
|
||||
|
||||
They will install into the site-package directory
|
||||
#{site_packages}
|
||||
#{HOMEBREW_PREFIX/"lib/python#{xy}/site-packages"}
|
||||
|
||||
See: https://github.com/Homebrew/brew/blob/master/docs/Homebrew-and-Python.md
|
||||
EOS
|
||||
|
@ -346,6 +340,7 @@ class Python3 < Formula
|
|||
end
|
||||
|
||||
test do
|
||||
xy = (prefix/"Frameworks/Python.framework/Versions").children.first.basename.to_s
|
||||
# Check if sqlite is ok, because we build with --enable-loadable-sqlite-extensions
|
||||
# and it can occur that building sqlite silently fails if OSX's sqlite is used.
|
||||
system "#{bin}/python#{xy}", "-c", "import sqlite3"
|
||||
|
|
Loading…
Reference in a new issue