Changeset 1167631 for python


Ignore:
Timestamp:
May 13, 2016, 6:50:20 PM (9 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:
2e324f5
Parents:
c09efca
Message:

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

Location:
python/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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)
Note: See TracChangeset for help on using the changeset viewer.