antlarr / bard

Bard Music Manager - A database to manage your music, find duplicates and fix tags
GNU General Public License v3.0
63 stars 5 forks source link

Lack of documentation, can't build the cpp code #2

Closed cecton closed 3 years ago

cecton commented 6 years ago

I would like to try things out but I didn't succeed to compile the code properly.

Here is what I installed:

apt-get install libboost-python-dev

Then I ran:

python3 setup.py build

And I ended up with:

running build
running build_py
warning: build_py: byte-compiling is disabled, skipping.

running build_ext
building 'bard_ext' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-MLq5fN/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -D_GLIBCXX_PARALLEL -I/usr/include/boost -I/usr/include/python3.5m -c bard/bard_ext.cpp -o build/temp.linux-x86_64-3.5/bard/bard_ext.o -std=gnu++17 -fopenmp -Ofast -march=native -mtune=native -funroll-loops
cc1plus: warning: command line option _-Wstrict-prototypes_ is valid for C/ObjC but not for C++
bard/bard_ext.cpp: In lambda function:
bard/bard_ext.cpp:133:20: error: expected unqualified-id before _[_ token
             auto & [itSongID, itFingerprint] = itSong;
                    ^
bard/bard_ext.cpp:133:20: error: expected initializer before _[_ token
bard/bard_ext.cpp:134:18: error: expected unqualified-id before _[_ token
             auto [offset, similarity] = compareChromaprintFingerprintsAndOffset(itFingerprint, v, cancelThreshold);
                  ^
bard/bard_ext.cpp:135:17: error: _similarity_ was not declared in this scope
             if (similarity > cancelThreshold)
                 ^~~~~~~~~~
bard/bard_ext.cpp:138:57: error: _itSongID_ was not declared in this scope
                 result.append(boost::python::make_tuple(itSongID, offset, similarity));
                                                         ^~~~~~~~
bard/bard_ext.cpp:138:67: error: _offset_ was not declared in this scope
                 result.append(boost::python::make_tuple(itSongID, offset, similarity));
                                                                   ^~~~~~
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

I'm running on Debian on WSL

antlarr commented 6 years ago

Hmm, what gcc version are you using? According to the gcc c++ status page, gcc 7 was the first version to support structured bindings. I know for sure gcc 7.3.x and gcc 8.1.x should work fine .

cecton commented 6 years ago
gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516

Ok thanks! 😖

antlarr commented 6 years ago

I'm sorry but I really want to use modern C++ features since it makes the code much nicer.

I checked and there's a gcc-7 package in sid, so maybe you can try installing just that package from sid?

In any case, thanks for the report!

cecton commented 6 years ago

Yes this is no problem for me, I just really want to try out XD

If you don't mind helping me (I don't know anything about C++).

Now I keep hitting this:

/usr/bin/ld: cannot find -lboost_python-py3

I made a Dockerfile that might be useful to you if you want to let people build it more easily:

#FROM gcc:7
FROM debian:testing

ADD https://raw.githubusercontent.com/guilhem/apt-get-install/master/apt-get-install /usr/bin/
RUN chmod +x /usr/bin/apt-get-install
RUN apt-get-install libboost-python-dev

ADD . /src

RUN apt-get-install python3-setuptools
RUN apt-get-install build-essential
WORKDIR /src
RUN python3 setup.py build

(It's not cleaned as you can see but I'll produce a proper version when I will succeed to build it)

Full output:

Step 9/9 : RUN python3 setup.py build
 ---> Running in c10ffe7bcd75
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/bard
copying bard/config.py -> build/lib.linux-x86_64-3.6/bard
copying bard/ffprobemetadata.py -> build/lib.linux-x86_64-3.6/bard
copying bard/__init__.py -> build/lib.linux-x86_64-3.6/bard
copying bard/terminalcolors.py -> build/lib.linux-x86_64-3.6/bard
copying bard/musicdatabase.py -> build/lib.linux-x86_64-3.6/bard
copying bard/song.py -> build/lib.linux-x86_64-3.6/bard
copying bard/comparesongs.py -> build/lib.linux-x86_64-3.6/bard
copying bard/bard.py -> build/lib.linux-x86_64-3.6/bard
copying bard/utils.py -> build/lib.linux-x86_64-3.6/bard
copying bard/normalizetags.py -> build/lib.linux-x86_64-3.6/bard
copying bard/__main__.py -> build/lib.linux-x86_64-3.6/bard
running build_ext
building 'bard_ext' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/bard
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -D_GLIBCXX_PARALLEL -I/usr/include/boost -I/usr/include/python3.6m -c bard/bard_ext.cpp -o build/temp.linux-x86_64-3.6/bard/bard_ext.o -std=gnu++17 -fopenmp -Ofast -march=native -mtune=native -funroll-loops
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fstack-protector-strong -Wformat
-Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/bard/bard_ext.o -lboost_python-py3 -o build/lib.linux-x86_64-3.6/bard_ext.cpython-36m-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lboost_python-py3
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1
The command '/bin/sh -c python3 setup.py build' returned a non-zero code: 1
antlarr commented 6 years ago

Can you try changing libraries=['boost_python-py3'], to libraries=['boost_python-py36'], in setup.py? (that is, py3 to py36)

antlarr commented 6 years ago

Btw, you need the mpv player if you want to use the "bard play" command. I'm not sure I documented that anywhere (yes, I should add more documentation, but I wanted to focus on the features first, and the blog post gave it more exposure than I expected :) )

cecton commented 6 years ago

Thanks Phoronix for that XD

cecton commented 6 years ago

Success!

Step 7/7 : RUN python3 setup.py build
 ---> Running in e0b375516d7e
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/bard
copying bard/config.py -> build/lib.linux-x86_64-3.6/bard
copying bard/ffprobemetadata.py -> build/lib.linux-x86_64-3.6/bard
copying bard/__init__.py -> build/lib.linux-x86_64-3.6/bard
copying bard/terminalcolors.py -> build/lib.linux-x86_64-3.6/bard
copying bard/musicdatabase.py -> build/lib.linux-x86_64-3.6/bard
copying bard/song.py -> build/lib.linux-x86_64-3.6/bard
copying bard/comparesongs.py -> build/lib.linux-x86_64-3.6/bard
copying bard/bard.py -> build/lib.linux-x86_64-3.6/bard
copying bard/utils.py -> build/lib.linux-x86_64-3.6/bard
copying bard/normalizetags.py -> build/lib.linux-x86_64-3.6/bard
copying bard/__main__.py -> build/lib.linux-x86_64-3.6/bard
running build_ext
building 'bard_ext' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/bard
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -D_GLIBCXX_PARALLEL -I/usr/include/boost -I/usr/include/python3.6m -c bard/bard_ext.cpp -o build/temp.linux-x86_64-3.6/bard/bard_ext.o -std=gnu++17 -fopenmp -Ofast -march=native -mtune=native -funroll-loops
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/bard/bard_ext.o -lboost_python-py36 -o build/lib.linux-x86_64-3.6/bard_ext.cpython-36m-x86_64-linux-gnu.so
running build_scripts
creating build/scripts-3.6
copying and adjusting scripts/bard -> build/scripts-3.6
changing mode of build/scripts-3.6/bard from 644 to 755
Removing intermediate container e0b375516d7e
 ---> 337f54c11afe
Successfully built 337f54c11afe
Successfully tagged bard:latest
antlarr commented 6 years ago

Great! Congrats, you're probably the first person to build Bard (apart from me :) )

Since I actually didn't test a clean installation yet and I don't currently have much time to work on this, I'll give you here an example config file you can put at ~/.config/bard. You can change all paths to something that make sense to you (the database should be created automatically, you shouldn't have to worry about that).

{ 
    "tmpdir": "/tmp/",
    "databasePath": "/home/antonio/.local/share/bard/music.db",
    "musicPaths": [
        "/home/antonio/music",
        "/home/antonio/music2"
    ],
    "translatePaths": false,
    "pathTranslationMap": [],
    "immutableDatabase" : false,
    "username" : "antonio"
}
cecton commented 6 years ago

Thanks! I will need that too.

There are a few dependencies probably missing in the setup.py and also the __main__.py should be this:

# -*- coding: utf-8 -*-

from bard.bard import main # was: from bard import main

main()

Dependencies: pydub, gmpy, numpy, dbus-python (not sure if it should be installed that way...),

cecton commented 6 years ago
FROM debian:testing

ADD https://raw.githubusercontent.com/guilhem/apt-get-install/master/apt-get-install /usr/bin/
RUN chmod +x /usr/bin/apt-get-install
RUN apt-get-install libboost-python-dev python3-setuptools build-essential libchromaprint-dev ca-certificates ffmpeg python3-dbus libgmp-dev
RUN python3 /usr/lib/python3/dist-packages/easy_install.py pyacoustid mutagen Pillow pydub numpy gmpy

ADD . /src
WORKDIR /src

RUN python3 setup.py build

VOLUME /data
VOLUME /music
RUN mkdir -p ~/.config && echo '{"databasePath":"/data/music.db","musicPaths":["/music"]}' > ~/.config/bard

CMD ["python3", "-mbard"]

(not yet finished but better... will finish another day)

antlarr commented 6 years ago

You can install the scripts/bard file to /usr/bin to execute bard nicely, but yes, you're right I should update __main__.py too. Btw, thanks for the list of missing dependencies! I just removed some unused code so gmpy isn't actually needed anymore.

cecton commented 3 years ago

Inactive, closing