aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2018-03-03 09:42:25 +0000
committerMike McQuaid2018-03-03 09:42:25 +0000
commit70253f0009ee8095a5d10ee7bdd891f1fe5cc35c (patch)
tree4e161095ae6bce7c24bb7a9bd8b1abce43108b1c /Library
parent84d718cbef0b96ef621a2ec51171f7d66c20f87d (diff)
downloadbrew-70253f0009ee8095a5d10ee7bdd891f1fe5cc35c.tar.bz2
Adjust docs and more internal code for Python 3.
Now we have `python` for Python 3 and `python@2` for Python 2 some more adjustments need to be made.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/compat/dependency_collector.rb6
-rw-r--r--Library/Homebrew/compat/requirements.rb8
-rw-r--r--Library/Homebrew/compat/requirements/language_module_requirement.rb8
-rw-r--r--Library/Homebrew/diagnostic.rb2
-rw-r--r--Library/Homebrew/exceptions.rb4
-rw-r--r--Library/Homebrew/formula.rb8
-rw-r--r--Library/Homebrew/language/python.rb24
-rw-r--r--Library/Homebrew/test/language_module_requirement_spec.rb4
8 files changed, 30 insertions, 34 deletions
diff --git a/Library/Homebrew/compat/dependency_collector.rb b/Library/Homebrew/compat/dependency_collector.rb
index 88d393488..8bea8a5aa 100644
--- a/Library/Homebrew/compat/dependency_collector.rb
+++ b/Library/Homebrew/compat/dependency_collector.rb
@@ -52,11 +52,11 @@ class DependencyCollector
output_deprecation(spec, "open-mpi")
Dependency.new("open-mpi", tags)
when :python, :python2
+ output_deprecation(spec, "python@2")
+ Dependency.new("python@2", tags)
+ when :python3
output_deprecation(spec, "python")
Dependency.new("python", tags)
- when :python3
- output_deprecation(spec, "python3")
- Dependency.new("python3", tags)
when :emacs, :mysql, :perl, :postgresql, :rbenv, :ruby
output_deprecation(spec)
Dependency.new(spec.to_s, tags)
diff --git a/Library/Homebrew/compat/requirements.rb b/Library/Homebrew/compat/requirements.rb
index 38344c1fc..3dd5c7479 100644
--- a/Library/Homebrew/compat/requirements.rb
+++ b/Library/Homebrew/compat/requirements.rb
@@ -84,16 +84,16 @@ end
class PythonRequirement < Requirement
fatal true
satisfy do
- odeprecated("PythonRequirement", "'depends_on \"python\"'")
- which "python"
+ odeprecated("PythonRequirement", "'depends_on \"python@2\"'")
+ which "python2"
end
end
class Python3Requirement < Requirement
fatal true
satisfy do
- odeprecated("Python3Requirement", "'depends_on \"python3\"'")
- which "python3"
+ odeprecated("Python3Requirement", "'depends_on \"python\"'")
+ which "python"
end
end
diff --git a/Library/Homebrew/compat/requirements/language_module_requirement.rb b/Library/Homebrew/compat/requirements/language_module_requirement.rb
index 5ddce7a66..fc9dcc442 100644
--- a/Library/Homebrew/compat/requirements/language_module_requirement.rb
+++ b/Library/Homebrew/compat/requirements/language_module_requirement.rb
@@ -38,9 +38,9 @@ class LanguageModuleRequirement < Requirement
when :perl
["/usr/bin/env", "perl", "-e", "use #{@import_name}"]
when :python
- ["/usr/bin/env", "python", "-c", "import #{@import_name}"]
+ ["/usr/bin/env", "python2", "-c", "import #{@import_name}"]
when :python3
- ["/usr/bin/env", "python3", "-c", "import #{@import_name}"]
+ ["/usr/bin/env", "python", "-c", "import #{@import_name}"]
when :ruby
["/usr/bin/env", "ruby", "-rubygems", "-e", "require '#{@import_name}'"]
end
@@ -51,8 +51,8 @@ class LanguageModuleRequirement < Requirement
when :lua then "luarocks-5.2 install"
when :lua51 then "luarocks-5.1 install"
when :perl then "cpan -i"
- when :python then "pip install"
- when :python3 then "pip3 install"
+ when :python then "pip3 install"
+ when :python3 then "pip install"
when :ruby then "gem install"
end
end
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index 8cbf124e6..79f5b2f1d 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -934,7 +934,7 @@ module Homebrew
from your PATH variable.
Python scripts will now install into #{HOMEBREW_PREFIX}/bin.
You can delete anything, except 'Extras', from the #{HOMEBREW_PREFIX}/share/python
- (and #{HOMEBREW_PREFIX}/share/python3) dir and install affected Python packages
+ (and #{HOMEBREW_PREFIX}/share/python@2) dir and install affected Python packages
anew with `pip install --upgrade`.
EOS
end
diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb
index 42c62338a..20ad2a378 100644
--- a/Library/Homebrew/exceptions.rb
+++ b/Library/Homebrew/exceptions.rb
@@ -343,8 +343,8 @@ class FormulaAmbiguousPythonError < RuntimeError
def initialize(formula)
super <<~EOS
The version of python to use with the virtualenv in the `#{formula.full_name}` formula
- cannot be guessed automatically. If the simultaneous use of python and python3
- is intentional, please add `:using => "python"` or `:using => "python3"` to
+ cannot be guessed automatically. If the simultaneous use of python and python@2
+ is intentional, please add `:using => "python"` or `:using => "python@2"` to
`virtualenv_install_with_resources` to resolve the ambiguity manually.
EOS
end
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 228eb537b..521c62637 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -2201,12 +2201,12 @@ class Formula
# # `build.with?` or `build.without? "another_formula"`:
# depends_on "postgresql" if build.without? "sqlite"
#
+ # <pre># Python 3.x if the `--with-python` is given to `brew install example`
+ # depends_on "python3" => :optional</pre>
# <pre># Python 2.7:
- # depends_on "python"</pre>
+ # depends_on "python@2"</pre>
# <pre># Python 2.7 but use system Python where possible
- # depends_on "python" if MacOS.version <= :snow_leopard</pre>
- # <pre># Python 3.x if the `--with-python3` is given to `brew install example`
- # depends_on "python3" => :optional</pre>
+ # depends_on "python@2" if MacOS.version <= :snow_leopard</pre>
def depends_on(dep)
specs.each { |spec| spec.depends_on(dep) }
end
diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb
index 648abb5b1..898f2ae59 100644
--- a/Library/Homebrew/language/python.rb
+++ b/Library/Homebrew/language/python.rb
@@ -89,7 +89,7 @@ module Language
# @param venv_root [Pathname, String] the path to the root of the virtualenv
# (often `libexec/"venv"`)
# @param python [String] which interpreter to use (e.g. "python"
- # or "python3")
+ # or "python2")
# @param formula [Formula] the active Formula
# @return [Virtualenv] a {Virtualenv} instance
def virtualenv_create(venv_root, python = "python", formula = self)
@@ -115,8 +115,8 @@ module Language
# Returns true if a formula option for the specified python is currently
# active or if the specified python is required by the formula. Valid
- # inputs are "python", "python3", :python, and :python3. Note that
- # "with-python", "without-python", "with-python3", and "without-python3"
+ # inputs are "python", "python2", :python, and :python2. Note that
+ # "with-python", "without-python", "with-python@2", and "without-python@2"
# formula options are handled correctly even if not associated with any
# corresponding depends_on statement.
# @api private
@@ -128,16 +128,16 @@ module Language
# Helper method for the common case of installing a Python application.
# Creates a virtualenv in `libexec`, installs all `resource`s defined
# on the formula, and then installs the formula. An options hash may be
- # passed (e.g., :using => "python3") to override the default, guessed
- # formula preference for python or python3, or to resolve an ambiguous
- # case where it's not clear whether python or python3 should be the
+ # passed (e.g., :using => "python") to override the default, guessed
+ # formula preference for python or python2, or to resolve an ambiguous
+ # case where it's not clear whether python or python2 should be the
# default guess.
def virtualenv_install_with_resources(options = {})
python = options[:using]
if python.nil?
- wanted = %w[python python@2 python@3 python3].select { |py| needs_python?(py) }
+ wanted = %w[python python@2 python2 python3].select { |py| needs_python?(py) }
raise FormulaAmbiguousPythonError, self if wanted.size > 1
- python = wanted.first || "python2.7"
+ python = wanted.first || "python"
end
venv = virtualenv_create(libexec, python.delete("@"))
venv.pip_install resources
@@ -154,7 +154,7 @@ module Language
# @param venv_root [Pathname, String] the path to the root of the
# virtualenv
# @param python [String] which interpreter to use; i.e. "python" or
- # "python3"
+ # "python2"
def initialize(formula, venv_root, python)
@formula = formula
@venv_root = Pathname.new(venv_root)
@@ -180,11 +180,11 @@ module Language
end
end
- # Robustify symlinks to survive python3 patch upgrades
+ # Robustify symlinks to survive python patch upgrades
@venv_root.find do |f|
next unless f.symlink?
next unless (rp = f.realpath.to_s).start_with? HOMEBREW_CELLAR
- python = rp.include?("python3") ? "python3" : "python"
+ python = rp.include?("python2") ? "python2" : "python"
new_target = rp.sub %r{#{HOMEBREW_CELLAR}/#{python}/[^/]+}, Formula[python].opt_prefix
f.unlink
f.make_symlink new_target
@@ -192,7 +192,7 @@ module Language
Pathname.glob(@venv_root/"lib/python*/orig-prefix.txt").each do |prefix_file|
prefix_path = prefix_file.read
- python = prefix_path.include?("python3") ? "python3" : "python"
+ python = prefix_path.include?("python2") ? "python2" : "python"
prefix_path.sub! %r{^#{HOMEBREW_CELLAR}/#{python}/[^/]+}, Formula[python].opt_prefix
prefix_file.atomic_write prefix_path
end
diff --git a/Library/Homebrew/test/language_module_requirement_spec.rb b/Library/Homebrew/test/language_module_requirement_spec.rb
index 6ca8cbd0e..74d092bac 100644
--- a/Library/Homebrew/test/language_module_requirement_spec.rb
+++ b/Library/Homebrew/test/language_module_requirement_spec.rb
@@ -31,10 +31,6 @@ describe LanguageModuleRequirement, :needs_compat do
it "does not satisfy invalid dependencies" do
expect(described_class.new(:python, "notapackage")).not_to be_satisfied
end
-
- it "satisfies valid dependencies" do
- expect(described_class.new(:python, "datetime")).to be_satisfied
- end
end
context "when the language is Ruby" do