History

python/: improve build

Paul Brossier committed 13 years ago

Commit ad5203c1 parent 208336b8 files · +47 −38Browse files

Showing the changes to python (7 of 8 files). Show all

Unified · Split

7 files
  1. python/README +0 −0
  2. python/ext/aubio-types.h +7 −4
  3. python/ext/aubiomodule.c +5 −3
  4. python/ext/ufuncs.c +4 −2
  5. python/gen_pyobject.py +1 −1
  6. python/generator.py +10 −10
  7. python/setup.py +20 −5
python/READMErenamed from python/README.md+0−0

File renamed without changes.

python/ext/aubio-types.h+7−4
@@ -10,16 +10,19 @@ · 9 unmodified lines
10// only import array and ufunc from main module10// only import array and ufunc from main module
11#ifndef PY_AUBIO_MODULE_MAIN11#ifndef PY_AUBIO_MODULE_MAIN
12#define NO_IMPORT_ARRAY12#define NO_IMPORT_ARRAY
13#endif
14#include <numpy/arrayobject.h>
15#ifndef PY_AUBIO_MODULE_UFUNC
13#define NO_IMPORT_UFUNC16#define NO_IMPORT_UFUNC
17#else
18#include <numpy/ufuncobject.h>
14#endif19#endif
15 20
16// import aubio21// import aubio
17#include <numpy/ndarraytypes.h>22//#include <numpy/npy_3kcompat.h>
18#include <numpy/ufuncobject.h>
19#include <numpy/npy_3kcompat.h>
20 23
21#define AUBIO_UNSTABLE 124#define AUBIO_UNSTABLE 1
22#include <aubio.h>25#include "aubio.h"
23 26
24#define Py_default_vector_length 102427#define Py_default_vector_length 1024
25 28
python/ext/aubiomodule.c+5−3
@@ -1,6 +1,9 @@
1#define PY_AUBIO_MODULE_MAIN1#define PY_AUBIO_MODULE_MAIN
2#include "aubio-types.h"2#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 );
4 7
5static char Py_alpha_norm_doc[] = "compute alpha normalisation factor";8static char Py_alpha_norm_doc[] = "compute alpha normalisation factor";
6 9
@@ -261,10 +264,9 @@ init_aubio (void) · 254 unmodified lines
261 }264 }
262 265
263 err = _import_array ();266 err = _import_array ();
264
265 if (err != 0) {267 if (err != 0) {
266 fprintf (stderr,268 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);
268 }270 }
269 271
270 Py_INCREF (&Py_cvecType);272 Py_INCREF (&Py_cvecType);
python/ext/ufuncs.c+4−2
@@ -1,3 +1,4 @@
1#define PY_AUBIO_MODULE_UFUNC
1#include "aubio-types.h"2#include "aubio-types.h"
2 3
3static void unwrap2pi(char **args, npy_intp *dimensions,4static void unwrap2pi(char **args, npy_intp *dimensions,
@@ -60,11 +61,12 @@ static char unwrap2pi_types[] = { · 56 unmodified lines
60 61
61void add_ufuncs ( PyObject *m )62void add_ufuncs ( PyObject *m )
62{63{
63 int err = _import_umath();64 int err = 0;
64 65
66 err = _import_umath ();
65 if (err != 0) {67 if (err != 0) {
66 fprintf (stderr,68 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);
68 }70 }
69 71
70 PyObject *f, *dict;72 PyObject *f, *dict;
python/gen_pyobject.py+1−1
@@ -172,7 +172,7 @@ def gen_new_init(newfunc, name): · 171 unmodified lines
172// WARNING: this file is generated, DO NOT EDIT172// WARNING: this file is generated, DO NOT EDIT
173 173
174// WARNING: if you haven't read the first line yet, please do so174// WARNING: if you haven't read the first line yet, please do so
175#include "ext/aubiowraphell.h"175#include "aubiowraphell.h"
176 176
177typedef struct177typedef struct
178{178{
python/generator.py+10−10
@@ -27,9 +27,9 @@ def get_cpp_objects(): · 26 unmodified lines
27 27
28 return cpp_output, cpp_objects28 return cpp_output, cpp_objects
29 29
30def generate_object_files():30def generate_object_files(output_path):
31 if os.path.isdir('generated'): shutil.rmtree('generated')31 if os.path.isdir(output_path): shutil.rmtree(output_path)
32 os.mkdir('generated')32 os.mkdir(output_path)
33 33
34 generated_objects = []34 generated_objects = []
35 cpp_output, cpp_objects = get_cpp_objects()35 cpp_output, cpp_objects = get_cpp_objects()
@@ -48,7 +48,7 @@ def generate_object_files(): · 12 unmodified lines
48 48
49 for this_object in cpp_objects:49 for this_object in cpp_objects:
50 lint = 050 lint = 0
51 51
52 if this_object[-2:] == '_t':52 if this_object[-2:] == '_t':
53 object_name = this_object[:-2]53 object_name = this_object[:-2]
54 else:54 else:
@@ -126,11 +126,11 @@ def generate_object_files(): · 71 unmodified lines
126 continue126 continue
127 if 1: #try:127 if 1: #try:
128 s = gen_new_init(new_methods[0], short_name)128 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)
130 s += gen_members(new_methods[0], short_name)130 s += gen_members(new_methods[0], short_name)
131 s += gen_methods(get_methods, set_methods, short_name)131 s += gen_methods(get_methods, set_methods, short_name)
132 s += gen_finish(short_name)132 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')
134 fd = open(generated_filepath, 'w')134 fd = open(generated_filepath, 'w')
135 fd.write(s)135 fd.write(s)
136 #except Exception, e:136 #except Exception, e:
@@ -174,14 +174,14 @@ def generate_object_files(): · 37 unmodified lines
174 s += """174 s += """
175 }"""175 }"""
176 176
177 fd = open('generated/aubio-generated.h', 'w')177 fd = open(os.path.join(output_path,'aubio-generated.h'), 'w')
178 fd.write(s)178 fd.write(s)
179 179
180 from os import listdir180 from os import listdir
181 generated_files = listdir('generated')181 generated_files = listdir(output_path)
182 generated_files = filter(lambda x: x.endswith('.c'), generated_files)182 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]
184 return generated_files184 return generated_files
185 185
186if __name__ == '__main__':186if __name__ == '__main__':
187 generate_object_files() 187 generate_object_files('gen')
python/setup.py+20−5
@@ -1,22 +1,37 @@
1#! /usr/bin/python1#! /usr/bin/python
2 2
3from distutils.core import setup, Extension3from distutils.core import setup, Extension
4from generator import generate_object_files
5import sys4import sys
6import os.path5import os.path
7import numpy6import numpy
8 7
9# read from VERSION8# read from VERSION
10for l in open(os.path.join('..','VERSION')).readlines(): exec (l.strip())9for l in open('VERSION').readlines(): exec (l.strip())
11__version__ = '.'.join \10__version__ = '.'.join \
12 ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \11 ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \
13 + AUBIO_VERSION_STATUS12 + AUBIO_VERSION_STATUS
14 13
15library_dirs = ['../build/src', '../src/.libs']14library_dirs = ['../build/src']
16include_dirs = ['../build/src', '../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
17library_dirs = filter (lambda x: os.path.isdir(x), library_dirs)21library_dirs = filter (lambda x: os.path.isdir(x), library_dirs)
18include_dirs = filter (lambda x: os.path.isdir(x), include_dirs)22include_dirs = filter (lambda x: os.path.isdir(x), include_dirs)
19 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'))
34
20aubio_extension = Extension("aubio._aubio", [35aubio_extension = Extension("aubio._aubio", [
21 "ext/aubiomodule.c",36 "ext/aubiomodule.c",
22 "ext/aubioproxy.c",37 "ext/aubioproxy.c",
@@ -29,7 +44,7 @@ aubio_extension = Extension("aubio._aubio", [ · 6 unmodified lines
29 "ext/py-fft.c",44 "ext/py-fft.c",
30 "ext/py-phasevoc.c",45 "ext/py-phasevoc.c",
31 # generated files46 # generated files
32 ] + generate_object_files(),47 ] + generated_object_files,
33 include_dirs = include_dirs + [ numpy.get_include() ],48 include_dirs = include_dirs + [ numpy.get_include() ],
34 library_dirs = library_dirs,49 library_dirs = library_dirs,
35 libraries=['aubio'])50 libraries=['aubio'])

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t