gogins / csound-ac

A C++ library for algorithmic composition, designed to be used with Csound, with both C++ and Python interfaces.
GNU Lesser General Public License v2.1
6 stars 0 forks source link

Bring CppSound into CsoundAC #13

Closed gogins closed 8 months ago

gogins commented 11 months ago

Continuous integration builds are failing because the csnd library headers are not found.

gogins commented 11 months ago

The CI build has libcsnd6 as a dylib from Csound, but no header files for it. So maybe just bringing in the headers will do the job.

gogins commented 11 months ago
In file included from /Users/michaelgogins/csound-ac/CsoundAC/CppSound.cpp:25:
/Library/Frameworks/CsoundLib64.framework/Headers/csoundCore.h:860:10: fatal error: 'sort.h' file not found
#include "sort.h"
gogins commented 11 months ago

Had to change compile with args to not use internal files.

gogins commented 11 months ago

Now it's:

dyld[792]: Library not loaded: @rpath/libCsoundAC.7.0.dylib
  Referenced from: <86A3265B-53A6-3E2E-ADB1-E06F2486C10B> /Users/michaelgogins/csound-ac/Parachronic-Piano
  Reason: no LC_RPATH's found

See:

https://discourse.cmake.org/t/how-to-get-an-lc-rpath-and-rpath-prefix-on-a-dylib-on-macos/5540
https://stackoverflow.com/questions/4513799/how-to-set-the-runtime-path-rpath-of-an-executable-with-gcc-under-mac-osx

The CsoundAC library is built with rpath /opt/homebrew/lib but the library is not installed there, rather:

michaelgogins@Michaels-MacBook-Pro ~/csound-ac/build-macos % find / -name "libCsoundAC*.dylib" -ls 2>/dev/null
85351342     2784 -rwxr-xr-x    1 root             wheel             1422344 Nov 21 08:25 /usr/local/lib/libCsoundAC.7.0.dylib
85315381     2672 -rwxr-xr-x    1 root             wheel             1366376 Nov 20 21:00 /usr/local/lib/libCsoundAC.6.0.dylib
85350527        0 lrwxr-xr-x    1 root             wheel                  21 Nov 21 08:22 /usr/local/lib/libCsoundAC.dylib -> libCsoundAC.7.0.dylib
85351342     2784 -rwxr-xr-x    1 root             wheel             1422344 Nov 21 08:25 /System/Volumes/Data/usr/local/lib/libCsoundAC.7.0.dylib
85315381     2672 -rwxr-xr-x    1 root             wheel             1366376 Nov 20 21:00 /System/Volumes/Data/usr/local/lib/libCsoundAC.6.0.dylib
85350527        0 lrwxr-xr-x    1 root             wheel                  21 Nov 21 08:22 /System/Volumes/Data/usr/local/lib/libCsoundAC.dylib -> libCsoundAC.7.0.dylib
20699838     3104 -rwxr-xr-x    1 michaelgogins    staff             1587538 Aug 22  2022 /System/Volumes/Data/Users/michaelgogins/csound-wasm/dependencies/csound-ac/build-macos/libCsoundAC.6.0.dylib
20699840        0 lrwxr-xr-x    1 michaelgogins    staff                  21 Aug 22  2022 /System/Volumes/Data/Users/michaelgogins/csound-wasm/dependencies/csound-ac/build-macos/libCsoundAC.dylib -> libCsoundAC.6.0.dylib
20701250     3104 -rwxr-xr-x    1 root             staff             1587544 Aug 22  2022 /System/Volumes/Data/Users/michaelgogins/csound-wasm/dependencies/csound-ac/build-macos/_CPack_Packages/Darwin/ZIP/csound-ac-0.5.0-Darwin/csound-ac/lib/libCsoundAC.6.0.dylib
20701251        0 lrwxr-xr-x    1 root             staff                  21 Aug 22  2022 /System/Volumes/Data/Users/michaelgogins/csound-wasm/dependencies/csound-ac/build-macos/_CPack_Packages/Darwin/ZIP/csound-ac-0.5.0-Darwin/csound-ac/lib/libCsoundAC.dylib -> libCsoundAC.6.0.dylib
85347457     2784 -rwxr-xr-x    1 michaelgogins    staff             1422344 Nov 21 08:17 /System/Volumes/Data/Users/michaelgogins/csound-ac/build-macos/libCsoundAC.7.0.dylib
85347458        0 lrwxr-xr-x    1 michaelgogins    staff                  21 Nov 21 08:17 /System/Volumes/Data/Users/michaelgogins/csound-ac/build-macos/libCsoundAC.dylib -> libCsoundAC.7.0.dylib
85349068     2784 -rwxr-xr-x    1 root             staff             1422344 Nov 21 08:18 /System/Volumes/Data/Users/michaelgogins/csound-ac/build-macos/_CPack_Packages/Darwin/ZIP/csound-ac-0.5.0-Darwin/csound-ac/lib/libCsoundAC.7.0.dylib
85349069        0 lrwxr-xr-x    1 root             staff                  21 Nov 21 08:18 /System/Volumes/Data/Users/michaelgogins/csound-ac/build-macos/_CPack_Packages/Darwin/ZIP/csound-ac-0.5.0-Darwin/csound-ac/lib/libCsoundAC.dylib -> libCsoundAC.7.0.dylib
20699838     3104 -rwxr-xr-x    1 michaelgogins    staff             1587538 Aug 22  2022 /Users/michaelgogins/csound-wasm/dependencies/csound-ac/build-macos/libCsoundAC.6.0.dylib
20699840        0 lrwxr-xr-x    1 michaelgogins    staff                  21 Aug 22  2022 /Users/michaelgogins/csound-wasm/dependencies/csound-ac/build-macos/libCsoundAC.dylib -> libCsoundAC.6.0.dylib
20701250     3104 -rwxr-xr-x    1 root             staff             1587544 Aug 22  2022 /Users/michaelgogins/csound-wasm/dependencies/csound-ac/build-macos/_CPack_Packages/Darwin/ZIP/csound-ac-0.5.0-Darwin/csound-ac/lib/libCsoundAC.6.0.dylib
20701251        0 lrwxr-xr-x    1 root             staff                  21 Aug 22  2022 /Users/michaelgogins/csound-wasm/dependencies/csound-ac/build-macos/_CPack_Packages/Darwin/ZIP/csound-ac-0.5.0-Darwin/csound-ac/lib/libCsoundAC.dylib -> libCsoundAC.6.0.dylib
85347457     2784 -rwxr-xr-x    1 michaelgogins    staff             1422344 Nov 21 08:17 /Users/michaelgogins/csound-ac/build-macos/libCsoundAC.7.0.dylib
85347458        0 lrwxr-xr-x    1 michaelgogins    staff                  21 Nov 21 08:17 /Users/michaelgogins/csound-ac/build-macos/libCsoundAC.dylib -> libCsoundAC.7.0.dylib
85349068     2784 -rwxr-xr-x    1 root             staff             1422344 Nov 21 08:18 /Users/michaelgogins/csound-ac/build-macos/_CPack_Packages/Darwin/ZIP/csound-ac-0.5.0-Darwin/csound-ac/lib/libCsoundAC.7.0.dylib
85349069        0 lrwxr-xr-x    1 root             staff                  21 Nov 21 08:18 /Users/michaelgogins/csound-ac/build-macos/_CPack_Packages/Darwin/ZIP/csound-ac-0.5.0-Darwin/csound-ac/lib/libCsoundAC.dylib -> libCsoundAC.7.0.dylib
gogins commented 11 months ago

I added an rpath to /usr/local/lib to the macOS build command in playpen.ini.

gogins commented 10 months ago

The Python example runs and completes, but the score ends up empty.

Is it in fact the case that a newly built and installed libCsoundAC is used by Python3? _Yes for Python 3.12, but no for other versions of Python!_

gogins commented 10 months ago

Index 9 (HEIGHT) of Event is always nan and I don't know why. This may the cause of our problems.

gogins commented 10 months ago

Event::setHeight wrongly set the new value to DEPTH. Does fixing that help? That was the bug, now fixed.

gogins commented 10 months ago

One more problem... Visual Studio Code uses Python 3.11, but CsoundAC's Python API installs for Python 3.12.

gogins commented 10 months ago

And another... bwfmetaedit was not installed, but now is (now that there is a brew package for it).

gogins commented 10 months ago

Python version not a problem after all.

gogins commented 8 months ago

I am re-opening this issue because building CsoundAC for Python 3.12 is indeed a problem on macOS. I need to build CsoundAC for Python 3.11 at least on macOS. And I am putting Soundfile support back in for native and Python interfaces.

gogins commented 8 months ago

It depends on what you want to search for.

If you want 3.7.3, use find_package(Python3 3.7.3 EXACT).

If you want version 3.7, regardless of the third digit, you can specify find_package(Python3 3.7 EXACT). In this case, the version 3.7.x, with the greatest value for x, will be founded.

And if you want to search specifically in a directory, set variable Python3_ROOT:

set(Python3_ROOT /ourbuilds/python) find_package(Python3 3.7 EXACT)

gogins commented 8 months ago

Pay close attention to https://cmake.org/cmake/help/latest/module/FindPython.html.

gogins commented 8 months ago

I ran cmake .. --debug-find and CMake quit looking upon finding 3.12.

gogins commented 8 months ago

Replaced 3.12 with 3.13 in CMakeLists.txt. Builds. Loading locally I get:

(lldb) bt
* thread #2, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
  * frame #0: 0x00000001030c937c Python`_PyObject_Malloc + 40
    frame #1: 0x0000000103128d0c Python`unicode_decode_utf8.llvm.13215352099771563103 + 116
    frame #2: 0x0000000101146c60 _CsoundAC.so`::PyInit__CsoundAC() [inlined] SWIG_Python_str_FromChar(c=<unavailable>) at CsoundACPYTHON_wrap.cxx:869:10 [opt]
    frame #3: 0x0000000101146c54 _CsoundAC.so`::PyInit__CsoundAC() [inlined] SWIG_This() at CsoundACPYTHON_wrap.cxx:2434:24 [opt]
    frame #4: 0x0000000101146c48 _CsoundAC.so`::PyInit__CsoundAC() at CsoundACPYTHON_wrap.cxx:107571:3 [opt]
    frame #5: 0x0000000100a80b74 Python`_imp_create_dynamic + 712

This implies SWIG is using the wrong Python library.

gogins commented 8 months ago

I am considering dropping support for the Python interface to CsoundAC. But first, I will try cleaning up my Python installation.

gogins commented 8 months ago

I partly cleaned up the installation by removing python3.11 and re-installing python3.12. I had to use pip3 install --upgrade pip which finally got me pip 23.3.2. I could then install the soundfile package. CsoundAC now builds for python3.12.

gogins commented 8 months ago

New problems. Pyqt5 and llvm use Python 3.9 which is installed but does not remove with brew. And pip treats python3.9 as the default.

gogins commented 8 months ago

Put python3.12 from homebrew first in my PATH and now things build and load using python3.12.

gogins commented 8 months ago

What a nightmare. I truly am spending more time configuration and debugging than composing, all efforts to do otherwise not really working.

I am going to try with pyenv.

gogins commented 8 months ago

This seemed to do something:

michaelgogins@Michaels-MBP ~ % brew pyenv-sync
michaelgogins@Michaels-MBP ~ % pyenv versions                                        
* system (set by /Users/michaelgogins/.pyenv/version)
  3.10.0 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.1 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.2 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.3 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.4 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.5 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.6 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.7 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.8 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.9 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.10 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.11 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.12 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.10.13 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2
  3.12.0 --> /opt/homebrew/Cellar/python@3.12/3.12.1_1
  3.12.1 --> /opt/homebrew/Cellar/python@3.12/3.12.1_1
michaelgogins@Michaels-MBP ~ % 
gogins commented 8 months ago

Created a Python venv and installed the soundfile in it it. Maybe I can now copy that to the real Python's site-packages directory.

gogins commented 8 months ago

Finally! Cloned python-soundfile and: python3.12 setup.py install. The old setup.py approach made an end run around my apparently permanently broken pip.