kylebgorman / pynini

Read-only mirror of Pynini
http://pynini.opengrm.org
Apache License 2.0
118 stars 27 forks source link

Cannot install via pip on macos 12.4 (Monteray) - 'shared_mutex' is unavailable #54

Closed david-waterworth closed 9 months ago

david-waterworth commented 2 years ago

I'm getting the error message

/usr/local/include/fst/lock.h:50:8: error: 'shared_mutex' is unavailable: introduced in maxOS 10.12

When running

pip install pynini

I think this is because the minimum target is set to 10.7 (hence an error for any api added > 10.7) i.e. looking back through the long I can see the compiler command clang ... -mmacosx-version-min=10.7

I'm not sure if I've installed the wrong version of OpenFst (I downloaded the latest) or is there any way of overriding the compiler flags when pip builds the wheel?

kylebgorman commented 2 years ago

Installation from source, particularly on MacOS, is basically unsupported. I don’t own a suite of Macs of various vintages so I have no way to test it.

As I hope is clear from pynini.opengrm.org the one installation method that is more or less guaranteed to work on MacOS is via conda-forge. They give me access (indirectly) to MacOS cloud-based CI which is used to build binaries that just work and install in seconds.

The only other convenient option would be for someone to invent something like manylinux wheels for MacOS. If someone invents that, I’ll use it to deliver PyPI MacOS wheels like I do for Linux.

I have no way to be certain but I don’t think the minimum version flag is at issue: MacOS just had poor C++ 11 and 17 support until quite recently, and I doubt the min version is strictly interpreted as the max version too. You’re welcome to play around with it though.

You of course need the absolutely most recent version of OpenFst to build against. Each release of Pynini is (notionally) pinned to an OpenFst release and won’t work with any other.

On Fri, Jul 15, 2022 at 5:45 AM David Waterworth @.***> wrote:

I'm getting the error message

/usr/local/include/fst/lock.h:50:8: error: 'shared_mutex' is unavailable: introduced in maxOS 10.12

When running

pip install pynini

I think this is because the minimum target is set to 10.7 (hence an error for any api added > 10.7) i.e. looking back through the long I can see the compiler command clang ... -mmacosx-version-min=10.7

I'm not sure if I've installed the wrong version of OpenFst (I downloaded the latest) or is there any way of overriding the compiler flags when pip builds the wheel?

— Reply to this email directly, view it on GitHub https://github.com/kylebgorman/pynini/issues/54, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABG4OPIHZ7S7XMOCVRZYLLVUEXMTANCNFSM53VAZS3A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

david-waterworth commented 2 years ago

Thanks @kylebgorman - I'll try conda-forge. I'm just playing around on my laptop so it's not a big deal. I normally work on Ubuntu and that seemed to install ok (I have an issue that I'll post later if I cannot figure it out myself)

kylebgorman commented 2 years ago

Yeah, if you install directly from Pip on x86_64 Ubuntu it'll use the manylinux wheel. Sadly there's nothing equivalent on MacOS.

(On conda there are arm64, aka Apple Silicon, binaries too.)

On Fri, Jul 15, 2022 at 8:17 AM David Waterworth @.***> wrote:

Thanks @kylebgorman https://github.com/kylebgorman - I'll try conda-forge. I'm just playing around on my laptop so it's not a big deal. I normally work on Ubuntu and that seemed to install ok (I have an issue that I'll post later if I cannot figure it out myself)

— Reply to this email directly, view it on GitHub https://github.com/kylebgorman/pynini/issues/54#issuecomment-1185488074, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABG4OLZLZYFVPEHITDZ4ELVUFJETANCNFSM53VAZS3A . You are receiving this because you were mentioned.Message ID: @.***>

kylebgorman commented 2 years ago

Closing. Not sure what I can do about this.

david-waterworth commented 2 years ago

PS this (and a few other similar discussions) are why I concluded that pip is setting the target to less than 10.12 when it builds from source

But I understand that there's not much you can do. If I have time I'll look closer and if I find anything useful I'll re-open.

It may be as simple as changing the code below in setup.py

if sys.platform.startswith("darwin"):
  COMPILE_ARGS.append("-stdlib=libc++")
  COMPILE_ARGS.append("-mmacosx-version-min=10.7")
david-waterworth commented 2 years ago

OK I can confirm that the changing setup.py from the above to

if sys.platform.startswith("darwin"):
  COMPILE_ARGS.append("-stdlib=libc++")
  COMPILE_ARGS.append("-mmacosx-version-min=10.12")

Allows me to build from source. I did the following

As long as the macosx-version-min is set >=10.12 it built and the tests passed (loads of C++ warnings but that's to be expected)

kylebgorman commented 2 years ago

Does anyone care about support for MacOS < 10.12? 10.11 ("El Capitan") is quite old in my book but I have no idea.

effendijohanes commented 2 years ago

Thank you very much @david-waterworth , I got the same error and it solves my problem! I'm on MacOS Catalina.

kylebgorman commented 1 year ago

@effendijohanes @david-waterworth could you weigh in on whether support for El Capitan (10.11) and earlier is desirable in your opinion? This fix requires that I de-list them and I'm trying to decide if I should do it or not in the next release.

david-waterworth commented 1 year ago

It's quite old and as far as I'm aware no longer supported by Apple. I think it's reasonable to no longer support it, I certainly don't need support for 10.11

lextoumbourou commented 1 year ago

El Captain was released in 2015 and was succeeded by Sierra around 2016. That is quite a long time in "Mac years". I think losing support for an 7-8 year old version is totally reasonable.

effendijohanes commented 1 year ago

@kylebgorman thank you for your hard work!

I agree with @lextoumbourou and @david-waterworth, if it's not supported by Apple anymore, I think it's reasonable not to support it anymore.

BTW I have upgraded my Mac to M1 Ventura.

taras-sereda commented 1 year ago

setting "-mmacosx-version-min=10.12" helps to build pynini on macOS Venture 13.5 @david-waterworth thank you for sharing this workaround