Changeset a89ed31


Ignore:
Timestamp:
Apr 25, 2016, 11:33:11 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:
c31b589
Parents:
07867cd
Message:

python/setup.py: add command 'generate' with option '--enable-double'

Location:
python
Files:
1 added
4 edited

Legend:

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

    r07867cd ra89ed31  
    11#include <Python.h>
    22#include <structmember.h>
     3
     4#include "aubio-generated.h"
    35
    46#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
  • python/ext/aubiomodule.c

    r07867cd ra89ed31  
    11#define PY_AUBIO_MODULE_MAIN
    22#include "aubio-types.h"
    3 #include "aubio-generated.h"
    43#include "py-musicutils.h"
    54
  • python/lib/gen_external.py

    r07867cd ra89ed31  
    1 import os
     1import os, glob
    22
    33header = """// this file is generated! do not modify
     
    6767    return cpp_output, cpp_objects
    6868
    69 def generate_external(output_path, usedouble = False):
     69def generate_external(output_path, usedouble = False, overwrite = True):
    7070    if not os.path.isdir(output_path): os.mkdir(output_path)
     71    elif overwrite == False: return glob.glob(os.path.join(output_path, '*.c'))
    7172    sources_list = []
    7273    cpp_output, cpp_objects = get_cpp_objects()
     
    161162
    162163    objlist = "".join(["extern PyTypeObject Py_%sType;\n" % p for p in lib])
    163     out = """
    164 // generated list of objects created with gen_external.py
     164    out = """// generated list of objects created with gen_external.py
     165
    165166#include <Python.h>
    166 
     167"""
     168    if usedouble:
     169        out += """
     170#ifndef HAVE_AUBIO_DOUBLE
     171#define HAVE_AUBIO_DOUBLE 1
     172#endif
     173"""
     174    out += """
    167175{objlist}
    168176int generated_objects ( void );
  • python/setup.py

    r07867cd ra89ed31  
    11#! /usr/bin/env python
    22
    3 from setuptools import setup, Extension
     3from setuptools import setup, Extension, Command
     4from lib.moresetuptools import CleanGenerated, GenerateCommand
    45
    56import sys
     
    1314        + AUBIO_VERSION_STATUS
    1415
     16# function to generate gen/*.{c,h}
     17from lib.gen_external import generate_external
     18output_path = 'gen'
    1519
    1620include_dirs = []
     
    1923extra_link_args = []
    2024
    21 include_dirs += ['ext']
     25include_dirs += [ 'ext' ]
     26include_dirs += [ output_path ] # aubio-generated.h
    2227include_dirs += [ numpy.get_include() ]
    2328
    2429if sys.platform.startswith('darwin'):
    2530    extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox']
    26 
    27 output_path = 'gen'
    28 generated_object_files = []
    29 
    30 if not os.path.isdir(output_path):
    31     from lib.gen_external import generate_external
    32     generated_object_files = generate_external(output_path)
    33     # define include dirs
    34 else:
    35     import glob
    36     generated_object_files = glob.glob(os.path.join(output_path, '*.c'))
    37 include_dirs += [output_path]
    3831
    3932if os.path.isfile('../src/aubio.h'):
     
    5750    "ext/py-source.c",
    5851    "ext/py-sink.c",
    59     # generated files
    60     ] + generated_object_files,
     52    # generate files if they don't exit
     53    ] + generate_external(output_path, overwrite = False),
    6154    include_dirs = include_dirs,
    6255    library_dirs = library_dirs,
     
    9790    classifiers = classifiers,
    9891    install_requires = ['numpy'],
     92    cmdclass = {
     93        'clean': CleanGenerated,
     94        'generate': GenerateCommand,
     95        }
    9996    )
Note: See TracChangeset for help on using the changeset viewer.