daniellga / harmonium

Audio analysis and IO
https://daniellga.github.io/harmonium/
MIT License
3 stars 2 forks source link

How to install r-harmonium? #1

Closed sorhawell closed 1 year ago

sorhawell commented 1 year ago

Hi @daniellga

I was trying out your cool project and was building your project with rextendr::document() with dir r-hormonium as workdir. However , I ran into a build error. It appears I have not installed library soxr on my antiquated macbook. See err msg below. How should I install soxr or any other dependencies before?

have a great day :)


✔ Saving changes in the open files.
ℹ Generating extendr wrapper functions for package: harmonium.
ℹ Re-compiling harmonium (debug build)
── R CMD INSTALL ────────────────────────────────────────────────────────────────────────
─  installing *source* package ‘harmonium’ ...
   ** using staged installation
   ** libs
   using C compiler: ‘Apple clang version 14.0.0 (clang-1400.0.29.202)’
   using SDK: ‘’
   rm -Rf harmonium.so ./rust/target/release/libharmonium.a entrypoint.o
   clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include    -fPIC  -falign-functions=64 -Wall -g -O2  -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c entrypoint.c -o entrypoint.o
   # In some environments, ~/.cargo/bin might not be included in PATH, so we need
   # to set it here to ensure cargo can be invoked. It is appended to PATH and
   # therefore is only used if cargo is absent from the user's PATH.
   if [ "true" != "true" ]; then \
        export CARGO_HOME=/Users/sorenwelling/Documents/projs/harmonium/r-harmonium/src/.cargo; \
    fi && \
        export PATH="/usr/local/Cellar/python@3.9/3.9.16/libexec/bin:/usr/local/opt/python@3.10/libexec/bin:/usr/local/opt/python@3.9/libexec/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sorenwelling/.cargo/bin/:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/Users/sorenwelling/.cargo/bin:/usr/ucb:/Users/sorenwelling/Applications/quarto/bin:/usr/texbin:/Applications/RStudio.app/Contents/Resources/app/quarto/bin:/Applications/RStudio.app/Contents/Resources/app/bin/postback:/Users/sorenwelling/.cargo/bin" && \
        cargo build --lib --release --manifest-path=./rust/Cargo.toml --target-dir ./rust/target
       Updating crates.io index
       Updating git repository `https://github.com/extendr/extendr`
       Updating git repository `https://github.com/RustAudio/rodio.git`
      Compiling proc-macro2 v1.0.58
      Compiling quote v1.0.27
      Compiling unicode-ident v1.0.9
      Compiling autocfg v1.1.0
      Compiling cfg-if v1.0.0
      Compiling syn v1.0.109
      Compiling log v0.4.17
      Compiling libc v0.2.144
      Compiling bitflags v1.3.2
      Compiling lazy_static v1.4.0
      Compiling memchr v2.5.0
      Compiling glob v0.3.1
      Compiling arrayvec v0.7.2
      Compiling num-traits v0.2.15
      Compiling num-integer v0.1.45
      Compiling clang-sys v1.6.1
      Compiling minimal-lexical v0.2.1
      Compiling version_check v0.9.4
      Compiling libloading v0.7.4
      Compiling nom v7.1.3
      Compiling encoding_rs v0.8.32
      Compiling bindgen v0.64.0
      Compiling regex-syntax v0.7.2
      Compiling lock_api v0.4.9
      Compiling syn v2.0.16
      Compiling parking_lot_core v0.9.7
      Compiling peeking_take_while v0.1.2
      Compiling shlex v1.1.0
      Compiling lazycell v1.3.0
      Compiling rustc-hash v1.1.0
      Compiling scopeguard v1.1.0
      Compiling semver v1.0.17
      Compiling smallvec v1.10.0
      Compiling core-foundation-sys v0.6.2
      Compiling signal-hook v0.3.15
      Compiling cexpr v0.6.0
      Compiling parking_lot v0.12.1
      Compiling regex v1.8.2
      Compiling num-complex v0.4.3
      Compiling rustfft v6.1.0
      Compiling signal-hook-registry v1.4.1
      Compiling rustversion v1.0.12
      Compiling strength_reduce v0.2.4
      Compiling transpose v0.2.2
      Compiling rustc_version v0.4.0
      Compiling primal-check v0.3.3
      Compiling ahash v0.8.3
      Compiling mio v0.8.6
      Compiling matrixmultiply v0.3.7
      Compiling once_cell v1.17.1
      Compiling cpal v0.15.2
      Compiling signal-hook-mio v0.2.3
      Compiling arrow2 v0.17.1
      Compiling mach2 v0.4.1
      Compiling getrandom v0.2.9
      Compiling bytemuck_derive v1.4.1
      Compiling futures-core v0.3.28
      Compiling heck v0.4.1
      Compiling core-foundation-sys v0.8.4
      Compiling dasp_sample v0.11.0
      Compiling rawpointer v0.2.1
      Compiling crossterm v0.25.0
      Compiling chrono v0.4.24
      Compiling bytemuck v1.13.1
      Compiling symphonia-core v0.5.2
      Compiling simdutf8 v0.1.4
      Compiling strum_macros v0.24.3
      Compiling either v1.8.1
      Compiling hash_hasher v2.0.3
      Compiling strum v0.24.1
      Compiling symphonia-metadata v0.5.2
      Compiling symphonia-utils-xiph v0.5.2
      Compiling symphonia-format-mkv v0.5.2
      Compiling symphonia-bundle-flac v0.5.2
      Compiling symphonia-codec-vorbis v0.5.2
      Compiling symphonia-format-ogg v0.5.2
      Compiling symphonia-format-wav v0.5.2
      Compiling symphonia-codec-adpcm v0.5.2
      Compiling symphonia-codec-pcm v0.5.2
      Compiling foreign_vec v0.1.0
      Compiling strsim v0.10.0
      Compiling ident_case v1.0.1
      Compiling libR-sys v0.4.0
      Compiling unicode-width v0.1.10
      Compiling ethnum v1.3.2
      Compiling dyn-clone v1.0.11
      Compiling fnv v1.0.7
      Compiling futures-task v0.3.28
      Compiling darling_core v0.14.4
      Compiling comfy-table v6.1.4
      Compiling symphonia v0.5.2
      Compiling ndarray v0.15.6
      Compiling futures-util v0.3.28
      Compiling futures-channel v0.3.28
      Compiling coreaudio-sys v0.2.12
      Compiling futures-sink v0.3.28
      Compiling pin-project-lite v0.2.9
      Compiling pkg-config v0.3.27
      Compiling realfft v3.2.0
      Compiling libsoxr-sys v0.1.4
      Compiling rubato v0.12.0
      Compiling tokio v1.28.1
      Compiling pin-utils v0.1.0
      Compiling async-trait v0.1.68
      Compiling thiserror v1.0.40
      Compiling darling_macro v0.14.4
      Compiling darling v0.14.4
      Compiling tokio-macros v2.1.0
      Compiling thiserror-impl v1.0.40
   error: failed to run custom build command for `libsoxr-sys v0.1.4`

   Caused by:
     process didn't exit successfully: `/Users/sorenwelling/Documents/projs/harmonium/r-harmonium/src/./rust/target/release/build/libsoxr-sys-58fccd8037b6ba39/build-script-build` (exit status: 101)
     --- stdout
     cargo:rerun-if-env-changed=SOXR_NO_PKG_CONFIG
     cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-apple-darwin
     cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_apple_darwin
     cargo:rerun-if-env-changed=HOST_PKG_CONFIG
     cargo:rerun-if-env-changed=PKG_CONFIG
     cargo:rerun-if-env-changed=SOXR_STATIC
     cargo:rerun-if-env-changed=SOXR_DYNAMIC
     cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
     cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
     cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-apple-darwin
     cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
     cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
     cargo:rerun-if-env-changed=PKG_CONFIG_PATH
     cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-apple-darwin
     cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
     cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
     cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
     cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-apple-darwin
     cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
     cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
     cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

     --- stderr
     thread 'main' panicked at '`PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "soxr"` did not exit successfully: exit status: 1
     error: could not find system library 'soxr' required by the 'libsoxr-sys' crate

     --- stderr
     Package soxr was not found in the pkg-config search path.
     Perhaps you should add the directory containing `soxr.pc'
     to the PKG_CONFIG_PATH environment variable
     No package 'soxr' found
     ', /Users/sorenwelling/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libsoxr-sys-0.1.4/build.rs:15:18
     note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
   warning: build failed, waiting for other jobs to finish...
   make: *** [rust/target/release/libharmonium.a] Error 101
   ERROR: compilation failed for package ‘harmonium’
─  removing ‘/private/var/folders/v1/b2c26lpn2yjd997jg_gn4fgc0000gn/T/RtmpMFYAvn/devtools_install_62a166beb3bb/harmonium’
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'R' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Type .Last.error to see the more details.
´´´
daniellga commented 1 year ago

This is a dependency I was supposed to remove from Cargo.toml, sorry about that. As far as I remember, that was the only dependency I needed to manually install. Would you mind trying again? I am waiting for some fixes on libsoxr crate before considering to reuse it.

sorhawell commented 1 year ago

I remove -lasound from Makevars and then it could compile and pass all tests :)

> rextendr::document()
✔ Saving changes in the open files.
ℹ Generating extendr wrapper functions for package: harmonium.
ℹ Re-compiling harmonium (debug build)
── R CMD INSTALL ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─  installing *source* package ‘harmonium’ ...
   ** using staged installation
   ** libs
   using C compiler: ‘Apple clang version 14.0.0 (clang-1400.0.29.202)’
   using SDK: ‘’
   rm -Rf harmonium.so ./rust/target/release/libharmonium.a entrypoint.o
   clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include    -fPIC  -falign-functions=64 -Wall -g -O2  -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c entrypoint.c -o entrypoint.o
   # In some environments, ~/.cargo/bin might not be included in PATH, so we need
   # to set it here to ensure cargo can be invoked. It is appended to PATH and
   # therefore is only used if cargo is absent from the user's PATH.
   if [ "true" != "true" ]; then \
        export CARGO_HOME=/Users/sorenwelling/Documents/projs/harmonium/r-harmonium/src/.cargo; \
    fi && \
        export PATH="/usr/local/Cellar/python@3.9/3.9.16/libexec/bin:/usr/local/opt/python@3.10/libexec/bin:/usr/local/opt/python@3.9/libexec/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sorenwelling/.cargo/bin/:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/Users/sorenwelling/.cargo/bin:/usr/ucb:/Users/sorenwelling/Applications/quarto/bin:/usr/texbin:/Applications/RStudio.app/Contents/Resources/app/quarto/bin:/Applications/RStudio.app/Contents/Resources/app/bin/postback:/Users/sorenwelling/.cargo/bin" && \
        cargo build --lib --release --manifest-path=./rust/Cargo.toml --target-dir ./rust/target
   warning: function `main` is never used
    --> src/generate_r_docs.rs:6:4
     |
   6 | fn main() {
     |    ^^^^
     |
     = note: `#[warn(dead_code)]` on by default

   warning: function `generate_r_docs` is never used
     --> src/generate_r_docs.rs:33:4
      |
   33 | fn generate_r_docs(files: Vec<&str>, github_folder: &str, hash: &mut HashMap<String, Vec<String>>) {
      |    ^^^^^^^^^^^^^^^

   warning: function `output_file` is never used
      --> src/generate_r_docs.rs:123:4
       |
   123 | fn output_file(hash: HashMap<String, Vec<String>>, output_path: PathBuf) {
       |    ^^^^^^^^^^^

   warning: `r-harmonium` (lib) generated 3 warnings
       Finished release [optimized] target(s) in 0.27s
   if [ "true" != "true" ]; then \
        rm -Rf /Users/sorenwelling/Documents/projs/harmonium/r-harmonium/src/.cargo && \
        rm -Rf ./rust/target/release/build; \
    fi
   clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -o harmonium.so entrypoint.o -L./rust/target/release -lharmonium -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
   ld: warning: -undefined dynamic_lookup may not work with chained fixups
   installing to /private/var/folders/v1/b2c26lpn2yjd997jg_gn4fgc0000gn/T/RtmpkgG4G7/devtools_install_b4686f5a7fe7/00LOCK-r-harmonium/00new/harmonium/libs
   ** checking absolute paths in shared objects and dynamic libraries
─  DONE (harmonium)
✔ Writing 'R/extendr-wrappers.R'
ℹ Updating harmonium documentation
Setting `RoxygenNote` to "7.2.3"
ℹ Loading harmonium
harmonium 0.1.0, see harmonium::hdocs() for documentation.
Deleting hconfig.Rd, print.HArray.Rd, print.HAudio.Rd, print.HDataType.Rd, print.HMatrix.Rd, print.HMetadataType.Rd, print.HResampler.Rd, and print.HResamplerType.Rd
Warning messages:
1: Skipping NAMESPACE
✖ It already exists and was not generated by roxygen2. 
2: Skipping NAMESPACE
✖ It already exists and was not generated by roxygen2. 
> devtools::test()
ℹ Testing harmonium
harmonium 0.1.0, see harmonium::hdocs() for documentation.
✔ | F W S  OK | Context
✔ |         8 | arrow_conversions [1.1s]                                                                                                                                                                               
✔ |         8 | as_mono [0.4s]                                                                                                                                                                                         
✔ |         6 | conversions                                                                                                                                                                                            
✔ |        11 | export                                                                                                                                                                                                 
✔ |        40 | harray [0.2s]                                                                                                                                                                                          
⠦ |        17 | haudio                                                                                                                                                                                                 thread '<unnamed>' panicked at 'cannot represent audio with complex data', src/hmatrix.rs:910:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'cannot represent audio with complex data', src/hmatrix.rs:988:9
✔ |        26 | haudio [0.1s]
✔ |        18 | haudiosink [0.5s]                                                                                                                                                                                      
⠏ |         0 | hconfig                                                                                                                                                                                                thread '<unnamed>' panicked at '"fmt" must be one of ["full", "mixed"].', src/hconfig.rs:9:14
✔ |        20 | hconfig [0.1s]                                                                                                                                                                                         
✔ |         5 | hfile                                                                                                                                                                                                  
✔ |        48 | hmatrix [0.2s]                                                                                                                                                                                         
⠏ |         0 | hresampler                                                                                                                                                                                             thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/hresampler.rs:386:1
✔ |         5 | hresampler
✔ |        12 | mean_cols [0.3s]                                                                                                                                                                                       
✔ |        40 | slice [0.2s]                                                                                                                                                                                           

══ Results ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Duration: 3.9 s

[ FAIL 0 | WARN 0 | SKIP 0 | PASS 247 ]
daniellga commented 1 year ago

-lasound is needed only for linux afaik... Are you on mac? If so, I will need to do some research on how to add lasound only for linux, excluding mac...

sorhawell commented 1 year ago

Yes I have an old MacBook :)

daniellga commented 1 year ago

after fighting makevars file for a long time, now all CIs are passing for macos as well so I am closing this.