-
Notifications
You must be signed in to change notification settings - Fork 111
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
Please test the beta release: V0.12.0 #364
Conversation
Rather than trying to create the location for `_soundfile_data/` manually, simply import it and use its reported `__path__` The existing method fails if using py2app because: - starting path is `/lib/python38.zip/soundfile.py` - desired path is `/lib/python3.8/_soundfile_data` - the previous method of stepping back from the starting path never reaches this desired path (it tries `/lib/_soundfile_data` and fails)
The `__path__` is a _Namespacepath object and it's a list of strings not a single string
Adding an empty `__init__.py` to the `_soundfile_data` package means that the __file__ attribute exists so we can do ``` import _soundfile_data _path = os.path.dirname(_soundfile_data.__file__) _full_path = _os.path.join(_path, _packaged_libname) _snd = _ffi.dlopen(_full_path) ```
apparently, multi-OS tags are no longer allowed.
Hrm, I just gave this a spin in a fresh conda environment, and it does not appear to be working. I think it's pulling my libsndfile from the operating system and not the wheel:
|
@bmcfee thank you for testing the library! It seems that soundfile is picking up your system's libsndfile. If you have libsndfile installed on your system, soundfile will always try that first, before trying to load its own. You should see the soundfile-provided libsndfile if you uninstall/mask the system's libsndfile. But you did find a bug regardless, I forgot to update the |
To test it, I added a line after 149 with Lines 149 to 151 in 77444fe
Doing this, it loads the provided libsndfile and the version is 1.2.0
I also tested loading an MP3 with librosa.load() and soundfile.read() and this worked both times.
Imo this should be reversed. Messing with the system installed packages does not seem like a good plan. |
@Barabazs thank you for testing the lib!
I understand and perhaps even agree with that. However, let's discuss this in a separate issue. Please open an issue to collect opinions on the load order. |
Right, that's exactly what's happening. It's maybe worth noting that this does not happen with the conda build, likely because conda environments will prioritize the local env's LD_LIBARARY_PATH above the operating system. This seems sane to me, under the principle of going from most specific to least specific search path, but that's just my take. That said, it's probably a good idea if all distributions of the package were consistent in this behavior (and across platforms - i've only tested linux), just to cut down on the possibility of unpredictable bugs down the road. |
Previously, we tried to load the system libsndfile before trying our own packaged libsndfile, to give users the option to use custom, potentially newer versions of libsndfile. However, this situation has reversed in the last few versions of libsndfile. These introduced some new features and much-needed bug fixes, and soundfile has been updated to provide feature-complete, up-to-date versions of libsndfile on most platforms. Linux package repositories, however, have largely not yet updated to these versions, making it desirable to use our libsndfile over the system-provided ones. Should the system-provided libsndfile be preferred over the bundled libsndfile, one should install the source packages or source wheels (or indeed, a system-provided soundfile).
After thinking about the problem some more, I think I have come around to this point of view as well. We should indeed prioritize our packaged libsndfile over the system-provided one, especially on linux, where the system's libsndfile is likely outdated. (It really doesn't matter much on Windows or macOS, since there's unlikely to be a system libsndfile anyway). As such, I have updated the wheels to first look for the packaged libsndfile, and only fall back to the system libsndfile if the packaged one is unavailable or incompatible. Please do test this again to make sure I didn't break anything in doing so! (The link to the wheels in the initial post of this PR has been updated) |
where the machine was incorrectly identified.
I gave this a spin, and hit some snags. The first problem was my fault - I cloned the repo and switched to this branch without pulling in the submodule for the data files. The build script still ran successfully, but the wheels did not include the .so files and that tripped me up. I didn't see anything about submodules / pull --recurse in the contributing guidelines, so you might want to add a note there. After fixing the submodule, I rebuilt the packages, and it looks like it should work for most platforms, but the linux build is still missing the .so file (obvious from the file sizes, confirmed by checking with unzip):
Contrast with the wheel archive @bastibe posted at the beginning of this PR:
Again, the wheel builds without failure, but now it fails to import:
Looks like the problem is that the _soundfile_data submodule does not actually have the linux_x86_64.so binary, at least not for the version hash used in this branch. Switching the submodule over to the
Summary: I expect most of my problems here are due to my unfamiliarity with the repo structure and build process for this package, but the end result does appear to work as expected. |
Yes, we deliver the binaries in the |
Great, LIS it's probably PEBKAC on my side 😁 But it might not hurt to make the build script a little more sensitive to missing object files if they really need to be there. |
no longer dies with a TypeError if _soundfile_data is empty, but falls back to the system library as it should.
I've added some documentation on the wheel build process, and fixed your TypeError. |
_explicit_libname = 'libsndfile.dylib' | ||
elif _sys.platform == 'win32': | ||
_explicit_libname = 'libsndfile.dll' | ||
elif _sys.plaform == 'linux': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #370, and published as v0.12.1
Dear soundfile community,
Find attached a beta release of the next version of soundfile, with
I would be grateful if you could test the wheels on the platform of your choice, and report back if they work, or if there are any issues.
soundfile-0.12.0.wheels.zip