beeware / toga

A Python native, OS native GUI toolkit.
https://toga.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
4.37k stars 682 forks source link

`uv add toga` on MacOS erroneously builds `pygobject` for linux #2995

Open abulka opened 9 hours ago

abulka commented 9 hours ago

Describe the bug

uv add toga or uv add toga-demo on MacOS fails. It tries to build pygobject (which is a linux thing) and fails. Interestingly uv pip install toga works correctly.

Steps to reproduce

  1. Create a new directory
  2. Issue the commands
    uv init --python 3.12
    uv sync
    uv add toga
  3. See failure error Notice uv tries to download and build pygobject which is GTK for linux, and should not be happening on a Mac!
% uv add toga
  × Failed to download and build `pygobject==3.50.0`
  ╰─▶ Build backend failed to build wheel through `build_wheel` (exit status: 1)
  ...
  help: `pygobject` (v3.50.0) was included because `py-15-toga-py12` (v0.1.0) depends on `toga` (v0.4.8) which depends
        on `toga-gtk==0.4.8` (v0.4.8) which depends on `pygobject>=3.50.0`

Expected behavior

Expect successful installation of toga wheel without needing pygobject .

Screenshots

No response

Environment

Logs

% uv add toga
  × Failed to download and build `pygobject==3.50.0`
  ╰─▶ Build backend failed to build wheel through `build_wheel` (exit status: 1)

      [stdout]
      + meson setup /Users/andy/.cache/uv/sdists-v6/pypi/pygobject/3.50.0/cSgYGol3pHG6adtW916RT/src
      /Users/andy/.cache/uv/sdists-v6/pypi/pygobject/3.50.0/cSgYGol3pHG6adtW916RT/src/.mesonpy-qhu3xuzk
      -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Dtests=false -Dwheel=true --wrap-mode=nofallback
      --native-file=/Users/andy/.cache/uv/sdists-v6/pypi/pygobject/3.50.0/cSgYGol3pHG6adtW916RT/src/.mesonpy-qhu3xuzk/meson-python-native-file.ini
      The Meson build system
      Version: 1.6.0
      Source dir: /Users/andy/.cache/uv/sdists-v6/pypi/pygobject/3.50.0/cSgYGol3pHG6adtW916RT/src
      Build dir: /Users/andy/.cache/uv/sdists-v6/pypi/pygobject/3.50.0/cSgYGol3pHG6adtW916RT/src/.mesonpy-qhu3xuzk
      Build type: native build
      Project name: pygobject
      Project version: 3.50.0
      C compiler for the host machine: cc (clang 16.0.0 "Apple clang version 16.0.0 (clang-1600.0.26.4)")
      C linker for the host machine: cc ld64 1115.7.3
      Host machine cpu family: aarch64
      Host machine cpu: aarch64
      Program python3 found: YES (/Users/andy/.cache/uv/builds-v0/.tmphEIS5m/bin/python)
      Found pkg-config: YES (/opt/homebrew/bin/pkg-config) 2.3.0
      Run-time dependency python found: YES 3.12
      Did not find CMake 'cmake'
      Found CMake: NO
      Run-time dependency gobject-introspection-1.0 found: NO (tried pkgconfig, framework and cmake)
      Not looking for a fallback subproject for the dependency gobject-introspection-1.0 because:
      Use of fallback dependencies is disabled.

      ../meson.build:31:9: ERROR: Dependency 'gobject-introspection-1.0' is required but not found.

      A full log can be found at
      /Users/andy/.cache/uv/sdists-v6/pypi/pygobject/3.50.0/cSgYGol3pHG6adtW916RT/src/.mesonpy-qhu3xuzk/meson-logs/meson-log.txt

  help: `pygobject` (v3.50.0) was included because `py-15-toga-py12` (v0.1.0) depends on `toga` (v0.4.8) which depends
        on `toga-gtk==0.4.8` (v0.4.8) which depends on `pygobject>=3.50.0`

Additional context

Workarounds:

  1. brew install pygobject3 before uv add toga solves the dependency and allows uv add toga to succeed. However this should not be needed on a Mac, as GTK is not relevant on Mac.
  2. Alternatively, a different way of installing toga via uv pip install toga works. This avoids the workspace level uv add toga approach.

May be related to https://github.com/astral-sh/uv/issues/7985

freakboy3742 commented 8 hours ago

Moving this to the toga repository as this is an issue with installing Toga, not the beeware tutorial.

freakboy3742 commented 8 hours ago

And thanks for the report!