Yikai-Liao / symusic

A cross platform note level midi decoding library with lightening speed, based on minimidi.
https://yikai-liao.github.io/symusic/
MIT License
108 stars 8 forks source link

nanobind problem #41

Closed wysstartgo closed 1 month ago

wysstartgo commented 1 month ago

when I run pip install symusic,the error occurs:

     In file included from /tmp/pip-install-j269we9w/symusic_fde26dadb687464ba7ae39e41005e3da/py_src/core.cpp:10:
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:431:5: note: candidate: ‘nanobind::ndarray<Args>::ndarray(nanobind::ndarray<Args>&&) [with Args = {nanobind::numpy, unsigned char}]’
        431 |     ndarray(ndarray &&t) noexcept : m_handle(t.m_handle), m_dltensor(t.m_dltensor) {
            |     ^~~~~~~
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:431:5: note:   candidate expects 1 argument, 2 provided
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:427:5: note: candidate: ‘nanobind::ndarray<Args>::ndarray(const nanobind::ndarray<Args>&) [with Args = {nanobind::numpy, unsigned char}]’
        427 |     ndarray(const ndarray &t) : m_handle(t.m_handle), m_dltensor(t.m_dltensor) {
            |     ^~~~~~~
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:427:5: note:   candidate expects 1 argument, 2 provided
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:404:5: note: candidate: ‘nanobind::ndarray<Args>::ndarray(std::conditional_t<is_const_v<typename nanobind::detail::ndarray_info<Ts ...>::scalar_type>, const void*, void*>, std::initializer_list<long unsigned int>, nanobind::handle, std::initializer_list<long int>, nanobind::dlpack::dtype, int32_t, int32_t) [with Args = {nanobind::numpy, unsigned char}; std::conditional_t<is_const_v<typename nanobind::detail::ndarray_info<Ts ...>::scalar_type>, const void*, void*> = void*; typename nanobind::detail::ndarray_info<Ts ...>::scalar_type = unsigned char; int32_t = int]’
        404 |     ndarray(std::conditional_t<std::is_const_v<Scalar>, const void *, void *> data,
            |     ^~~~~~~
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:404:5: note:   candidate expects 7 arguments, 2 provided
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:390:5: note: candidate: ‘nanobind::ndarray<Args>::ndarray(std::conditional_t<is_const_v<typename nanobind::detail::ndarray_info<Ts ...>::scalar_type>, const void*, void*>, size_t, const size_t*, nanobind::handle, const int64_t*, nanobind::dlpack::dtype, int32_t, int32_t) [with Args = {nanobind::numpy, unsigned char}; std::conditional_t<is_const_v<typename nanobind::detail::ndarray_info<Ts ...>::scalar_type>, const void*, void*> = void*; typename nanobind::detail::ndarray_info<Ts ...>::scalar_type = unsigned char; size_t = long unsigned int; int64_t = long int; int32_t = int]’
        390 |     ndarray(std::conditional_t<std::is_const_v<Scalar>, const void *, void *> data,
            |     ^~~~~~~
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:390:5: note:   candidate expects 8 arguments, 2 provided
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:388:14: note: candidate: ‘template<class ... Args2> nanobind::ndarray<Args>::ndarray(const nanobind::ndarray<Args2 ...>&) [with Args2 = {Args2 ...}; Args = {nanobind::numpy, unsigned char}]’
        388 |     explicit ndarray(const ndarray<Args2...> &other) : ndarray(other.m_handle) { }
            |              ^~~~~~~
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:388:14: note:   template argument deduction/substitution failed:
      /tmp/pip-install-j269we9w/symusic_fde26dadb687464ba7ae39e41005e3da/py_src/core.cpp:801:24: note:   mismatched types ‘const nanobind::ndarray<Args ...>’ and ‘uint8_t*’ {aka ‘unsigned char*’}
        801 |             return py::ndarray<py::numpy, pianoroll_t>{const_cast<uint8_t*>(pianoroll.release()),
            |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        802 |                 { std::get<0>(pianoroll.dims()),
            |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        803 |                     std::get<1>(pianoroll.dims()),
            |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        804 |                     std::get<2>(pianoroll.dims()),
            |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        805 |                     std::get<3>(pianoroll.dims()) }
            |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        806 |             };
            |             ~
      In file included from /tmp/pip-install-j269we9w/symusic_fde26dadb687464ba7ae39e41005e3da/py_src/core.cpp:10:
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:382:14: note: candidate: ‘nanobind::ndarray<Args>::ndarray(nanobind::detail::ndarray_handle*) [with Args = {nanobind::numpy, unsigned char}]’
        382 |     explicit ndarray(detail::ndarray_handle *handle) : m_handle(handle) {
            |              ^~~~~~~
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:382:14: note:   candidate expects 1 argument, 2 provided
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:380:5: note: candidate: ‘constexpr nanobind::ndarray<Args>::ndarray() [with Args = {nanobind::numpy, unsigned char}]’
        380 |     ndarray() = default;
            |     ^~~~~~~
      /mnt/ai_workspace/ComfyUI/venv_comfyui310/lib/python3.10/site-packages/nanobind/include/nanobind/ndarray.h:380:5: note:   candidate expects 0 arguments, 2 provided
      ninja: build stopped: subcommand failed.

      *** CMake build failed
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for symusic
Failed to build symusic
ERROR: Could not build wheels for symusic, which is required to install pyproject.toml-based projects

I checked the nanobind,it is 2.0.0

Yikai-Liao commented 1 month ago

In the latest version, I have fixed nanobind to 1.9.2. #40

I don't know why pip doesn't solve this dependency correctly. Maybe you need to manually install the correct version of nanobind.

[build-system]
requires = [
    "setuptools>=42",
    "scikit-build>=0.13",
    "scikit-build-core>=0.3.3",
    "nanobind==v1.9.2",
    "cmake>=3.20",
    "ninja",
]
Yikai-Liao commented 1 month ago

Sorry, the 0.4.8 is not uploaded to pypi correctly.

Yikai-Liao commented 1 month ago

All the pre-compiled files of 0.4.8 have been uploaded to pypi manually.

wysstartgo commented 1 month ago

when I use pip install symusic==0.4.8,the error below occurs:

/tmp/pip-install-kti1b0xx/symusic_2329d688018f47829fa1210f09dfd269/3rdparty/zpp_bits/zpp_bits.h:2400:41:   required from ‘constexpr auto zpp::bits::out<ByteView, Options>::operator()(auto:143&& ...) [with auto:143 = {const std::vector<symusic::Note<symusic::Tick>, std::allocator<symusic::Note<symusic::Tick> > >&}; ByteView = std::vector<unsigned char, std::allocator<unsigned char> >; Options = {}]’
      /tmp/pip-install-kti1b0xx/symusic_2329d688018f47829fa1210f09dfd269/src/io/zpp.cpp:85:8:   required from ‘symusic::vec<unsigned char> symusic::details::serailize_zpp(const T&) [with T = std::vector<symusic::Note<symusic::Tick>, std::allocator<symusic::Note<symusic::Tick> > >; symusic::vec<unsigned char> = std::vector<unsigned char, std::allocator<unsigned char> >]’
      /tmp/pip-install-kti1b0xx/symusic_2329d688018f47829fa1210f09dfd269/src/io/zpp.cpp:130:1:   required from here
      /tmp/pip-install-kti1b0xx/symusic_2329d688018f47829fa1210f09dfd269/3rdparty/zpp_bits/zpp_bits.h:80:30: error: ‘__builtin_bit_cast’ was not declared in this scope; did you mean ‘__builtin_strcat’?
         80 |     return __builtin_bit_cast(ToType, from);
            |            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
            |            __builtin_strcat
      [71/76] Building CXX object 3rdparty/prestosynth/CMakeFiles/prestosynth.dir/src/soundfont_internal.cpp.o
      [72/76] Building CXX object CMakeFiles/symusic.dir/src/io/midi.cpp.o
      [73/76] Building CXX object CMakeFiles/core.dir/py_src/core.cpp.o
      ninja: build stopped: subcommand failed.

      *** CMake build failed
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for symusic
Failed to build symusic
ERROR: Could not build wheels for symusic, which is required to install pyproject.toml-based projects
wysstartgo commented 1 month ago

Can you provide the version about GCC and G++?

Yikai-Liao commented 1 month ago

@wysstartgo You can refer here: https://github.com/Natooz/MidiTok/issues/155#issuecomment-2027122797

The zpp_bits library requires a newer compiler to support some of the features in the c++20 standard. However, because of its better performance, I chose to use it for pickle support.

wysstartgo commented 1 month ago

Solved by https://github.com/Natooz/MidiTok/issues/155#issuecomment-2027122797