Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python, python@2: make PEP 394 compliant #25060

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1785285
python: make PEP 394 compliant
ilovezfs Mar 9, 2018
791a4e0
python@2: make PEP 394 compliant
ilovezfs Mar 9, 2018
0345e77
ansible: revision for python@2
ilovezfs Mar 9, 2018
da7a8c0
ansible-lint: revision for python@2
ilovezfs Mar 9, 2018
07b3ee3
awscli: revision for python
ilovezfs Mar 9, 2018
6962dfa
bandcamp-dl: revision for python
ilovezfs Mar 9, 2018
0af5baa
buku: revision for python
ilovezfs Mar 9, 2018
e0ee8bc
conjure-up: revision for python
ilovezfs Mar 9, 2018
1b4580d
csvkit: revision for python
ilovezfs Mar 9, 2018
c63c9e5
csvtomd: revision for python
ilovezfs Mar 9, 2018
7847d10
fdroidserver: revision for python
ilovezfs Mar 9, 2018
4cab71c
httpie: revision for python
ilovezfs Mar 9, 2018
4740e93
juju-wait: revision for python
ilovezfs Mar 9, 2018
d64a9a4
khal: revision for python
ilovezfs Mar 9, 2018
8914b20
khard: revision for python
ilovezfs Mar 9, 2018
96b8018
magic-wormhole: revision for python
ilovezfs Mar 9, 2018
642f373
mitmproxy: revision for python
ilovezfs Mar 9, 2018
2a368bc
molecule: revision for python@2
ilovezfs Mar 9, 2018
b387542
mps-youtube: revision for python and python@2
ilovezfs Mar 9, 2018
7f19709
ponysay: revision for python
ilovezfs Mar 9, 2018
6cd969d
shyaml: revision for python
ilovezfs Mar 9, 2018
6f1b7c3
sip: revision for python and python@2
ilovezfs Mar 9, 2018
68362fd
snapcraft: revision for python
ilovezfs Mar 9, 2018
85fdc5c
thefuck: revision for python
ilovezfs Mar 9, 2018
b6d8736
todoman: revision for python
ilovezfs Mar 9, 2018
208bd41
vdirsyncer: revision for python
ilovezfs Mar 9, 2018
33fb54f
vim: revision for python
ilovezfs Mar 9, 2018
742ba33
vim@7.4: revision for python
ilovezfs Mar 9, 2018
623a9c3
xonsh: revision for python
ilovezfs Mar 9, 2018
003e9e2
you-get: revision for python
ilovezfs Mar 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Formula/ansible-lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class AnsibleLint < Formula
homepage "https://github.com/willthames/ansible-lint/"
url "https://files.pythonhosted.org/packages/cd/d6/7e2abd17c523df9f8ae64694f12805c8f30934363f9eb6a68f9ffcbc2ff8/ansible-lint-3.4.20.tar.gz"
sha256 "1e7f1d5d5ee91b817dedc0b612c2beb5ff44879d592ea17a2eaa6571aa9a2bff"
revision 2
revision 3

bottle do
cellar :any
Expand Down
2 changes: 1 addition & 1 deletion Formula/ansible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Ansible < Formula
homepage "https://www.ansible.com/"
url "https://releases.ansible.com/ansible/ansible-2.4.3.0.tar.gz"
sha256 "0e98b3a56928d03979d5f8e7ae5d8e326939111b298729b03f00b3ad8f998a3d"
revision 2
revision 3
head "https://github.com/ansible/ansible.git", :branch => "devel"

bottle do
Expand Down
1 change: 1 addition & 0 deletions Formula/awscli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Awscli < Formula
# awscli should only be updated every 10 releases on multiples of 10
url "https://github.com/aws/aws-cli/archive/1.14.50.tar.gz"
sha256 "d5705a1c04ce2b9fb6ca6faea3865f5519696b1449064a061eaf5ac35a590ba7"
revision 1
head "https://github.com/aws/aws-cli.git", :branch => "develop"

bottle do
Expand Down
2 changes: 1 addition & 1 deletion Formula/bandcamp-dl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BandcampDl < Formula
url "https://github.com/iheanyi/bandcamp-dl/archive/v0.0.8-10.tar.gz"
version "0.0.8-10"
sha256 "f02b5067faba3d8e133f9121194cb59d33dc3cbff79eeef5349003e812293c7e"
revision 1
revision 2
head "https://github.com/iheanyi/bandcamp-dl.git"

bottle do
Expand Down
2 changes: 1 addition & 1 deletion Formula/buku.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Buku < Formula
homepage "https://github.com/jarun/Buku"
url "https://github.com/jarun/Buku/archive/v3.6.tar.gz"
sha256 "6126dbf820a18af69b0bd24eb86a04a71d4904ba84dc174b98c1050fae8f9fad"
revision 1
revision 2

bottle do
cellar :any
Expand Down
2 changes: 1 addition & 1 deletion Formula/conjure-up.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ConjureUp < Formula
homepage "https://conjure-up.io/"
url "https://github.com/conjure-up/conjure-up/archive/2.5.5.tar.gz"
sha256 "7a16b91c46c1f86eb7bc96597cbdb371ea94d062ff554c71615267cba54f3433"
revision 1
revision 2

bottle do
cellar :any
Expand Down
2 changes: 1 addition & 1 deletion Formula/csvkit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Csvkit < Formula
homepage "https://csvkit.readthedocs.io/"
url "https://files.pythonhosted.org/packages/53/de/a8ee2fb47af463251fd39e0dc2b7356ceb58fd0f5867f7f6d0f7cc6e8a0d/csvkit-1.0.2.tar.gz"
sha256 "5a897f87c920dec3e7debc31102dfe774a8d704641bfafa98e04729bd4d26e17"
revision 2
revision 3

bottle do
cellar :any_skip_relocation
Expand Down
2 changes: 1 addition & 1 deletion Formula/csvtomd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Csvtomd < Formula
homepage "https://github.com/mplewis/csvtomd"
url "https://files.pythonhosted.org/packages/2f/41/289bedde7fb32d817d5802eff68b99546842cb34df840665ec39b363f258/csvtomd-0.2.1.tar.gz"
sha256 "d9fdf166c3c299ad5800b3cb1661f223b98237f38f22e9d253d45d321f70ec72"
revision 2
revision 3

bottle do
cellar :any_skip_relocation
Expand Down
2 changes: 1 addition & 1 deletion Formula/fdroidserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Fdroidserver < Formula
homepage "https://f-droid.org"
url "https://files.pythonhosted.org/packages/df/29/163c75b97f8c83f2eb1f5d55978f630a0a99fda989ad857e78cba6eb64fe/fdroidserver-1.0.2.tar.gz"
sha256 "abb5a16f8e21b4683255a61707d2c31123ad3ab5b091c490aaa524c6b8dfa9a5"
revision 3
revision 4

bottle do
cellar :any
Expand Down
2 changes: 1 addition & 1 deletion Formula/httpie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Httpie < Formula
homepage "https://httpie.org/"
url "https://files.pythonhosted.org/packages/28/93/4ebf2de4bc74bd517a27a600b2b23a5254a20f28e6e36fc876fd98f7a51b/httpie-0.9.9.tar.gz"
sha256 "f1202e6fa60367e2265284a53f35bfa5917119592c2ab08277efc7fffd744fcb"
revision 2
revision 3
head "https://github.com/jkbrzt/httpie.git"

bottle do
Expand Down
2 changes: 1 addition & 1 deletion Formula/juju-wait.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class JujuWait < Formula
homepage "https://launchpad.net/juju-wait"
url "https://files.pythonhosted.org/packages/3d/c2/8cce9ec8386be418a76566fcd2e7dcbaa7138a92b0b9b463306d9191cfd7/juju-wait-2.6.2.tar.gz"
sha256 "86622804896e80f26a3ed15dff979584952ba484ccb5258d8bab6589e26dd46d"
revision 2
revision 3

bottle do
cellar :any
Expand Down
2 changes: 1 addition & 1 deletion Formula/khal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Khal < Formula
url "https://github.com/pimutils/khal.git",
:tag => "v0.9.8",
:revision => "b03df58c129f99a35ba74cda0fbc253eb47cfeac"
revision 2
revision 3
head "https://github.com/pimutils/khal.git"

bottle do
Expand Down
2 changes: 1 addition & 1 deletion Formula/khard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Khard < Formula
homepage "https://github.com/scheibler/khard/"
url "https://files.pythonhosted.org/packages/19/91/6309d5b0477582b9b663cd65f1346cec6ed5f44e734bac722e1ca2ddc1e3/khard-0.12.2.tar.gz"
sha256 "9193d2d07cdb69cc6e35a0732111efb92bbfba854a1dd42b4f9c91a52a16c507"
revision 1
revision 2

bottle do
cellar :any
Expand Down
2 changes: 1 addition & 1 deletion Formula/magic-wormhole.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class MagicWormhole < Formula
homepage "https://github.com/warner/magic-wormhole"
url "https://files.pythonhosted.org/packages/b5/d3/5409c111835af19af00643a8fbd0c0a6f30f025400ca5bb72f59fd1e42fb/magic-wormhole-0.10.5.tar.gz"
sha256 "9558ea1f3551e535deec3462cd5c8391cb32ebb12ecd8b40b36861dbee4917ee"
revision 2
revision 3

bottle do
cellar :any
Expand Down
2 changes: 1 addition & 1 deletion Formula/mitmproxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Mitmproxy < Formula
homepage "https://mitmproxy.org"
url "https://github.com/mitmproxy/mitmproxy/archive/v3.0.3.tar.gz"
sha256 "e1e33275f4b581d7bc54ea0a014dd105d824f2b1da6068889f652fda8610bb5c"
revision 1
revision 2
head "https://github.com/mitmproxy/mitmproxy.git"

bottle do
Expand Down
2 changes: 1 addition & 1 deletion Formula/molecule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Molecule < Formula
homepage "https://molecule.readthedocs.io"
url "https://files.pythonhosted.org/packages/aa/0f/dc6393eed9588e477a23488fbd23efd40246fcc64815179db6c8c892f554/molecule-1.25.1.tar.gz"
sha256 "aeafd3a6c5a0de707308006dcf727883c9daf4446d18d9e68eb97659c51ebbb0"
revision 2
revision 3

bottle do
cellar :any
Expand Down
2 changes: 1 addition & 1 deletion Formula/mps-youtube.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class MpsYoutube < Formula
homepage "https://github.com/mps-youtube/mps-youtube"
url "https://github.com/mps-youtube/mps-youtube/archive/v0.2.8.tar.gz"
sha256 "d5f2c4bc1f57f0566242c4a0a721a5ceaa6d6d407f9d6dd29009a714a0abec74"
revision 1
revision 2

bottle do
cellar :any_skip_relocation
Expand Down
2 changes: 1 addition & 1 deletion Formula/ponysay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Ponysay < Formula
homepage "http://erkin.co/ponysay/"
url "https://github.com/erkin/ponysay/archive/3.0.3.tar.gz"
sha256 "c382d7f299fa63667d1a4469e1ffbf10b6813dcd29e861de6be55e56dc52b28a"
revision 2
revision 3

bottle do
cellar :any_skip_relocation
Expand Down
108 changes: 52 additions & 56 deletions Formula/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Python < Formula
homepage "https://www.python.org/"
url "https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz"
sha256 "159b932bf56aeaa76fd66e7420522d8c8853d486b8567c459b84fe2ed13bcaba"
revision 3
revision 4
head "https://github.com/python/cpython.git"

bottle do
Expand All @@ -18,27 +18,23 @@ class Python < Formula
end

option "with-tcl-tk", "Use Homebrew's Tk instead of macOS Tk (has optional Cocoa and threads support)"
option "with-quicktest", "Run `make quicktest` after the build"
option "with-sphinx-doc", "Build HTML documentation"

deprecated_option "quicktest" => "with-quicktest"
deprecated_option "with-brewed-tk" => "with-tcl-tk"

depends_on "pkg-config" => :build
depends_on "readline" => :recommended
depends_on "sqlite" => :recommended
depends_on "gdbm" => :recommended
depends_on "sphinx-doc" => :build
depends_on "gdbm"
depends_on "openssl"
depends_on "xz" => :recommended # for the lzma module added in 3.3
depends_on "readline"
depends_on "sqlite"
depends_on "xz"
depends_on "tcl-tk" => :optional
depends_on "sphinx-doc" => [:build, :optional]

skip_clean "bin/pip3", "bin/pip-3.4", "bin/pip-3.5", "bin/pip-3.6"
skip_clean "bin/easy_install3", "bin/easy_install-3.4", "bin/easy_install-3.5", "bin/easy_install-3.6"

resource "setuptools" do
url "https://files.pythonhosted.org/packages/6c/54/f7e9cea6897636a04e74c3954f0d8335cc38f7d01e27eec98026b049a300/setuptools-38.5.1.zip"
sha256 "6425484c08e99a98a42209c25c3d325f749230b55284d66192784f941a7e6628"
url "https://files.pythonhosted.org/packages/e0/02/2b14188e06ddf61e5b462e216b15d893e8472fca28b1b0c5d9272ad7e87c/setuptools-38.5.2.zip"
sha256 "8246123e984cadf687163bdcd1bb58eb325e2891b066e1f0224728a41c8d9064"
end

resource "pip" do
Expand Down Expand Up @@ -87,12 +83,12 @@ def install
--datarootdir=#{share}
--datadir=#{share}
--enable-framework=#{frameworks}
--enable-loadable-sqlite-extensions
--without-ensurepip
--with-dtrace
]

args << "--without-gcc" if ENV.compiler == :clang
args << "--enable-loadable-sqlite-extensions" if build.with?("sqlite")

cflags = []
ldflags = []
Expand Down Expand Up @@ -124,12 +120,10 @@ def install
args << "--with-openssl=#{Formula["openssl"].opt_prefix}"
end

if build.with? "sqlite"
inreplace "setup.py" do |s|
s.gsub! "sqlite_setup_debug = False", "sqlite_setup_debug = True"
s.gsub! "for d_ in inc_dirs + sqlite_inc_paths:",
"for d_ in ['#{Formula["sqlite"].opt_include}']:"
end
inreplace "setup.py" do |s|
s.gsub! "sqlite_setup_debug = False", "sqlite_setup_debug = True"
s.gsub! "for d_ in inc_dirs + sqlite_inc_paths:",
"for d_ in ['#{Formula["sqlite"].opt_include}']:"
end

# Allow python modules to use ctypes.find_library to find homebrew's stuff
Expand All @@ -151,18 +145,17 @@ def install
args << "CPPFLAGS=#{cppflags.join(" ")}" unless cppflags.empty?

system "./configure", *args

system "make"
if build.with?("quicktest")
system "make", "quicktest", "TESTPYTHONOPTS=-s", "TESTOPTS=-j#{ENV.make_jobs} -w"
end

ENV.deparallelize do
# Tell Python not to install into /Applications (default for framework builds)
system "make", "install", "PYTHONAPPSDIR=#{prefix}"
system "make", "frameworkinstallextras", "PYTHONAPPSDIR=#{pkgshare}"
end

# Any .app get a " 3" attached, so it does not conflict with python 2.x.
Dir.glob("#{prefix}/*.app") { |app| mv app, app.sub(/\.app$/, " 3.app") }

# Prevent third-party packages from building against fragile Cellar paths
inreplace Dir[lib_cellar/"**/_sysconfigdata_m_darwin_darwin.py",
lib_cellar/"config*/Makefile",
Expand All @@ -179,6 +172,12 @@ def install
%r{('LINKFORSHARED': .*?)'(Python.framework/Versions/3.\d+/Python)'}m,
"\\1'#{opt_prefix}/Frameworks/\\2'"

# A fix, because python and python3 both want to install Python.framework
# and therefore we can't link both into HOMEBREW_PREFIX/Frameworks
# https://github.com/Homebrew/homebrew/issues/15943
["Headers", "Python", "Resources"].each { |f| rm(prefix/"Frameworks/Python.framework/#{f}") }
rm prefix/"Frameworks/Python.framework/Versions/Current"

# Symlink the pkgconfig files into HOMEBREW_PREFIX so they're accessible.
(lib/"pkgconfig").install_symlink Dir["#{frameworks}/Python.framework/Versions/#{xy}/lib/pkgconfig/*"]

Expand All @@ -189,33 +188,23 @@ def install
(libexec/r).install resource(r)
end

if build.with? "sphinx-doc"
cd "Doc" do
system "make", "html"
doc.install Dir["build/html/*"]
end
cd "Doc" do
system "make", "html"
doc.install Dir["build/html/*"]
end

# Install unversioned symlinks.
# Install unversioned symlinks in libexec/bin.
{
"idle" => "idle3",
"pydoc" => "pydoc3",
"python" => "python3",
"python-config" => "python3-config",
}.each do |unversioned_name, versioned_name|
bin.install_symlink (bin/versioned_name).realpath => unversioned_name
(libexec/"bin").install_symlink (bin/versioned_name).realpath => unversioned_name
end
man1.install_symlink man1/"python#{xy}.1" => "python.1"
end

def post_install
# Avoid conflicts during migration from python3
rm_f %W[
#{HOMEBREW_PREFIX}/bin/easy_install
#{HOMEBREW_PREFIX}/bin/pip
#{HOMEBREW_PREFIX}/bin/wheel
]

ENV.delete "PYTHONPATH"

xy = (prefix/"Frameworks/Python.framework/Versions").children.sort.first.basename.to_s
Expand Down Expand Up @@ -254,21 +243,28 @@ def post_install
end
end

bin.install_symlink bin/"wheel" => "wheel3"
rm_rf [bin/"pip", bin/"easy_install"]
mv bin/"wheel", bin/"wheel3"

# Install unversioned symlinks in libexec/bin.
{
"easy_install" => "easy_install-#{xy}",
"pip" => "pip3",
"wheel" => "wheel3",
}.each do |unversioned_name, versioned_name|
(libexec/"bin").install_symlink (bin/versioned_name).realpath => unversioned_name
end

# post_install happens after link
%W[pip pip3 pip#{xy} easy_install easy_install-#{xy} wheel wheel3].each do |e|
%W[pip3 pip#{xy} easy_install-#{xy} wheel3].each do |e|
(HOMEBREW_PREFIX/"bin").install_symlink bin/e
end

# Help distutils find brewed stuff when building extensions
include_dirs = [HOMEBREW_PREFIX/"include", Formula["openssl"].opt_include]
library_dirs = [HOMEBREW_PREFIX/"lib", Formula["openssl"].opt_lib]

if build.with? "sqlite"
include_dirs << Formula["sqlite"].opt_include
library_dirs << Formula["sqlite"].opt_lib
end
include_dirs = [HOMEBREW_PREFIX/"include", Formula["openssl"].opt_include,
Formula["sqlite"].opt_include]
library_dirs = [HOMEBREW_PREFIX/"lib", Formula["openssl"].opt_lib,
Formula["sqlite"].opt_lib]

if build.with? "tcl-tk"
include_dirs << Formula["tcl-tk"].opt_include
Expand Down Expand Up @@ -334,17 +330,16 @@ def caveats
xy = version.to_s.slice(/(3\.\d)/) || "3.6"
end
text = <<~EOS
Python has been installed as
#{HOMEBREW_PREFIX}/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
#{HOMEBREW_PREFIX}/bin
#{opt_libexec}/bin

If you need Homebrew's Python 2.7 run
brew install python@2

If you wish to have python@2's python and python2 executables in your PATH then
add the following to #{shell_profile}:
export PATH="#{HOMEBREW_PREFIX}/opt/python@2/libexec/bin:#{HOMEBREW_PREFIX}/opt/python@2/bin:$PATH"

Pip, setuptools, and wheel have been installed. To update them run
pip3 install --upgrade pip setuptools wheel

Expand All @@ -368,13 +363,14 @@ def caveats
end

test do
xy = (prefix/"Frameworks/Python.framework/Versions").children.sort.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", "-c", "import sqlite3"
system "#{bin}/python#{xy}", "-c", "import sqlite3"
# Check if some other modules import. Then the linked libs are working.
system "#{bin}/python", "-c", "import tkinter; root = tkinter.Tk()"
system "#{bin}/python", "-c", "import _gdbm"
system bin/"pip", "list", "--format=columns"
system "#{bin}/python#{xy}", "-c", "import tkinter; root = tkinter.Tk()"
system "#{bin}/python#{xy}", "-c", "import _gdbm"
system bin/"pip3", "list", "--format=columns"
end
end

Expand Down
Loading