Changeset 1167631


Ignore:
Timestamp:
May 13, 2016, 6:50:20 PM (4 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
2e324f5
Parents:
c09efca
Message:

move python/setup.py to setup.py, update Makefile, add requirements

Files:
1 added
3 edited
2 moved

Legend:

Unmodified
Added
Removed
  • Makefile

    rc09efca r1167631  
    2929
    3030build_python:
    31         cd python && python ./setup.py generate $(ENABLE_DOUBLE) build
     31        python ./setup.py generate $(ENABLE_DOUBLE) build
    3232
     33test_python: export LD_LIBRARY_PATH=$(PWD)/build/src
    3334test_python:
    34         cd python && pip install -v .
    35         cd python && LD_LIBRARY_PATH=$(PWD)/build/src nose2 --verbose
    36         cd python && pip uninstall -y -v aubio
     35        pip install -v -r requirements.txt
     36        pip install -v .
     37        nose2 --verbose
     38        pip uninstall -y -v aubio
    3739
    3840test_python_osx:
    39         cd python && pip install --user -v .
     41        # create links from ~/lib/lib* to build/src/lib*
    4042        [ -f build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.4.dylib ~/lib ) || true
    41         cd python && nose2 --verbose
    42         cd python && pip uninstall -y -v aubio
     43        # then run the tests
     44        pip install --user -v -r requirements.txt
     45        pip install --user -v .
     46        nose2 --verbose
     47        pip uninstall -y -v aubio
    4348
    4449clean_python:
    45         cd python && ./setup.py clean
     50        ./setup.py clean
    4651
    4752build_python3:
    48         cd python && python3 ./setup.py generate $(ENABLE_DOUBLE) build
     53        python3 ./setup.py generate $(ENABLE_DOUBLE) build
    4954
    5055clean_python3:
    51         cd python && python3 ./setup.py clean
     56        python3 ./setup.py clean
    5257
    5358clean:
  • nose2.cfg

    rc09efca r1167631  
    11[unittest]
    2 start-dir = tests/
     2start-dir = python/tests/
    33plugins = nose2.plugins.mp
    44
  • python/lib/gen_external.py

    rc09efca r1167631  
    11import os, glob
    22
    3 header = """// this file is generated! do not modify
     3header = 'src/aubio.h'
     4output_path = 'python/gen'
     5
     6source_header = """// this file is generated! do not modify
    47#include "aubio-types.h"
    58"""
     
    4245
    4346
    44 def get_cpp_objects():
     47def get_cpp_objects(header=header):
    4548
    46     cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=1 -I../build/src ../src/aubio.h').readlines()]
     49    cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=1 {:s}'.format(header)).readlines()]
    4750    #cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=0 -I../build/src ../src/onset/onset.h').readlines()]
    4851    #cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=0 -I../build/src ../src/pitch/pitch.h').readlines()]
     
    6770    return cpp_output, cpp_objects
    6871
    69 def generate_external(output_path, usedouble = False, overwrite = True):
     72def generate_external(header=header, output_path=output_path, usedouble=False, overwrite=True):
    7073    if not os.path.isdir(output_path): os.mkdir(output_path)
    7174    elif overwrite == False: return glob.glob(os.path.join(output_path, '*.c'))
    7275    sources_list = []
    73     cpp_output, cpp_objects = get_cpp_objects()
     76    cpp_output, cpp_objects = get_cpp_objects(header)
    7477    lib = {}
    7578
     
    122125    """
    123126
    124     from .gen_code import MappedObject
     127    try:
     128        from .gen_code import MappedObject
     129    except (SystemError, ValueError) as e:
     130        from gen_code import MappedObject
    125131    for o in lib:
    126         out = header
     132        out = source_header
    127133        mapped = MappedObject(lib[o], usedouble = usedouble)
    128134        out += mapped.gen_code()
     
    133139            sources_list.append(output_file)
    134140
    135     out = header
     141    out = source_header
    136142    out += "#include \"aubio-generated.h\""
    137143    check_types = "\n     ||  ".join(["PyType_Ready(&Py_%sType) < 0" % o for o in lib])
     
    187193
    188194if __name__ == '__main__':
    189     output_path = 'gen'
    190     generate_external(output_path)
     195    import sys
     196    if len(sys.argv) > 1: header = sys.argv[1]
     197    if len(sys.argv) > 2: output_path = sys.argv[2]
     198    generate_external(header, output_path)
  • python/lib/moresetuptools.py

    rc09efca r1167631  
    11import distutils, distutils.command.clean, distutils.dir_util
     2from .gen_external import generate_external, header, output_path
    23
    34class CleanGenerated(distutils.command.clean.clean):
    45    def run(self):
    5         distutils.dir_util.remove_tree('gen')
     6        distutils.dir_util.remove_tree(output_path)
    67        distutils.command.clean.clean.run(self)
    78
     
    2425    def run(self):
    2526        self.announce( 'Generating code', level=distutils.log.INFO)
    26         from .gen_external import generate_external
    27         generated_object_files = generate_external('gen', usedouble = self.enable_double)
     27        generated_object_files = generate_external(header, output_path, usedouble = self.enable_double)
  • setup.py

    rc09efca r1167631  
    11#! /usr/bin/env python
    2 
    3 from setuptools import setup, Extension
    4 from lib.moresetuptools import CleanGenerated, GenerateCommand
    52
    63import sys
    74import os.path
    85import numpy
     6from setuptools import setup, Extension
     7from python.lib.moresetuptools import CleanGenerated, GenerateCommand
     8# function to generate gen/*.{c,h}
     9from python.lib.gen_external import generate_external, header, output_path
    910
    1011# read from VERSION
     
    1415        + AUBIO_VERSION_STATUS
    1516
    16 # function to generate gen/*.{c,h}
    17 from lib.gen_external import generate_external
    18 output_path = 'gen'
    19 
    2017include_dirs = []
    2118library_dirs = []
     
    2320extra_link_args = []
    2421
    25 include_dirs += [ 'ext' ]
     22include_dirs += [ 'python/ext' ]
    2623include_dirs += [ output_path ] # aubio-generated.h
    2724include_dirs += [ numpy.get_include() ]
     
    3027    extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox']
    3128
    32 if os.path.isfile('../src/aubio.h'):
     29if os.path.isfile('src/aubio.h'):
    3330    define_macros += [('USE_LOCAL_AUBIO', 1)]
    34     include_dirs += ['../src'] # aubio.h
    35     library_dirs += ['../build/src']
     31    include_dirs += ['src'] # aubio.h
     32    library_dirs += ['build/src']
    3633
    3734aubio_extension = Extension("aubio._aubio", [
    38     "ext/aubiomodule.c",
    39     "ext/aubioproxy.c",
    40     "ext/ufuncs.c",
    41     "ext/py-musicutils.c",
    42     "ext/py-cvec.c",
    43     # example without macro
    44     "ext/py-filter.c",
    45     # macroised
    46     "ext/py-filterbank.c",
    47     "ext/py-fft.c",
    48     "ext/py-phasevoc.c",
    49     "ext/py-source.c",
    50     "ext/py-sink.c",
     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",
    5146    # generate files if they don't exit
    52     ] + generate_external(output_path, overwrite = False),
     47    ] + generate_external(header, output_path, overwrite = False),
    5348    include_dirs = include_dirs,
    5449    library_dirs = library_dirs,
     
    7570    version = __version__,
    7671    packages = ['aubio'],
    77     package_dir = {'aubio':'lib/aubio'},
    78     scripts = ['scripts/aubiocut'],
     72    package_dir = {'aubio':'python/lib/aubio'},
     73    scripts = ['python/scripts/aubiocut'],
    7974    ext_modules = [aubio_extension],
    8075    description = 'interface to the aubio library',
     
    9287        'clean': CleanGenerated,
    9388        'generate': GenerateCommand,
    94         }
     89        },
     90    test_suite = 'nose2.collector.collector',
    9591    )
Note: See TracChangeset for help on using the changeset viewer.