class Autoproj::PackageManagers::PipManager
Using pip to install python packages
Attributes
Public Class Methods
Source
# File lib/autoproj/package_managers/pip_manager.rb, line 20 def initialize(ws) super(ws) @installed_pips = Set.new end
Calls superclass method
Autoproj::PackageManagers::Manager::new
Public Instance Methods
Source
# File lib/autoproj/package_managers/pip_manager.rb, line 35 def activate_python Autoproj::Python.setup_python_configuration_options(ws: ws) Autoproj::Python.assert_python_activated(ws: ws) end
Source
# File lib/autoproj/package_managers/pip_manager.rb, line 29 def guess_pip_program activate_python Autobuild.programs["pip"] = "pip" unless Autobuild.programs["pip"] Autobuild.programs["pip"] end
Source
# File lib/autoproj/package_managers/pip_manager.rb, line 9 def initialize_environment ws.env.set "PYTHONUSERBASE", pip_home ws.env.add_path "PATH", File.join(pip_home, "bin") end
Source
# File lib/autoproj/package_managers/pip_manager.rb, line 40 def install(pips, filter_uptodate_packages: false, install_only: false) guess_pip_program pips = [pips] if pips.is_a?(String) base_cmdline = [Autobuild.tool("pip"), "install", "--user"] cmdlines = [base_cmdline + pips] if pips_interaction(cmdlines) Autoproj.message " installing/updating Python dependencies:" \ " #{pips.sort.join(', ')}" cmdlines.each do |c| Autobuild::Subprocess.run "autoproj", "osdeps", *c, env: ws.env.resolved_env end pips.each do |p| @installed_pips << p end end end
Source
# File lib/autoproj/package_managers/pip_manager.rb, line 25 def os_dependencies super + ["pip"] end
Calls superclass method
Autoproj::PackageManagers::Manager#os_dependencies
Source
# File lib/autoproj/package_managers/pip_manager.rb, line 16 def pip_home ws.env["AUTOPROJ_PYTHONUSERBASE"] || File.join(ws.prefix_dir, "pip") end
Return the directory where python packages are installed to. The actual path is pip_home/lib/pythonx.y/site-packages.
Source
# File lib/autoproj/package_managers/pip_manager.rb, line 63 def pips_interaction(cmdlines) if OSPackageInstaller.force_osdeps return true elsif enabled? return true elsif silent? return false end # We're not supposed to install rubygem packages but silent is not # set, so display information about them anyway puts <<-EOMSG #{Autoproj.color('The build process and/or the packages require some Python packages to be installed', :bold)} #{Autoproj.color('and you required autoproj to not do it itself', :bold)} The following command line can be used to install them manually #{' '} #{cmdlines.map { |c| c.join(' ') }.join("\n ")} #{' '} Autoproj expects these Python packages to be installed in #{pip_home} This can be overridden by setting the AUTOPROJ_PYTHONUSERBASE environment variable manually EOMSG print " #{Autoproj.color('Press ENTER to continue ', :bold)}" $stdout.flush $stdin.readline puts false end