Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring CppSound into CsoundAC #13

Closed
9 of 13 tasks
gogins opened this issue Nov 20, 2023 · 24 comments
Closed
9 of 13 tasks

Bring CppSound into CsoundAC #13

gogins opened this issue Nov 20, 2023 · 24 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Comments

@gogins
Copy link
Owner

gogins commented Nov 20, 2023

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

  • Bring in all necessary files into the CsoundAC source directory.
  • Remove libcsnd libraries and #includes from CMakeLists.txt.
  • Add new files to CMakeLists.txt.
  • Replace CppSound with CxxSound throughout filenames and code. Use Cxx preface rather than a new namespace?
  • Remove any unnecessary files and references.
  • Build locally.
  • Test piece for C++.
  • Test piece for Lua. No, I will deprecate Lua support.
  • Test piece for Python.
  • Install in cloud-5 and test there.
  • Build on GitHub.
  • Update documentation.
  • Release.
@gogins gogins added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Nov 20, 2023
@gogins gogins self-assigned this Nov 20, 2023
@gogins
Copy link
Owner Author

gogins commented Nov 21, 2023

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 added a commit that referenced this issue Nov 21, 2023
Try adding header for non-dev libcsnd6 (#13).
@gogins
Copy link
Owner Author

gogins commented Nov 21, 2023

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
Copy link
Owner Author

gogins commented Nov 21, 2023

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

@gogins
Copy link
Owner Author

gogins commented Nov 21, 2023

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 added a commit that referenced this issue Nov 21, 2023
gogins added a commit that referenced this issue Nov 21, 2023
gogins added a commit that referenced this issue Nov 21, 2023
@gogins
Copy link
Owner Author

gogins commented Nov 21, 2023

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

@gogins
Copy link
Owner Author

gogins commented Nov 24, 2023

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
Copy link
Owner Author

gogins commented Nov 24, 2023

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

@gogins
Copy link
Owner Author

gogins commented Nov 24, 2023

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

@gogins
Copy link
Owner Author

gogins commented Nov 24, 2023

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

@gogins
Copy link
Owner Author

gogins commented Nov 24, 2023

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

gogins added a commit that referenced this issue Nov 24, 2023
@gogins
Copy link
Owner Author

gogins commented Nov 24, 2023

Python version not a problem after all.

@gogins gogins closed this as completed Nov 24, 2023
@gogins gogins reopened this Jan 28, 2024
@gogins
Copy link
Owner Author

gogins commented Jan 28, 2024

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
Copy link
Owner Author

gogins commented Jan 29, 2024

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
Copy link
Owner Author

gogins commented Jan 29, 2024

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

@gogins
Copy link
Owner Author

gogins commented Jan 29, 2024

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

@gogins
Copy link
Owner Author

gogins commented Jan 29, 2024

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
Copy link
Owner Author

gogins commented Jan 29, 2024

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

@gogins
Copy link
Owner Author

gogins commented Jan 29, 2024

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
Copy link
Owner Author

gogins commented Jan 29, 2024

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
Copy link
Owner Author

gogins commented Jan 29, 2024

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

@gogins
Copy link
Owner Author

gogins commented Jan 30, 2024

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
Copy link
Owner Author

gogins commented Jan 30, 2024

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
Copy link
Owner Author

gogins commented Jan 30, 2024

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
Copy link
Owner Author

gogins commented Jan 30, 2024

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.

@gogins gogins closed this as completed Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant