Changeset 8d09036


Ignore:
Timestamp:
Oct 3, 2016, 4:40:48 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, sampler, yinfft+
Children:
5864b43
Parents:
45521d2
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

    r45521d2 r8d09036  
    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

    r45521d2 r8d09036  
    128128        distutils.command.clean.clean.run(self)
    129129
    130 class GenerateCommand(distutils.cmd.Command):
    131     description = 'generate gen/gen-*.c files from ../src/aubio.h'
    132     user_options = [
     130from distutils.command.build_ext import build_ext as _build_ext
     131class build_ext(_build_ext):
     132
     133    user_options = _build_ext.user_options + [
    133134            # The format is (long option, short option, description).
    134135            ('enable-double', None, 'use HAVE_AUBIO_DOUBLE=1 (default: 0)'),
     
    136137
    137138    def initialize_options(self):
     139        _build_ext.initialize_options(self)
    138140        self.enable_double = False
    139141
    140142    def finalize_options(self):
     143        _build_ext.finalize_options(self)
    141144        if self.enable_double:
    142145            self.announce(
     
    144147                    level=distutils.log.INFO)
    145148
    146     def run(self):
    147         self.announce( 'Generating code', level=distutils.log.INFO)
    148         generated_object_files = generate_external(header, output_path, usedouble=self.enable_double)
     149    def build_extension(self, extension):
     150        if self.enable_double:
     151            extension.define_macros += [('HAVE_AUBIO_DOUBLE', 1)]
     152        if os.path.isfile('src/aubio.h'):
     153            # if aubio headers are found in this directory
     154            add_local_aubio_header(extension)
     155            # was waf used to build the shared lib?
     156            if os.path.isdir(os.path.join('build','src')):
     157                # link against build/src/libaubio, built with waf
     158                add_local_aubio_lib(extension)
     159            else:
     160                # add libaubio sources and look for optional deps with pkg-config
     161                add_local_aubio_sources(extension, usedouble=self.enable_double)
     162        else:
     163            # look for aubio headers and lib using pkg-config
     164            add_system_aubio(extension)
     165        # generate files python/gen/*.c, python/gen/aubio-generated.h
     166        extension.sources += generate_external(header, output_path, overwrite = False,
     167                usedouble=self.enable_double)
     168        return _build_ext.build_extension(self, extension)
  • setup.py

    r45521d2 r8d09036  
    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.