History

move python/setup.py to setup.py, update Makefile, add requirements

Paul Brossier committed 10 years ago

Commit 11676311 parent c09efca6 files · +63 −52Browse files

Showing the changes to python (4 of 6 files). Show all

Unified · Split

4 files
  1. python/lib/gen_external.py +18 −10
  2. python/lib/moresetuptools.py +3 −3
  3. python/nose2.cfg +0 −6
  4. python/setup.py +0 −95
python/lib/gen_external.py+18−10
@@ -1,6 +1,9 @@
1import os, glob1import os, glob
2 2
3header = """// this file is generated! do not modify3header = 'src/aubio.h'
4output_path = 'python/gen'
5
6source_header = """// this file is generated! do not modify
4#include "aubio-types.h"7#include "aubio-types.h"
5"""8"""
6 9
@@ -41,9 +44,9 @@ skip_objects = [ · 34 unmodified lines
41 ]44 ]
42 45
43 46
44def get_cpp_objects():47def 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 #cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=0 -I../build/src ../src/onset/onset.h').readlines()]50 #cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=0 -I../build/src ../src/onset/onset.h').readlines()]
48 #cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=0 -I../build/src ../src/pitch/pitch.h').readlines()]51 #cpp_output = [l.strip() for l in os.popen('cpp -DAUBIO_UNSTABLE=0 -I../build/src ../src/pitch/pitch.h').readlines()]
49 52
@@ -66,11 +69,11 @@ def get_cpp_objects(): · 16 unmodified lines
66 69
67 return cpp_output, cpp_objects70 return cpp_output, cpp_objects
68 71
69def generate_external(output_path, usedouble = False, overwrite = True):72def generate_external(header=header, output_path=output_path, usedouble=False, overwrite=True):
70 if not os.path.isdir(output_path): os.mkdir(output_path)73 if not os.path.isdir(output_path): os.mkdir(output_path)
71 elif overwrite == False: return glob.glob(os.path.join(output_path, '*.c'))74 elif overwrite == False: return glob.glob(os.path.join(output_path, '*.c'))
72 sources_list = []75 sources_list = []
73 cpp_output, cpp_objects = get_cpp_objects()76 cpp_output, cpp_objects = get_cpp_objects(header)
74 lib = {}77 lib = {}
75 78
76 for o in cpp_objects:79 for o in cpp_objects:
@@ -121,9 +124,12 @@ def generate_external(output_path, usedouble = False, overwrite = True): · 44 unmodified lines
121 print ( "{:15s} {:10s} {:d}".format(o, family, len(lib[o][family]) ) )124 print ( "{:15s} {:10s} {:d}".format(o, family, len(lib[o][family]) ) )
122 """125 """
123 126
124 from .gen_code import MappedObject127 try:
128 from .gen_code import MappedObject
129 except (SystemError, ValueError) as e:
130 from gen_code import MappedObject
125 for o in lib:131 for o in lib:
126 out = header132 out = source_header
127 mapped = MappedObject(lib[o], usedouble = usedouble)133 mapped = MappedObject(lib[o], usedouble = usedouble)
128 out += mapped.gen_code()134 out += mapped.gen_code()
129 output_file = os.path.join(output_path, 'gen-%s.c' % o)135 output_file = os.path.join(output_path, 'gen-%s.c' % o)
@@ -132,7 +138,7 @@ def generate_external(output_path, usedouble = False, overwrite = True): · 2 unmodified lines
132 print ("wrote %s" % output_file )138 print ("wrote %s" % output_file )
133 sources_list.append(output_file)139 sources_list.append(output_file)
134 140
135 out = header141 out = source_header
136 out += "#include \"aubio-generated.h\""142 out += "#include \"aubio-generated.h\""
137 check_types = "\n || ".join(["PyType_Ready(&Py_%sType) < 0" % o for o in lib])143 check_types = "\n || ".join(["PyType_Ready(&Py_%sType) < 0" % o for o in lib])
138 out += """144 out += """
@@ -186,5 +192,7 @@ void add_generated_objects( PyObject *m ); · 47 unmodified lines
186 return sources_list192 return sources_list
187 193
188if __name__ == '__main__':194if __name__ == '__main__':
189 output_path = 'gen'195 import sys
190 generate_external(output_path)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+3−3
@@ -1,8 +1,9 @@
1import distutils, distutils.command.clean, distutils.dir_util1import distutils, distutils.command.clean, distutils.dir_util
2from .gen_external import generate_external, header, output_path
2 3
3class CleanGenerated(distutils.command.clean.clean):4class CleanGenerated(distutils.command.clean.clean):
4 def run(self):5 def run(self):
5 distutils.dir_util.remove_tree('gen')6 distutils.dir_util.remove_tree(output_path)
6 distutils.command.clean.clean.run(self)7 distutils.command.clean.clean.run(self)
7 8
8class GenerateCommand(distutils.cmd.Command):9class GenerateCommand(distutils.cmd.Command):
@@ -23,5 +24,4 @@ class GenerateCommand(distutils.cmd.Command): · 14 unmodified lines
23 24
24 def run(self):25 def run(self):
25 self.announce( 'Generating code', level=distutils.log.INFO)26 self.announce( 'Generating code', level=distutils.log.INFO)
26 from .gen_external import generate_external27 generated_object_files = generate_external(header, output_path, usedouble = self.enable_double)
27 generated_object_files = generate_external('gen', usedouble = self.enable_double)
python/nose2.cfg+0−6
@@ -1,6 +0,0 @@
1[unittest]
2start-dir = tests/
3plugins = nose2.plugins.mp
4
5[multiprocess]
6always-on = true
python/setup.py+0−95
@@ -1,95 +0,0 @@
1#! /usr/bin/env python
2
3from setuptools import setup, Extension
4from lib.moresetuptools import CleanGenerated, GenerateCommand
5
6import sys
7import os.path
8import numpy
9
10# read from VERSION
11for l in open('VERSION').readlines(): exec (l.strip())
12__version__ = '.'.join \
13 ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \
14 + AUBIO_VERSION_STATUS
15
16# function to generate gen/*.{c,h}
17from lib.gen_external import generate_external
18output_path = 'gen'
19
20include_dirs = []
21library_dirs = []
22define_macros = []
23extra_link_args = []
24
25include_dirs += [ 'ext' ]
26include_dirs += [ output_path ] # aubio-generated.h
27include_dirs += [ numpy.get_include() ]
28
29if sys.platform.startswith('darwin'):
30 extra_link_args += ['-framework','CoreFoundation', '-framework','AudioToolbox']
31
32if os.path.isfile('../src/aubio.h'):
33 define_macros += [('USE_LOCAL_AUBIO', 1)]
34 include_dirs += ['../src'] # aubio.h
35 library_dirs += ['../build/src']
36
37aubio_extension = Extension("aubio._aubio", [
38 "ext/aubiomodule.c",
39 "ext/aubioproxy.c",
40 "ext/ufuncs.c",
41 "ext/py-musicutils.c",
42 "ext/py-cvec.c",
43 # example without macro
44 "ext/py-filter.c",
45 # macroised
46 "ext/py-filterbank.c",
47 "ext/py-fft.c",
48 "ext/py-phasevoc.c",
49 "ext/py-source.c",
50 "ext/py-sink.c",
51 # generate files if they don't exit
52 ] + generate_external(output_path, overwrite = False),
53 include_dirs = include_dirs,
54 library_dirs = library_dirs,
55 extra_link_args = extra_link_args,
56 define_macros = define_macros,
57 libraries=['aubio'])
58
59classifiers = [
60 'Development Status :: 4 - Beta',
61 'Environment :: Console',
62 'Intended Audience :: Science/Research',
63 'Topic :: Software Development :: Libraries',
64 'Topic :: Multimedia :: Sound/Audio :: Analysis',
65 'Topic :: Multimedia :: Sound/Audio :: Sound Synthesis',
66 'Operating System :: POSIX',
67 'Operating System :: MacOS :: MacOS X',
68 'Operating System :: Microsoft :: Windows',
69 'Programming Language :: C',
70 'Programming Language :: Python',
71 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
72 ]
73
74distrib = setup(name='aubio',
75 version = __version__,
76 packages = ['aubio'],
77 package_dir = {'aubio':'lib/aubio'},
78 scripts = ['scripts/aubiocut'],
79 ext_modules = [aubio_extension],
80 description = 'interface to the aubio library',
81 long_description = 'interface to the aubio library',
82 license = 'GNU/GPL version 3',
83 author = 'Paul Brossier',
84 author_email = 'piem@aubio.org',
85 maintainer = 'Paul Brossier',
86 maintainer_email = 'piem@aubio.org',
87 url = 'http://aubio.org/',
88 platforms = 'any',
89 classifiers = classifiers,
90 install_requires = ['numpy'],
91 cmdclass = {
92 'clean': CleanGenerated,
93 'generate': GenerateCommand,
94 }
95 )

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