pysodium icon indicating copy to clipboard operation
pysodium copied to clipboard

Even if libsdoium is installed, the storage location of libsodium cannot be obtained

Open TakumiHoriguchi opened this issue 1 year ago • 13 comments

Hello, I am developing using Mac and Debian.(macOS sonoma 14.5) I installed libsodium, but the search for the line below doesn't work well, and the error message on line 35 is returned. libsodium is installed using the following method on mac brew install libsodium In debian apt-get apt-get install -y libsodium-dev

On Mac, it works if you hardcode the path on line 33. You can't do that with debian.

https://github.com/stef/pysodium/blob/baf11790a6bd454441393b5377bad7cc591089ae/pysodium/init.py#L33

If you have any problems with my usage, please teach me the steps. thank you.

Thanks for the amazing work so far ! (This is an automatic translation)

TakumiHoriguchi avatar Oct 21 '24 09:10 TakumiHoriguchi

sorry for the late answer, another project took all my attention. what do you mean with hard-coding the path in line 33? what would be that path? i have no access to macs, help me out by debugging this for me and figuring out a reliable way to support macs as well. thank you very much!

stef avatar Nov 10 '24 02:11 stef

googled a bit, it seems that brew doesn't install libraries in any of /usr/lib lor /usr/local/lib but somewhat random locations instead. i don't really know how to guess these correctly, i think it is better to just make a symlink to libsodium into either /usr/lib or /usr/local/lib, it will be picked up there correctly. why brew does this, i dunno, maybe open a ticket with brew to fix this?

stef avatar Nov 10 '24 02:11 stef

pkg-config --libs libsodium and pkg-config --cflags libsodium work no matter where the library is installed as long as the tool itself is in the PATH. Which is the case with Brew.

jedisct1 avatar Nov 10 '24 15:11 jedisct1

oh, so you say i get the path using os.system('pkg-config --libs') instead of find_library, hmm, that could work, not nice, but it sounds workable..

stef avatar Nov 10 '24 17:11 stef

~~I'm not very familiar at all with cmake, but looks like it has FindPkgConfig to do that: https://stackoverflow.com/questions/29191855/what-is-the-proper-way-to-use-pkg-config-from-cmake~~

Scratch that, this is not using cmake :)

jedisct1 avatar Nov 10 '24 17:11 jedisct1

not sure we are talking about the same thing. this is about python ctypes.find_library not finding libsodium, has nothing to do with cmake.

stef avatar Nov 10 '24 17:11 stef

sorry for the late answer, another project took all my attention. what do you mean with hard-coding the path in line 33? what would be that path? i have no access to macs, help me out by debugging this for me and figuring out a reliable way to support macs as well. thank you very much!

Thank you for your reply. Sorry for the late reply. It's because of the time difference.

The hardcoded path is below. /opt/homebrew/Cellar/libsodium/1.0.20/lib/libsodium.dylib

I also tried moving libsodium, which was installed with brew, to usr/lib, but the result was the same.

TakumiHoriguchi avatar Nov 11 '24 01:11 TakumiHoriguchi

hmm, pkg-config -l doesn't work it only gives me the linker flags, like -lsodium not a path.

stef avatar Nov 11 '24 14:11 stef

it's not very convenient to have also the version in the path /opt/homebrew/Cellar/libsodium/1.0.20/lib/libsodium.dylib this makes it extra painful to find the library.

stef avatar Nov 11 '24 15:11 stef

according to the wisdom of mastodon, you should:

contact the maintainer of the brew libsodium install script. They need to add a link to /opt/homebrew/lib/ for Apple Silicon. Intel brew probably puts it in /usr/local/lib.

the install script should put a link to the lib into /usr/local/lib then it will be picked up perfectly by ctypes and pysodium.

stef avatar Nov 11 '24 18:11 stef

btw is there no link in /opt/homebrew/lib to libsodium?

stef avatar Nov 11 '24 19:11 stef

the dear people at cynthion had a similar issue, and the solution is to use brew python which nows how to find other brew stuff: https://github.com/greatscottgadgets/cynthion/issues/136

stef avatar Nov 11 '24 19:11 stef

this is also an interesting comment: https://apple.stackexchange.com/questions/437618/why-is-homebrew-installed-in-opt-homebrew-on-apple-silicon-macs/437622#437622

stef avatar Nov 11 '24 21:11 stef