Changeset 2675227 for setup.py


Ignore:
Timestamp:
May 14, 2016, 9:45:03 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, pitchshift, sampler, timestretch, yinfft+
Children:
6e8b8f4
Parents:
283bb90
Message:

setup.py: clean-up, add option to build libaubio inside python-aubio

The setup script now attempts to build the _aubio extension as follows:

  • if src/aubio.h is found, use it to generate python/gen/ files
  • if build/src/ is found, use it to link python-aubio against libaubio
  • otherwise:
    • add all libaubio source (src/*) to the python module sources
    • look for optional dependencies using pkg-config
    • set flags accordingly
  • otherwise, look for aubio headers and libraries using pkg-config

This should help building the python module in a virtualenv (#2),
on windows (#55), and allow installing aubio directly with pip.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • setup.py

    r283bb90 r2675227  
    11#! /usr/bin/env python
    22
    3 import sys
    4 import os.path
     3import sys, os.path, glob
    54import numpy
    65from setuptools import setup, Extension
    7 from python.lib.moresetuptools import CleanGenerated, GenerateCommand
     6from python.lib.moresetuptools import *
    87# function to generate gen/*.{c,h}
    98from python.lib.gen_external import generate_external, header, output_path
     
    2726    extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox']
    2827
    29 if os.path.isfile('src/aubio.h'):
    30     define_macros += [('USE_LOCAL_AUBIO', 1)]
    31     include_dirs += ['src'] # aubio.h
    32     library_dirs += ['build/src']
     28sources = glob.glob(os.path.join('python', 'ext', '*.c'))
    3329
    34 aubio_extension = Extension("aubio._aubio", [
    35     "python/ext/aubiomodule.c",
    36     "python/ext/aubioproxy.c",
    37     "python/ext/ufuncs.c",
    38     "python/ext/py-musicutils.c",
    39     "python/ext/py-cvec.c",
    40     "python/ext/py-filter.c",
    41     "python/ext/py-filterbank.c",
    42     "python/ext/py-fft.c",
    43     "python/ext/py-phasevoc.c",
    44     "python/ext/py-source.c",
    45     "python/ext/py-sink.c",
    46     # generate files if they don't exit
    47     ] + generate_external(header, output_path, overwrite = False),
     30aubio_extension = Extension("aubio._aubio",
     31    sources,
    4832    include_dirs = include_dirs,
    4933    library_dirs = library_dirs,
    5034    extra_link_args = extra_link_args,
    51     define_macros = define_macros,
    52     libraries=['aubio'])
     35    define_macros = define_macros)
     36
     37if os.path.isfile('src/aubio.h'):
     38    # if aubio headers are found in this directory
     39    add_local_aubio_header(aubio_extension)
     40    # was waf used to build the shared lib?
     41    if os.path.isdir(os.path.join('build','src')):
     42        # link against build/src/libaubio, built with waf
     43        add_local_aubio_lib(aubio_extension)
     44    else:
     45        # add libaubio sources and look for optional deps with pkg-config
     46        add_local_aubio_sources(aubio_extension)
     47        __version__ += '_libaubio'
     48else:
     49    # look for aubio headers and lib using pkg-config
     50    add_system_aubio(aubio_extension)
     51
     52
     53# generate files if they don't exit
     54aubio_extension.sources += generate_external(header, output_path, overwrite = False)
    5355
    5456classifiers = [
Note: See TracChangeset for help on using the changeset viewer.