github.com/hwaf/hwaf@v0.0.0-20140814122253-5465f73b20f1/py-hwaftools/orch/features/feature_pypackage.py (about)

     1  #!/usr/bin/env python
     2  '''Feature to install a Python package via its setup.py file.
     3  
     4  This feature relies on the "unpack" step to have run.  It is assumed
     5  the suite is installing Python or that python_install_dir is
     6  explicitly set.
     7  
     8  It produces the "build" and "install" steps.
     9  
    10  Note, these steps run in the source directory.  A "prepare" step is not required.
    11  
    12  '''
    13  
    14  from waflib.TaskGen import feature
    15  
    16  import orch.features
    17  orch.features.register_defaults(
    18      'pypackage',
    19      build_cmd = 'python setup.py build',
    20      build_cmd_options = '',
    21      build_target = '',
    22      build_target_path = '{source_unpacked_path}/{build_target}',
    23      
    24      install_cmd = 'python setup.py install --prefix={python_install_dir}',
    25      install_cmd_options = '',
    26      install_target = '',
    27      install_target_path = '{python_install_dir}/{install_target}',
    28      
    29  )
    30  
    31  @feature('pypackage')
    32  def feature_pypackage(tgen):
    33      
    34      # dummy prepare step, for feature_patch's benefit and "depends = prepare:xxx_install"
    35      tgen.step('prepare',
    36                rule = "/bin/true",
    37                source = tgen.control_node('unpack'),
    38                target = tgen.control_node('prepare'))
    39  
    40      tgen.step('build',
    41                rule = tgen.worch.format('{build_cmd} {build_cmd_options}'),
    42                source = tgen.control_node('prepare'),
    43                target = tgen.worch.build_target_path,
    44                cwd = tgen.worch.source_unpacked_path)
    45  
    46      tgen.step('install',
    47                rule = tgen.worch.format('{install_cmd} {install_cmd_options}'),
    48                source = [tgen.worch.build_target_path, tgen.control_node('build')],
    49                target = tgen.make_node(tgen.worch.install_target_path),
    50                cwd = tgen.worch.source_unpacked_path)