astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
26.41k stars 768 forks source link

Unable to instal cairocffi #7896

Closed peterbe closed 1 month ago

peterbe commented 1 month ago
/tmp
❯ rm uv.lock pyproject.toml

/tmp
❯ mkdir foo && cd foo

/tmp/foo
❯ uv init && uv add cairocffi
Initialized project `foo`
Using CPython 3.12.5
Creating virtual environment at: .venv
Resolved 4 packages in 4ms
Installed 3 packages in 10ms
 + cairocffi==1.7.1
 + cffi==1.17.1
 + pycparser==2.22

Looking good, but I can't use it

❯ uv run python
Python 3.12.5 (main, Aug 14 2024, 04:32:18) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cairocffi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/private/tmp/foo/.venv/lib/python3.12/site-packages/cairocffi/__init__.py", line 60, in <module>
    cairo = dlopen(
            ^^^^^^^
  File "/private/tmp/foo/.venv/lib/python3.12/site-packages/cairocffi/__init__.py", line 57, in dlopen
    raise OSError(error_message)  # pragma: no cover
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: no library called "cairo-2" was found
no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': dlopen(libcairo.so.2, 0x0002): tried: 'libcairo.so.2' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcairo.so.2' (no such file), '/usr/lib/libcairo.so.2' (no such file, not in dyld cache), 'libcairo.so.2' (no such file).  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libcairo.so.2'
cannot load library 'libcairo.2.dylib': dlopen(libcairo.2.dylib, 0x0002): tried: 'libcairo.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcairo.2.dylib' (no such file), '/usr/lib/libcairo.2.dylib' (no such file, not in dyld cache), 'libcairo.2.dylib' (no such file).  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libcairo.2.dylib'
cannot load library 'libcairo-2.dll': dlopen(libcairo-2.dll, 0x0002): tried: 'libcairo-2.dll' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcairo-2.dll' (no such file), '/usr/lib/libcairo-2.dll' (no such file, not in dyld cache), 'libcairo-2.dll' (no such file).  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libcairo-2.dll'

I don't know if this is "uv's fault" but if pip could it install it, perhaps it is. Sorry, I'm new to uv.

peterbe commented 1 month ago

I'm testing this on a macOS Sonoma 14.6

peterbe commented 1 month ago

oh curious. It could be a macOS thing because the code that I was working on just worked in GitHub Actions, which is ubuntu-latest.

peterbe commented 1 month ago

This fixes the problem:

❯ DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib uv run python
Python 3.12.5 (main, Aug 14 2024, 04:32:18) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cairocffi
>>>
charliermarsh commented 1 month ago

Thanks for following up!