Changeset ad5203c for python


Ignore:
Timestamp:
Mar 5, 2013, 5:46:48 PM (11 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:
63f6c13
Parents:
208336b
Message:

python/: improve build

Location:
python
Files:
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • python/ext/aubio-types.h

    r208336b rad5203c  
    1111#ifndef PY_AUBIO_MODULE_MAIN
    1212#define NO_IMPORT_ARRAY
     13#endif
     14#include <numpy/arrayobject.h>
     15#ifndef PY_AUBIO_MODULE_UFUNC
    1316#define NO_IMPORT_UFUNC
     17#else
     18#include <numpy/ufuncobject.h>
    1419#endif
    1520
    1621// import aubio
    17 #include <numpy/ndarraytypes.h>
    18 #include <numpy/ufuncobject.h>
    19 #include <numpy/npy_3kcompat.h>
     22//#include <numpy/npy_3kcompat.h>
    2023
    2124#define AUBIO_UNSTABLE 1
    22 #include <aubio.h>
     25#include "aubio.h"
    2326
    2427#define Py_default_vector_length 1024
  • python/ext/aubiomodule.c

    r208336b rad5203c  
    11#define PY_AUBIO_MODULE_MAIN
    22#include "aubio-types.h"
    3 #include "generated/aubio-generated.h"
     3#include "aubio-generated.h"
     4
     5extern void add_generated_objects ( PyObject *m );
     6extern void add_ufuncs ( PyObject *m );
    47
    58static char Py_alpha_norm_doc[] = "compute alpha normalisation factor";
     
    262265
    263266  err = _import_array ();
    264 
    265267  if (err != 0) {
    266268    fprintf (stderr,
    267         "Unable to import Numpy C API from aubio module (error %d)\n", err);
     269        "Unable to import Numpy array from aubio module (error %d)\n", err);
    268270  }
    269271
  • python/ext/ufuncs.c

    r208336b rad5203c  
     1#define PY_AUBIO_MODULE_UFUNC
    12#include "aubio-types.h"
    23
     
    6162void add_ufuncs ( PyObject *m )
    6263{
    63   int err = _import_umath();
     64  int err = 0;
    6465
     66  err = _import_umath ();
    6567  if (err != 0) {
    6668    fprintf (stderr,
    67             "Unable to import Numpy C API Ufunc from aubio module (error %d)\n", err);
     69        "Unable to import Numpy umath from aubio module (error %d)\n", err);
    6870  }
    6971
  • python/gen_pyobject.py

    r208336b rad5203c  
    173173
    174174// WARNING: if you haven't read the first line yet, please do so
    175 #include "ext/aubiowraphell.h"
     175#include "aubiowraphell.h"
    176176
    177177typedef struct
  • python/generator.py

    r208336b rad5203c  
    2828  return cpp_output, cpp_objects
    2929
    30 def generate_object_files():
    31   if os.path.isdir('generated'): shutil.rmtree('generated')
    32   os.mkdir('generated')
     30def generate_object_files(output_path):
     31  if os.path.isdir(output_path): shutil.rmtree(output_path)
     32  os.mkdir(output_path)
    3333
    3434  generated_objects = []
     
    4949  for this_object in cpp_objects:
    5050      lint = 0
    51    
     51
    5252      if this_object[-2:] == '_t':
    5353          object_name = this_object[:-2]
     
    127127      if 1: #try:
    128128          s = gen_new_init(new_methods[0], short_name)
    129           s += gen_do(do_methods[0], short_name) 
     129          s += gen_do(do_methods[0], short_name)
    130130          s += gen_members(new_methods[0], short_name)
    131131          s += gen_methods(get_methods, set_methods, short_name)
    132132          s += gen_finish(short_name)
    133           generated_filepath = 'generated/gen-'+short_name+'.c'
     133          generated_filepath = os.path.join(output_path,'gen-'+short_name+'.c')
    134134          fd = open(generated_filepath, 'w')
    135135          fd.write(s)
     
    175175  }"""
    176176
    177   fd = open('generated/aubio-generated.h', 'w')
     177  fd = open(os.path.join(output_path,'aubio-generated.h'), 'w')
    178178  fd.write(s)
    179179
    180180  from os import listdir
    181   generated_files = listdir('generated')
     181  generated_files = listdir(output_path)
    182182  generated_files = filter(lambda x: x.endswith('.c'), generated_files)
    183   generated_files = ['generated/'+f for f in generated_files]
     183  generated_files = [output_path+'/'+f for f in generated_files]
    184184  return generated_files
    185185
    186186if __name__ == '__main__':
    187   generate_object_files()
     187  generate_object_files('gen')
  • python/setup.py

    r208336b rad5203c  
    22
    33from distutils.core import setup, Extension
    4 from generator import generate_object_files
    54import sys
    65import os.path
     
    87
    98# read from VERSION
    10 for l in open(os.path.join('..','VERSION')).readlines(): exec (l.strip())
     9for l in open('VERSION').readlines(): exec (l.strip())
    1110__version__ = '.'.join \
    1211        ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \
    1312        + AUBIO_VERSION_STATUS
    1413
    15 library_dirs = ['../build/src', '../src/.libs']
    16 include_dirs = ['../build/src', '../src', '.' ]
     14library_dirs = ['../build/src']
     15include_dirs = ['../src'] # aubio.h
     16include_dirs += ['../build/src'] # config.h
     17include_dirs += ['ext']
     18include_dirs += ['gen']
     19#include_dirs += ['../build/src', '../src', '.' ]
     20
    1721library_dirs = filter (lambda x: os.path.isdir(x), library_dirs)
    1822include_dirs = filter (lambda x: os.path.isdir(x), include_dirs)
     23
     24generated_object_files = []
     25
     26output_path = 'gen'
     27
     28if not os.path.isdir(output_path):
     29    from generator import generate_object_files
     30    generated_object_files = generate_object_files(output_path)
     31else:
     32    import glob
     33    generated_object_files = glob.glob(os.path.join(output_path, '*.c'))
    1934
    2035aubio_extension = Extension("aubio._aubio", [
     
    3045            "ext/py-phasevoc.c",
    3146            # generated files
    32             ] + generate_object_files(),
     47            ] + generated_object_files,
    3348        include_dirs = include_dirs + [ numpy.get_include() ],
    3449        library_dirs = library_dirs,
Note: See TracChangeset for help on using the changeset viewer.