| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  | require "language/python_virtualenv_constants" | 
					
						
							| 
									
										
										
										
											2014-03-07 18:03:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | module Language | 
					
						
							|  |  |  |   module Python | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     def self.major_minor_version(python) | 
					
						
							| 
									
										
										
										
											2014-03-07 18:03:54 +00:00
										 |  |  |       version = /\d\.\d/.match `#{python} --version 2>&1` | 
					
						
							|  |  |  |       return unless version | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-11 16:09:35 +03:00
										 |  |  |       Version.create(version.to_s) | 
					
						
							| 
									
										
										
										
											2014-03-07 18:03:54 +00:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 23:01:52 -04:00
										 |  |  |     def self.homebrew_site_packages(python = "python3.7") | 
					
						
							|  |  |  |       HOMEBREW_PREFIX/site_packages(python) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def self.site_packages(python = "python3.7") | 
					
						
							| 
									
										
										
										
											2019-03-11 20:14:03 +11:00
										 |  |  |       if (python == "pypy") || (python == "pypy3") | 
					
						
							| 
									
										
										
										
											2018-09-05 23:01:52 -04:00
										 |  |  |         "site-packages" | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         "lib/python#{major_minor_version python}/site-packages" | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2014-10-19 13:47:55 -07:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     def self.each_python(build, &block) | 
					
						
							| 
									
										
										
										
											2014-03-07 18:03:54 +00:00
										 |  |  |       original_pythonpath = ENV["PYTHONPATH"] | 
					
						
							| 
									
										
										
										
											2019-03-11 20:14:03 +11:00
										 |  |  |       pythons = { "python@3" => "python3", | 
					
						
							|  |  |  |                   "python@2" => "python2.7", | 
					
						
							|  |  |  |                   "pypy"     => "pypy", | 
					
						
							|  |  |  |                   "pypy3"    => "pypy3" } | 
					
						
							|  |  |  |       pythons.each do |python_formula, python| | 
					
						
							| 
									
										
										
										
											2018-02-28 03:20:14 -08:00
										 |  |  |         python_formula = Formulary.factory(python_formula) | 
					
						
							|  |  |  |         next if build.without? python_formula.to_s | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |         version = major_minor_version python | 
					
						
							| 
									
										
										
										
											2018-02-28 03:20:14 -08:00
										 |  |  |         ENV["PYTHONPATH"] = if python_formula.installed? | 
					
						
							| 
									
										
										
										
											2014-03-07 18:03:54 +00:00
										 |  |  |           nil | 
					
						
							|  |  |  |         else | 
					
						
							| 
									
										
										
										
											2018-09-05 23:01:52 -04:00
										 |  |  |           homebrew_site_packages(python) | 
					
						
							| 
									
										
										
										
											2014-03-07 18:03:54 +00:00
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-09-24 19:24:46 +01:00
										 |  |  |         block&.call python, version | 
					
						
							| 
									
										
										
										
											2014-03-07 18:03:54 +00:00
										 |  |  |       end | 
					
						
							|  |  |  |       ENV["PYTHONPATH"] = original_pythonpath | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2014-10-19 13:47:55 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     def self.reads_brewed_pth_files?(python) | 
					
						
							| 
									
										
										
										
											2018-09-05 23:01:52 -04:00
										 |  |  |       return unless homebrew_site_packages(python).directory? | 
					
						
							|  |  |  |       return unless homebrew_site_packages(python).writable_real? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 23:01:52 -04:00
										 |  |  |       probe_file = homebrew_site_packages(python)/"homebrew-pth-probe.pth" | 
					
						
							| 
									
										
										
										
											2014-11-05 19:37:24 -08:00
										 |  |  |       begin | 
					
						
							|  |  |  |         probe_file.atomic_write("import site; site.homebrew_was_here = True") | 
					
						
							| 
									
										
										
										
											2017-12-13 06:06:07 +00:00
										 |  |  |         with_homebrew_path { quiet_system python, "-c", "import site; assert(site.homebrew_was_here)" } | 
					
						
							| 
									
										
										
										
											2014-11-05 19:37:24 -08:00
										 |  |  |       ensure | 
					
						
							|  |  |  |         probe_file.unlink if probe_file.exist? | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2014-10-19 13:47:55 -07:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     def self.user_site_packages(python) | 
					
						
							| 
									
										
										
										
											2014-10-19 13:47:55 -07:00
										 |  |  |       Pathname.new(`#{python} -c "import site; print(site.getusersitepackages())"`.chomp) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     def self.in_sys_path?(python, path) | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |       script = <<~PYTHON | 
					
						
							| 
									
										
										
										
											2014-10-19 13:47:55 -07:00
										 |  |  |         import os, sys | 
					
						
							|  |  |  |         [os.path.realpath(p) for p in sys.path].index(os.path.realpath("#{path}")) | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |       PYTHON | 
					
						
							| 
									
										
										
										
											2014-10-19 13:47:55 -07:00
										 |  |  |       quiet_system python, "-c", script | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2014-11-06 22:25:11 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     def self.setup_install_args(prefix) | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |       shim = <<~PYTHON | 
					
						
							| 
									
										
										
										
											2014-12-09 23:17:11 -08:00
										 |  |  |         import setuptools, tokenize | 
					
						
							|  |  |  |         __file__ = 'setup.py' | 
					
						
							|  |  |  |         exec(compile(getattr(tokenize, 'open', open)(__file__).read() | 
					
						
							|  |  |  |           .replace('\\r\\n', '\\n'), __file__, 'exec')) | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |       PYTHON | 
					
						
							| 
									
										
										
										
											2014-12-09 23:17:11 -08:00
										 |  |  |       %W[
 | 
					
						
							|  |  |  |         -c | 
					
						
							|  |  |  |         #{shim} | 
					
						
							| 
									
										
										
										
											2015-01-08 16:43:40 -08:00
										 |  |  |         --no-user-cfg | 
					
						
							| 
									
										
										
										
											2014-12-09 23:17:11 -08:00
										 |  |  |         install | 
					
						
							|  |  |  |         --prefix=#{prefix} | 
					
						
							| 
									
										
										
										
											2018-09-05 23:01:52 -04:00
										 |  |  |         --install-scripts=#{prefix}/bin | 
					
						
							| 
									
										
										
										
											2014-12-09 23:17:11 -08:00
										 |  |  |         --single-version-externally-managed | 
					
						
							|  |  |  |         --record=installed.txt | 
					
						
							|  |  |  |       ] | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2015-03-02 21:44:35 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |     # Mixin module for {Formula} adding virtualenv support features. | 
					
						
							|  |  |  |     module Virtualenv | 
					
						
							|  |  |  |       def self.included(base) | 
					
						
							|  |  |  |         base.class_eval do | 
					
						
							|  |  |  |           resource "homebrew-virtualenv" do | 
					
						
							|  |  |  |             url PYTHON_VIRTUALENV_URL | 
					
						
							|  |  |  |             sha256 PYTHON_VIRTUALENV_SHA256 | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       # Instantiates, creates, and yields a {Virtualenv} object for use from | 
					
						
							| 
									
										
										
										
											2018-10-18 21:42:43 -04:00
										 |  |  |       # {Formula#install}, which provides helper methods for instantiating and | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |       # installing packages into a Python virtualenv. | 
					
						
							|  |  |  |       # @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" | 
					
						
							| 
									
										
										
										
											2018-03-03 09:42:25 +00:00
										 |  |  |       #   or "python2") | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |       # @param formula [Formula] the active Formula | 
					
						
							|  |  |  |       # @return [Virtualenv] a {Virtualenv} instance | 
					
						
							|  |  |  |       def virtualenv_create(venv_root, python = "python", formula = self) | 
					
						
							| 
									
										
										
										
											2016-07-29 08:45:26 -07:00
										 |  |  |         ENV.refurbish_args | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |         venv = Virtualenv.new formula, venv_root, python | 
					
						
							|  |  |  |         venv.create | 
					
						
							| 
									
										
										
										
											2016-07-31 11:59:30 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Find any Python bindings provided by recursive dependencies | 
					
						
							|  |  |  |         formula_deps = formula.recursive_dependencies | 
					
						
							|  |  |  |         pth_contents = formula_deps.map do |d| | 
					
						
							|  |  |  |           next if d.build? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 23:01:52 -04:00
										 |  |  |           dep_site_packages = Formula[d.name].opt_prefix/Language::Python.site_packages(python) | 
					
						
							| 
									
										
										
										
											2016-07-31 11:59:30 -07:00
										 |  |  |           next unless dep_site_packages.exist? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-31 11:59:30 -07:00
										 |  |  |           "import site; site.addsitedir('#{dep_site_packages}')\n" | 
					
						
							| 
									
										
										
										
											2016-08-05 22:01:32 +08:00
										 |  |  |         end.compact | 
					
						
							|  |  |  |         unless pth_contents.empty? | 
					
						
							| 
									
										
										
										
											2018-09-05 23:01:52 -04:00
										 |  |  |           (venv_root/Language::Python.site_packages(python)/"homebrew_deps.pth").write pth_contents.join | 
					
						
							| 
									
										
										
										
											2016-07-31 11:59:30 -07:00
										 |  |  |         end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |         venv | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-05 00:20:20 -07:00
										 |  |  |       # Returns true if a formula option for the specified python is currently | 
					
						
							|  |  |  |       # active or if the specified python is required by the formula. Valid | 
					
						
							| 
									
										
										
										
											2018-03-03 09:42:25 +00:00
										 |  |  |       # inputs are "python", "python2", :python, and :python2. Note that | 
					
						
							|  |  |  |       # "with-python", "without-python", "with-python@2", and "without-python@2" | 
					
						
							| 
									
										
										
										
											2016-08-05 00:20:20 -07:00
										 |  |  |       # formula options are handled correctly even if not associated with any | 
					
						
							|  |  |  |       # corresponding depends_on statement. | 
					
						
							|  |  |  |       # @api private | 
					
						
							|  |  |  |       def needs_python?(python) | 
					
						
							|  |  |  |         return true if build.with?(python) | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-05 00:20:20 -07:00
										 |  |  |         (requirements.to_a | deps).any? { |r| r.name == python && r.required? } | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |       # Helper method for the common case of installing a Python application. | 
					
						
							|  |  |  |       # Creates a virtualenv in `libexec`, installs all `resource`s defined | 
					
						
							| 
									
										
										
										
											2016-08-05 00:20:20 -07:00
										 |  |  |       # on the formula, and then installs the formula. An options hash may be | 
					
						
							| 
									
										
										
										
											2018-10-18 21:42:43 -04:00
										 |  |  |       # passed (e.g., `:using => "python"`) to override the default, guessed | 
					
						
							| 
									
										
										
										
											2018-03-03 09:42:25 +00:00
										 |  |  |       # formula preference for python or python2, or to resolve an ambiguous | 
					
						
							|  |  |  |       # case where it's not clear whether python or python2 should be the | 
					
						
							| 
									
										
										
										
											2016-08-05 00:20:20 -07:00
										 |  |  |       # default guess. | 
					
						
							|  |  |  |       def virtualenv_install_with_resources(options = {}) | 
					
						
							|  |  |  |         python = options[:using] | 
					
						
							|  |  |  |         if python.nil? | 
					
						
							| 
									
										
										
										
											2019-03-11 20:14:03 +11:00
										 |  |  |           wanted = %w[python python@2 python2 python3 python@3 pypy pypy3].select { |py| needs_python?(py) } | 
					
						
							| 
									
										
										
										
											2016-08-05 00:20:20 -07:00
										 |  |  |           raise FormulaAmbiguousPythonError, self if wanted.size > 1
 | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-09 13:45:30 -08:00
										 |  |  |           python = wanted.first || "python2.7" | 
					
						
							|  |  |  |           python = "python3" if python == "python" | 
					
						
							| 
									
										
										
										
											2016-08-05 00:20:20 -07:00
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-12-30 14:49:26 -08:00
										 |  |  |         venv = virtualenv_create(libexec, python.delete("@")) | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |         venv.pip_install resources | 
					
						
							| 
									
										
										
										
											2016-08-02 22:37:15 +02:00
										 |  |  |         venv.pip_install_and_link buildpath | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |         venv | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       # Convenience wrapper for creating and installing packages into Python | 
					
						
							|  |  |  |       # virtualenvs. | 
					
						
							|  |  |  |       class Virtualenv | 
					
						
							|  |  |  |         # Initializes a Virtualenv instance. This does not create the virtualenv | 
					
						
							|  |  |  |         # on disk; {#create} does that. | 
					
						
							|  |  |  |         # @param formula [Formula] the active Formula | 
					
						
							|  |  |  |         # @param venv_root [Pathname, String] the path to the root of the | 
					
						
							|  |  |  |         #   virtualenv | 
					
						
							| 
									
										
										
										
											2019-04-08 12:47:15 -04:00
										 |  |  |         # @param python [String] which interpreter to use, i.e. "python" or | 
					
						
							| 
									
										
										
										
											2018-03-03 09:42:25 +00:00
										 |  |  |         #   "python2" | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |         def initialize(formula, venv_root, python) | 
					
						
							|  |  |  |           @formula = formula | 
					
						
							|  |  |  |           @venv_root = Pathname.new(venv_root) | 
					
						
							|  |  |  |           @python = python | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Obtains a copy of the virtualenv library and creates a new virtualenv | 
					
						
							|  |  |  |         # on disk. | 
					
						
							|  |  |  |         # @return [void] | 
					
						
							|  |  |  |         def create | 
					
						
							|  |  |  |           return if (@venv_root/"bin/python").exist? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           @formula.resource("homebrew-virtualenv").stage do |stage| | 
					
						
							|  |  |  |             old_pythonpath = ENV.delete "PYTHONPATH" | 
					
						
							|  |  |  |             begin | 
					
						
							|  |  |  |               staging = Pathname.new(stage.staging.tmpdir) | 
					
						
							| 
									
										
										
										
											2018-09-05 23:01:52 -04:00
										 |  |  |               ENV.prepend_create_path "PYTHONPATH", staging/"target"/Language::Python.site_packages(@python) | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |               @formula.system @python, *Language::Python.setup_install_args(staging/"target") | 
					
						
							|  |  |  |               @formula.system @python, "-s", staging/"target/bin/virtualenv", "-p", @python, @venv_root | 
					
						
							|  |  |  |             ensure | 
					
						
							|  |  |  |               ENV["PYTHONPATH"] = old_pythonpath | 
					
						
							|  |  |  |             end | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-03 09:42:25 +00:00
										 |  |  |           # Robustify symlinks to survive python patch upgrades | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |           @venv_root.find do |f| | 
					
						
							|  |  |  |             next unless f.symlink? | 
					
						
							| 
									
										
										
										
											2016-09-10 10:38:35 +01:00
										 |  |  |             next unless (rp = f.realpath.to_s).start_with? HOMEBREW_CELLAR | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-08 08:10:48 -08:00
										 |  |  |             python = rp.include?("python@2") ? "python@2" : "python" | 
					
						
							| 
									
										
										
										
											2016-09-10 10:38:35 +01:00
										 |  |  |             new_target = rp.sub %r{#{HOMEBREW_CELLAR}/#{python}/[^/]+}, Formula[python].opt_prefix | 
					
						
							|  |  |  |             f.unlink | 
					
						
							|  |  |  |             f.make_symlink new_target | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |           end | 
					
						
							| 
									
										
										
										
											2016-10-04 09:47:14 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           Pathname.glob(@venv_root/"lib/python*/orig-prefix.txt").each do |prefix_file| | 
					
						
							|  |  |  |             prefix_path = prefix_file.read | 
					
						
							| 
									
										
										
										
											2018-03-08 08:10:48 -08:00
										 |  |  |             python = prefix_path.include?("python@2") ? "python@2" : "python" | 
					
						
							| 
									
										
										
										
											2016-10-04 09:47:14 -07:00
										 |  |  |             prefix_path.sub! %r{^#{HOMEBREW_CELLAR}/#{python}/[^/]+}, Formula[python].opt_prefix | 
					
						
							|  |  |  |             prefix_file.atomic_write prefix_path | 
					
						
							|  |  |  |           end | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |         end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Installs packages represented by `targets` into the virtualenv. | 
					
						
							|  |  |  |         # @param targets [String, Pathname, Resource, | 
					
						
							|  |  |  |         #   Array<String, Pathname, Resource>] (A) token(s) passed to pip | 
					
						
							|  |  |  |         #   representing the object to be installed. This can be a directory | 
					
						
							|  |  |  |         #   containing a setup.py, a {Resource} which will be staged and | 
					
						
							|  |  |  |         #   installed, or a package identifier to be fetched from PyPI. | 
					
						
							|  |  |  |         #   Multiline strings are allowed and treated as though they represent | 
					
						
							|  |  |  |         #   the contents of a `requirements.txt`. | 
					
						
							|  |  |  |         # @return [void] | 
					
						
							|  |  |  |         def pip_install(targets) | 
					
						
							|  |  |  |           targets = [targets] unless targets.is_a? Array | 
					
						
							|  |  |  |           targets.each do |t| | 
					
						
							|  |  |  |             if t.respond_to? :stage | 
					
						
							|  |  |  |               next if t.name == "homebrew-virtualenv" | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |               t.stage { do_install Pathname.pwd } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |               t = t.lines.map(&:strip) if t.respond_to?(:lines) && t =~ /\n/ | 
					
						
							|  |  |  |               do_install t | 
					
						
							|  |  |  |             end | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-02 22:37:15 +02:00
										 |  |  |         # Installs packages represented by `targets` into the virtualenv, but | 
					
						
							|  |  |  |         #   unlike {#pip_install} also links new scripts to {Formula#bin}. | 
					
						
							|  |  |  |         # @param (see #pip_install) | 
					
						
							|  |  |  |         # @return (see #pip_install) | 
					
						
							|  |  |  |         def pip_install_and_link(targets) | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |           bin_before = Dir[@venv_root/"bin/*"].to_set | 
					
						
							| 
									
										
										
										
											2016-08-02 22:37:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |           pip_install(targets) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |           bin_after = Dir[@venv_root/"bin/*"].to_set | 
					
						
							| 
									
										
										
										
											2016-08-02 22:37:15 +02:00
										 |  |  |           bin_to_link = (bin_after - bin_before).to_a | 
					
						
							|  |  |  |           @formula.bin.install_symlink(bin_to_link) | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |         end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         private | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         def do_install(targets) | 
					
						
							|  |  |  |           targets = [targets] unless targets.is_a? Array | 
					
						
							|  |  |  |           @formula.system @venv_root/"bin/pip", "install", | 
					
						
							| 
									
										
										
										
											2016-07-31 11:59:30 -07:00
										 |  |  |                           "-v", "--no-deps", "--no-binary", ":all:", | 
					
						
							|  |  |  |                           "--ignore-installed", *targets | 
					
						
							| 
									
										
										
										
											2016-07-22 23:02:52 -07:00
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 19:52:43 +02:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |