- Timestamp:
- May 13, 2016, 6:50:20 PM (9 years ago)
- 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
- Location:
- python/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/lib/gen_external.py
rc09efca r1167631 1 1 import os, glob 2 2 3 header = """// this file is generated! do not modify 3 header = 'src/aubio.h' 4 output_path = 'python/gen' 5 6 source_header = """// this file is generated! do not modify 4 7 #include "aubio-types.h" 5 8 """ … … 42 45 43 46 44 def get_cpp_objects( ):47 def get_cpp_objects(header=header): 45 48 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()] 47 50 #cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=0 -I../build/src ../src/onset/onset.h').readlines()] 48 51 #cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=0 -I../build/src ../src/pitch/pitch.h').readlines()] … … 67 70 return cpp_output, cpp_objects 68 71 69 def generate_external( output_path, usedouble = False, overwrite =True):72 def generate_external(header=header, output_path=output_path, usedouble=False, overwrite=True): 70 73 if not os.path.isdir(output_path): os.mkdir(output_path) 71 74 elif overwrite == False: return glob.glob(os.path.join(output_path, '*.c')) 72 75 sources_list = [] 73 cpp_output, cpp_objects = get_cpp_objects( )76 cpp_output, cpp_objects = get_cpp_objects(header) 74 77 lib = {} 75 78 … … 122 125 """ 123 126 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 125 131 for o in lib: 126 out = header132 out = source_header 127 133 mapped = MappedObject(lib[o], usedouble = usedouble) 128 134 out += mapped.gen_code() … … 133 139 sources_list.append(output_file) 134 140 135 out = header141 out = source_header 136 142 out += "#include \"aubio-generated.h\"" 137 143 check_types = "\n || ".join(["PyType_Ready(&Py_%sType) < 0" % o for o in lib]) … … 187 193 188 194 if __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 1 1 import distutils, distutils.command.clean, distutils.dir_util 2 from .gen_external import generate_external, header, output_path 2 3 3 4 class CleanGenerated(distutils.command.clean.clean): 4 5 def run(self): 5 distutils.dir_util.remove_tree( 'gen')6 distutils.dir_util.remove_tree(output_path) 6 7 distutils.command.clean.clean.run(self) 7 8 … … 24 25 def run(self): 25 26 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.