Skip to content

πŸŽ› πŸ”Š A Python library for audio.

Attempted fixes for Windows and Ubuntu compilation.

Peter Sobot025fd95b31a1
diff --git a/.github/workflows/all.yml b/.github/workflows/all.yml
index 897c6ee..43e28b7 100644
--- a/.github/workflows/all.yml
+++ b/.github/workflows/all.yml
@@ -35,7 +35,7 @@ jobs:
pip install wheel
pip install -r test-requirements.txt
- name: Lint Python code
- run: flake8 . --count --ignore=W503,E203 --exclude .git,dist,doc,build --show-source --statistics --max-line-length 100
+ run: flake8 . --count --ignore=W503,E203 --exclude .git,dist,doc,build,vendors --show-source --statistics --max-line-length 100
- name: Check Python formatting
run: black pedalboard tests --line-length 100 --experimental-string-processing --diff --check
diff --git a/setup.py b/setup.py
index 92994b2..0f7d5a9 100644
--- a/setup.py
+++ b/setup.py
@@ -107,8 +107,11 @@ ALL_COMPILER_FLAGS.extend(
"-DPROTOTYPES=1",
"-DHAVE_STRCHR",
"-DHAVE_MEMCPY",
- "-Dieee754_float32_t=float",
"-DHAVE_MPGLIB",
+ # Some data types are defined in config.h, which we don't include:
+ "-Dieee754_float32_t=float",
+ "-Duint32_t=u_int32_t",
+ "-Duint16_t=u_int16_t",
]
)
ALL_SOURCE_PATHS += list(Path("vendors/lame/libmp3lame").glob("*.c"))
@@ -236,29 +239,28 @@ else:
)
-class C_CxxCompiler(UnixCCompiler):
- def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
+def patch_compile(original_compile):
+ def new_compile(obj, src, ext, cc_args, extra_postargs, *args, **kwargs):
_cc_args = cc_args
if ext in ('.cpp', '.cxx', '.cc', '.mm'):
_cc_args = cc_args + ALL_CPPFLAGS
- elif ext in ('.c'):
+ elif ext in ('.c',):
# We're compiling C code, remove the -std= arg:
- extra_postargs = [arg for arg in extra_postargs if '-std=' not in arg]
+ extra_postargs = [arg for arg in extra_postargs if 'std=' not in arg]
- UnixCCompiler._compile(self, obj, src, ext, _cc_args, extra_postargs, pp_opts)
+ return original_compile(obj, src, ext, _cc_args, extra_postargs, *args, **kwargs)
+
+ return new_compile
class BuildC_CxxExtensions(build_ext):
+ """
+ Add custom logic for injecting different arguments when compiling C vs C++ files.
+ """
+
def build_extensions(self, *args, **kwargs):
- if self.compiler.compiler_type == 'unix':
- # Replace the compiler
- old_compiler = self.compiler
- self.compiler = C_CxxCompiler()
-
- # Copy its attributes
- for attr, value in old_compiler.__dict__.items():
- setattr(self.compiler, attr, value)
+ self.compiler._compile = patch_compile(self.compiler._compile)
build_ext.build_extensions(self, *args, **kwargs)