Class: Autobuild::Python
- Inherits:
-
Configurable
- Object
- Package
- Configurable
- Autobuild::Python
- Defined in:
- lib/autobuild/packages/python.rb
Overview
Handler class to build python-based packages
Instance Attribute Summary collapse
-
#buildflags ⇒ Object
Returns the value of attribute buildflags.
-
#installflags ⇒ Object
Returns the value of attribute installflags.
Attributes inherited from Configurable
Attributes inherited from Package
#dependencies, #env, #failures, #importdir, #importer, #logdir, #name, #prefix, #srcdir, #statistics, #update, #updated, #utilities
Class Method Summary collapse
Instance Method Summary collapse
-
#build ⇒ Object
Do the build in builddir.
- #configurestamp ⇒ Object
- #generate_build_command ⇒ Object
- #generate_install_command ⇒ Object
-
#initialize(options) ⇒ Python
constructor
A new instance of Python.
-
#install ⇒ Object
Install the result in prefix.
- #install_mode? ⇒ Boolean
- #prepare_for_forced_build ⇒ Object
- #python_path ⇒ Object
- #update_environment ⇒ Object
Methods inherited from Configurable
builddir, #builddir, builddir=, #builddir=, #buildstamp, #configure, #ensure_dependencies_installed, #prepare, #prepare_for_rebuild
Methods inherited from Package
[], #add_env_op, #add_stat, #all_dependencies, #applied_post_install?, #apply_env, #apply_post_install, #checked_out?, clear, #depends_on, #depends_on?, #disable, #disable_doc, #disable_phases, #disabled?, #doc_dir, #doc_dir=, #doc_disabled, #doc_target_dir, #doc_target_dir=, #doc_task, each, #enable_doc, #env_add, #env_add_path, #env_add_prefix, #env_set, #env_source_after, #error, #failed?, #file, #find_in_path, #fingerprint, #full_env, #generates_doc?, #has_doc?, #import, #import=, #import_invoked?, #imported?, #in_dir, #inspect, #install_doc, #install_invoked?, #installed?, #installstamp, #isolate_errors, #message, #method_missing, #parallel_build_level, #parallel_build_level=, #post_install, #prepare, #prepare_for_rebuild, #process_formatting_string, #progress, #progress_done, #progress_start, #provides, #resolve_dependency_env, #resolved_env, #respond_to_missing?, #run, #self_fingerprint, #source_tree, #task, #to_s, #update?, #updated?, #utility, #warn, #working_directory
Constructor Details
#initialize(options) ⇒ Python
Returns a new instance of Python.
18 19 20 21 22 |
# File 'lib/autobuild/packages/python.rb', line 18 def initialize() @buildflags = [] @installflags = [] super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Autobuild::Package
Instance Attribute Details
#buildflags ⇒ Object
Returns the value of attribute buildflags.
12 13 14 |
# File 'lib/autobuild/packages/python.rb', line 12 def buildflags @buildflags end |
#installflags ⇒ Object
Returns the value of attribute installflags.
12 13 14 |
# File 'lib/autobuild/packages/python.rb', line 12 def installflags @installflags end |
Class Method Details
.user_site(prefix) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/autobuild/packages/python.rb', line 53 def self.user_site(prefix) return File.join(prefix, @user_site) if @user_site begin env = Autobuild.env.resolved_env.merge({ 'PYTHONUSERBASE' => "/" }) _, output, _, ret = Open3.popen3(env, 'python -m site --user-site') rescue Exception => e raise "Unable to set PYTHONPATH: #{e.}" end if ret.value.success? @user_site = Pathname.new(output.read.chomp) .relative_path_from(Pathname.new("/")) File.join(prefix, @user_site) else raise 'Unable to set PYTHONPATH: user site directory disabled?' end end |
Instance Method Details
#build ⇒ Object
Do the build in builddir
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/autobuild/packages/python.rb', line 77 def build return unless install_mode? command = generate_build_command command << '--force' if @forced progress_start 'building %s [progress not available]', done_message: 'built %s' do run 'build', *command, working_directory: srcdir end Autobuild.touch_stamp(buildstamp) end |
#configurestamp ⇒ Object
14 15 16 |
# File 'lib/autobuild/packages/python.rb', line 14 def configurestamp "#{builddir}/configure-autobuild-stamp" end |
#generate_build_command ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/autobuild/packages/python.rb', line 33 def generate_build_command command = %w[python setup.py] command << "egg_info" command << "--egg-base=#{builddir}" command << "build" command << "--build-base=#{builddir}" command += buildflags.flatten command end |
#generate_install_command ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/autobuild/packages/python.rb', line 43 def generate_install_command command = generate_build_command command << 'install' command << "--prefix=#{prefix}" command << "--record=#{builddir}/install.log" command << "--single-version-externally-managed" command += installflags.flatten command end |
#install ⇒ Object
Install the result in prefix
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/autobuild/packages/python.rb', line 90 def install return unless install_mode? command = generate_install_command command << '--force' if @forced progress_start 'installing %s', done_message: 'installed %s' do run 'install', *command, working_directory: srcdir end super end |
#install_mode? ⇒ Boolean
24 25 26 |
# File 'lib/autobuild/packages/python.rb', line 24 def install_mode? File.file?(File.join(srcdir, 'setup.py')) end |
#prepare_for_forced_build ⇒ Object
28 29 30 31 |
# File 'lib/autobuild/packages/python.rb', line 28 def prepare_for_forced_build super @forced = true end |
#python_path ⇒ Object
72 73 74 |
# File 'lib/autobuild/packages/python.rb', line 72 def python_path self.class.user_site(prefix) end |
#update_environment ⇒ Object
102 103 104 105 106 |
# File 'lib/autobuild/packages/python.rb', line 102 def update_environment super path = install_mode? ? python_path : srcdir env_add_path 'PYTHONPATH', path end |