Changeset 5a7c000


Ignore:
Timestamp:
Nov 28, 2016, 4:33:48 PM (7 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

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    rc3af14b r5a7c000  
    2929
    3030build_python:
    31         python ./setup.py generate $(ENABLE_DOUBLE) build
     31        python ./setup.py build_ext $(ENABLE_DOUBLE)
    3232
    3333test_python: export LD_LIBRARY_PATH=$(PWD)/build/src
     
    7373
    7474build_python3:
    75         python3 ./setup.py generate $(ENABLE_DOUBLE) build
     75        python3 ./setup.py build_ext $(ENABLE_DOUBLE)
    7676
    7777clean_python3:
  • 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)
  • setup.py

    rc3af14b r5a7c000  
    4848
    4949if os.path.isfile('src/aubio.h'):
    50     # if aubio headers are found in this directory
    51     add_local_aubio_header(aubio_extension)
    52     # was waf used to build the shared lib?
    53     if os.path.isdir(os.path.join('build','src')):
    54         # link against build/src/libaubio, built with waf
    55         add_local_aubio_lib(aubio_extension)
    56     else:
    57         # add libaubio sources and look for optional deps with pkg-config
    58         add_local_aubio_sources(aubio_extension)
    59         __version__ += 'a2' # pypi version
    60 else:
    61     # look for aubio headers and lib using pkg-config
    62     add_system_aubio(aubio_extension)
    63 
     50    if not os.path.isdir(os.path.join('build','src')):
     51        __version__ += 'a2' # python only version
    6452
    6553classifiers = [
     
    7765    'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
    7866    ]
    79 
    80 from distutils.command.build_ext import build_ext as _build_ext
    81 class build_ext(_build_ext):
    82 
    83     def build_extension(self, extension):
    84         # generate files python/gen/*.c, python/gen/aubio-generated.h
    85         extension.sources += generate_external(header, output_path, overwrite = False)
    86         return _build_ext.build_extension(self, extension)
    8767
    8868distrib = setup(name='aubio',
     
    10585    cmdclass = {
    10686        'clean': CleanGenerated,
    107         'generate': GenerateCommand,
    10887        'build_ext': build_ext,
    10988        },
Note: See TracChangeset for help on using the changeset viewer.