Changeset 5a7c000 for python


Ignore:
Timestamp:
Nov 28, 2016, 4:33:48 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
sampler
Children:
8706a42
Parents:
c3af14b
git-author:
Paul Brossier <piem@piem.org> (10/03/16 16:40:48)
git-committer:
Paul Brossier <piem@piem.org> (11/28/16 16:33:48)
Message:

setup.py: use custom build_ext instead of 'generate' command, define HAVE_AUBIO_DOUBLE to 1 if needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/moresetuptools.py

    rc3af14b r5a7c000  
    125125        distutils.command.clean.clean.run(self)
    126126
    127 class GenerateCommand(distutils.cmd.Command):
    128     description = 'generate gen/gen-*.c files from ../src/aubio.h'
    129     user_options = [
     127from distutils.command.build_ext import build_ext as _build_ext
     128class build_ext(_build_ext):
     129
     130    user_options = _build_ext.user_options + [
    130131            # The format is (long option, short option, description).
    131132            ('enable-double', None, 'use HAVE_AUBIO_DOUBLE=1 (default: 0)'),
     
    133134
    134135    def initialize_options(self):
     136        _build_ext.initialize_options(self)
    135137        self.enable_double = False
    136138
    137139    def finalize_options(self):
     140        _build_ext.finalize_options(self)
    138141        if self.enable_double:
    139142            self.announce(
     
    141144                    level=distutils.log.INFO)
    142145
    143     def run(self):
    144         self.announce( 'Generating code', level=distutils.log.INFO)
    145         generated_object_files = generate_external(header, output_path, usedouble=self.enable_double)
     146    def build_extension(self, extension):
     147        if self.enable_double:
     148            extension.define_macros += [('HAVE_AUBIO_DOUBLE', 1)]
     149        if os.path.isfile('src/aubio.h'):
     150            # if aubio headers are found in this directory
     151            add_local_aubio_header(extension)
     152            # was waf used to build the shared lib?
     153            if os.path.isdir(os.path.join('build','src')):
     154                # link against build/src/libaubio, built with waf
     155                add_local_aubio_lib(extension)
     156            else:
     157                # add libaubio sources and look for optional deps with pkg-config
     158                add_local_aubio_sources(extension, usedouble=self.enable_double)
     159        else:
     160            # look for aubio headers and lib using pkg-config
     161            add_system_aubio(extension)
     162        # generate files python/gen/*.c, python/gen/aubio-generated.h
     163        extension.sources += generate_external(header, output_path, overwrite = False,
     164                usedouble=self.enable_double)
     165        return _build_ext.build_extension(self, extension)
Note: See TracChangeset for help on using the changeset viewer.