Skip to content
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

Add M1 homebrew dylib dir #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guillaumegenthial
Copy link

@guillaumegenthial guillaumegenthial commented Jun 12, 2021

This seems to fix installation problems on M1 chips with libheif installed with M1 brew.

The dylib location has changed with the M1 native brew.

Procedure to install pyheif on M1 mac

brew install libffi libheif
pip install git+https://github.com/carsales/pyheif.git

@panosangelopoulos
Copy link

Hi @guillaumegenthial, i was trying to install the package based on your fix but it seems that the problem remains.

    build/temp.linux-aarch64-3.8/_libheif_cffi.c:570:15: fatal error: libheif/heif.h: No such file or directory
          #include "libheif/heif.h"
                   ^~~~~~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1

@OgulcanCelik
Copy link

This works great, review this please!

@homm
Copy link
Contributor

homm commented Nov 18, 2021

Does #42 solve this? Please try the 0.6.0 version.

@panosangelopoulos
Copy link

hi @homm, unfortunately, it's not solved by 0.6.0.

The issue remains.

@homm
Copy link
Contributor

homm commented Dec 8, 2021

@panosangelopoulos Could you run in terminal:

$ echo $HOMEBREW_PREFIX

@pramttl
Copy link

pramttl commented Apr 27, 2022

I still see this issue as of pyheif==0.7.0

UPDATE: Sorry, it gets resolved after I run brew install libffi libheif and then run pip install pyheif. Works great! 👍

(Old error log before running the brew install)

      generating cffi module 'build/temp.macosx-12.3-arm64-3.8/_libheif_cffi.c'
      creating build/temp.macosx-12.3-arm64-3.8
      building '_libheif_cffi' extension
      creating build/temp.macosx-12.3-arm64-3.8/build
      creating build/temp.macosx-12.3-arm64-3.8/build/temp.macosx-12.3-arm64-3.8
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/usr/local/include -I/usr/include -I/opt/local/include -I/opt/homebrew/include -I/Users/pranjal/.pyenv/versions/3.8.13/envs/real38/include -I/Users/pranjal/.pyenv/versions/3.8.13/include/python3.8 -c build/temp.macosx-12.3-arm64-3.8/_libheif_cffi.c -o build/temp.macosx-12.3-arm64-3.8/build/temp.macosx-12.3-arm64-3.8/_libheif_cffi.o
      build/temp.macosx-12.3-arm64-3.8/_libheif_cffi.c:570:15: fatal error: 'libheif/heif.h' file not found
           #include "libheif/heif.h"
                    ^~~~~~~~~~~~~~~~
      1 error generated.
      error: command 'clang' failed with exit status 1
      [end of output]

@boxed
Copy link

boxed commented May 18, 2022

Tried pip install git+https://github.com/guillaumegenthial/pyheif.git today on my M1, I got the compilation error above. I have libheif installed via brew, and I have the header file:

ls /opt/homebrew/include/libheif/
heif.h		heif_cxx.h	heif_plugin.h	heif_version.h

I don't understand what's wrong. Anyone have any ideas?

@boxed
Copy link

boxed commented May 18, 2022

aha! My bad. The correct incantation for pip is:

pip install git+https://github.com/guillaumegenthial/pyheif.git@m1-support

I can confirm this PR works on m1 macs no problem.

@c0ridrew
Copy link

c0ridrew commented Aug 25, 2022

I found this workaround to install this patched version of pyheif in M1 chips mac only since installing this version failed in other systems.
Hope this helps whoever struggling with the same problem 👍

pyheif= [
    {version = "^0.5.1", markers = "sys_platform != 'darwin'"},
    {git = "https://github.com/guillaumegenthial/pyheif.git", rev = "m1-support", markers = "sys_platform == 'darwin'"}
]

Tried with poetry but I assume the same thing can be done with other package managers.

@NTag
Copy link

NTag commented Dec 30, 2022

Could this PR be merged and a new version of the lib be released? It's quit annoying 🥲

@boxed
Copy link

boxed commented Feb 15, 2023

Any help we can give on this issue?

@homm
Copy link
Contributor

homm commented Jun 16, 2023

Any help we can give on this issue?

Yes, you can provide your $HOMEBREW_PREFIX asked Dec 8, 2021

Could this PR be merged

Yes, sure, the only issue "installing this version failed in other systems"

@boxed
Copy link

boxed commented Jun 16, 2023

for me $HOMEBREW_PREFIX seems unset. That doesn't seem like it could be what you asked for...

@homm
Copy link
Contributor

homm commented Aug 23, 2023

for me $HOMEBREW_PREFIX seems unset.

You don't have homebrew properly installed in your system. The final step of installation should be adding brew shellenv in your environment.

Try this:

$ eval "$(/opt/homebrew/bin/brew shellenv)"

$ pip install git+https://github.com/carsales/pyheif.git@master#egg=pyheif
Collecting pyheif
Building wheels for collected packages: pyheif
  Building wheel for pyheif (setup.py) ... done
  Created wheel for pyheif: filename=pyheif-0.7.1-cp39-cp39-macosx_10_9_universal2.whl
Successfully built pyheif
Installing collected packages: pyheif
Successfully installed pyheif-0.7.1

$ ipython 
Python 3.9.6 (default, May  7 2023, 23:32:44) 

In [1]: import pyheif

In [2]: pyheif.__version__
Out[2]: '0.7.1'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants