Library/Homebrew/language/python.rb
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)
              ENV.prepend_create_path "PYTHONPATH", staging/"target"/Language::Python.site_packages(@python)
              @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

          # 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?("python@2") ? "python@2" : "python"
            new_target = rp.sub %r{#{HOMEBREW_CELLAR}/#{python}/[^/]+}, Formula[python].opt_prefix
            f.unlink
            f.make_symlink new_target
          end

          Pathname.glob(@venv_root/"lib/python*/orig-prefix.txt").each do |prefix_file|
            prefix_path = prefix_file.read
            python = prefix_path.include?("python@2") ? "python@2" : "python"
            prefix_path.sub! %r{^#{HOMEBREW_CELLAR}/#{python}/[^/]+}, Formula[python].opt_prefix
            prefix_file.atomic_write prefix_path
          end
        end
# Obtains a copy of the virtualenv library and creates a new virtualenv
# on disk.
# @return [void]
Obtains a copy of the virtualenv library and creates a new virtualenv
on disk.
Obtains a copy of the virtualenv library and creates a new virtualenv on disk .
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)
              ENV.prepend_create_path "PYTHONPATH", staging/"target"/Language::Python.site_packages(@python)
              @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
          @venv_root.find do |f|
            next unless f.symlink?
            next unless (rp = f.realpath.to_s).start_with? HOMEBREW_CELLAR
            python = rp.include?("python@2") ? "python@2" : "python"
            new_target = rp.sub %r{#{HOMEBREW_CELLAR}/#{python}/[^/]+}, Formula[python].opt_prefix
            f.unlink
            f.make_symlink new_target
          end
          Pathname.glob(@venv_root/"lib/python*/orig-prefix.txt").each do |prefix_file|
            prefix_path = prefix_file.read
            python = prefix_path.include?("python@2") ? "python@2" : "python"
            prefix_path.sub! %r{^#{HOMEBREW_CELLAR}/#{python}/[^/]+}, Formula[python].opt_prefix
            prefix_file.atomic_write prefix_path
          end
        end
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 ) ENV . prepend_create_path "PYTHONPATH" , staging / "target" / Language :: Python . site_packages ( @python ) @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 @venv_root . find do | f | next unless f . symlink? next unless ( rp = f . realpath . to_s ) . start_with? HOMEBREW_CELLAR python = rp . include? ( "python@2" ) ? "python@2" : "python" new_target = rp . sub %r{ #{ HOMEBREW_CELLAR } / #{ python } /[^/]+ } , Formula [ python ] . opt_prefix f . unlink f . make_symlink new_target end Pathname . glob ( @venv_root / "lib/python*/orig-prefix.txt" ) . each do | prefix_file | prefix_path = prefix_file . read python = prefix_path . include? ( "python@2" ) ? "python@2" : "python" prefix_path . sub! %r{ ^ #{ HOMEBREW_CELLAR } / #{ python } /[^/]+ } , Formula [ python ] . opt_prefix prefix_file . atomic_write prefix_path end end
Obtains a copy of the virtualenv library and creates a new virtualenv
on disk.
Obtains a copy of the virtualenv library and creates a new virtualenv on disk .
# Robustify symlinks to survive python patch upgrades
None
void