// only import array and ufunc from main module
#ifndef PY_AUBIO_MODULE_MAIN
#define NO_IMPORT_ARRAY
+#endif
+#include <numpy/arrayobject.h>
+#ifndef PY_AUBIO_MODULE_UFUNC
#define NO_IMPORT_UFUNC
+#else
+#include <numpy/ufuncobject.h>
#endif
// import aubio
-#include <numpy/ndarraytypes.h>
-#include <numpy/ufuncobject.h>
-#include <numpy/npy_3kcompat.h>
+//#include <numpy/npy_3kcompat.h>
#define AUBIO_UNSTABLE 1
-#include <aubio.h>
+#include "aubio.h"
#define Py_default_vector_length 1024
#define PY_AUBIO_MODULE_MAIN
#include "aubio-types.h"
-#include "generated/aubio-generated.h"
+#include "aubio-generated.h"
+
+extern void add_generated_objects ( PyObject *m );
+extern void add_ufuncs ( PyObject *m );
static char Py_alpha_norm_doc[] = "compute alpha normalisation factor";
}
err = _import_array ();
-
if (err != 0) {
fprintf (stderr,
- "Unable to import Numpy C API from aubio module (error %d)\n", err);
+ "Unable to import Numpy array from aubio module (error %d)\n", err);
}
Py_INCREF (&Py_cvecType);
+#define PY_AUBIO_MODULE_UFUNC
#include "aubio-types.h"
static void unwrap2pi(char **args, npy_intp *dimensions,
void add_ufuncs ( PyObject *m )
{
- int err = _import_umath();
+ int err = 0;
+ err = _import_umath ();
if (err != 0) {
fprintf (stderr,
- "Unable to import Numpy C API Ufunc from aubio module (error %d)\n", err);
+ "Unable to import Numpy umath from aubio module (error %d)\n", err);
}
PyObject *f, *dict;
// WARNING: this file is generated, DO NOT EDIT
// WARNING: if you haven't read the first line yet, please do so
-#include "ext/aubiowraphell.h"
+#include "aubiowraphell.h"
typedef struct
{
return cpp_output, cpp_objects
-def generate_object_files():
- if os.path.isdir('generated'): shutil.rmtree('generated')
- os.mkdir('generated')
+def generate_object_files(output_path):
+ if os.path.isdir(output_path): shutil.rmtree(output_path)
+ os.mkdir(output_path)
generated_objects = []
cpp_output, cpp_objects = get_cpp_objects()
for this_object in cpp_objects:
lint = 0
-
+
if this_object[-2:] == '_t':
object_name = this_object[:-2]
else:
continue
if 1: #try:
s = gen_new_init(new_methods[0], short_name)
- s += gen_do(do_methods[0], short_name)
+ s += gen_do(do_methods[0], short_name)
s += gen_members(new_methods[0], short_name)
s += gen_methods(get_methods, set_methods, short_name)
s += gen_finish(short_name)
- generated_filepath = 'generated/gen-'+short_name+'.c'
+ generated_filepath = os.path.join(output_path,'gen-'+short_name+'.c')
fd = open(generated_filepath, 'w')
fd.write(s)
#except Exception, e:
s += """
}"""
- fd = open('generated/aubio-generated.h', 'w')
+ fd = open(os.path.join(output_path,'aubio-generated.h'), 'w')
fd.write(s)
from os import listdir
- generated_files = listdir('generated')
+ generated_files = listdir(output_path)
generated_files = filter(lambda x: x.endswith('.c'), generated_files)
- generated_files = ['generated/'+f for f in generated_files]
+ generated_files = [output_path+'/'+f for f in generated_files]
return generated_files
if __name__ == '__main__':
- generate_object_files()
+ generate_object_files('gen')
#! /usr/bin/python
from distutils.core import setup, Extension
-from generator import generate_object_files
import sys
import os.path
import numpy
# read from VERSION
-for l in open(os.path.join('..','VERSION')).readlines(): exec (l.strip())
+for l in open('VERSION').readlines(): exec (l.strip())
__version__ = '.'.join \
([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \
+ AUBIO_VERSION_STATUS
-library_dirs = ['../build/src', '../src/.libs']
-include_dirs = ['../build/src', '../src', '.' ]
+library_dirs = ['../build/src']
+include_dirs = ['../src'] # aubio.h
+include_dirs += ['../build/src'] # config.h
+include_dirs += ['ext']
+include_dirs += ['gen']
+#include_dirs += ['../build/src', '../src', '.' ]
+
library_dirs = filter (lambda x: os.path.isdir(x), library_dirs)
include_dirs = filter (lambda x: os.path.isdir(x), include_dirs)
+generated_object_files = []
+
+output_path = 'gen'
+
+if not os.path.isdir(output_path):
+ from generator import generate_object_files
+ generated_object_files = generate_object_files(output_path)
+else:
+ import glob
+ generated_object_files = glob.glob(os.path.join(output_path, '*.c'))
+
aubio_extension = Extension("aubio._aubio", [
"ext/aubiomodule.c",
"ext/aubioproxy.c",
"ext/py-fft.c",
"ext/py-phasevoc.c",
# generated files
- ] + generate_object_files(),
+ ] + generated_object_files,
include_dirs = include_dirs + [ numpy.get_include() ],
library_dirs = library_dirs,
libraries=['aubio'])
+++ /dev/null
-
-try:
- from aubio.aubiowrapper import *
-except ImportError:
- try:
- import os
- import sys
- cur_dir = os.path.dirname(sys.argv[0])
- sys.path.append(os.path.join(cur_dir,'..','..','python'))
- sys.path.append(os.path.join(cur_dir,'..','..','python','aubio','.libs'))
- from aubio.aubiowrapper import *
- except ImportError:
- raise