beeware / mobile-forge

A tool to manage building cross-platform binary wheels for mobile devices
BSD 3-Clause "New" or "Revised" License
14 stars 9 forks source link

`forge iOS lru-dict` fails with errors in `subprocess` call #39

Closed noelmullankuzhy closed 3 months ago

noelmullankuzhy commented 3 months ago

Describe the bug

Building after Issue #38 fix.

Running forge iOS lru-dict causes the following error.

lru.c:629:17: error: incompatible function pointer types initializing 'PyCFunction' (aka 'struct _object *(*)(struct _object *, struct _object *)') with an expression of type 'PyCFunctionWithKeywords' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') [-Wincompatible-function-pointer-types]
{"popitem", (PyCFunctionWithKeywords)LRU_popitem, METH_VARARGS | METH_KEYWORDS,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
error: command '/Users/noelmullankuzhy/Tools/Python-Apple-support/support/3.11/iOS/bin/arm64-apple-ios12.0-clang' failed with exit code 1

ERROR Backend subprocess exited when trying to invoke build_wheel
********************************************************************************
Failed build: lru-dict 1.1.8 for iphoneos 12.0 on arm64
********************************************************************************
Traceback (most recent call last):
  File "/Users/noelmullankuzhy/Tools/mobile-forge/src/forge/build.py", line 268, in build
    self._build()
  File "/Users/noelmullankuzhy/Tools/mobile-forge/src/forge/build.py", line 511, in _build
    self.cross_venv.run(
  File "/Users/noelmullankuzhy/Tools/mobile-forge/src/forge/cross.py", line 356, in run
    return subprocess.run(logfile, *args, **self.cross_kwargs(kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noelmullankuzhy/Tools/mobile-forge/src/forge/subprocess.py", line 49, in run
    raise stdlib_subprocess.CalledProcessError(return_code, args)
subprocess.CalledProcessError: Command '(['python', '-m', 'build', '--no-isolation', '--wheel', '--outdir', '/Users/noelmullankuzhy/Tools/mobile-forge/dist'],)' returned non-zero exit status 1.

Steps to reproduce

  1. clone repository and run source ./setup-iOS.sh 3.11
  2. After environment is set up run forge iOS lru-dict

Expected behavior

Lou-dict wheels are generated with out issues

Screenshots

No response

Environment

Logs

Terminal Output Terminal Output forge iOS lri-dict Fail.txt

Error Logs lru-dict-1.1.8-cp311-ios_12_0_iphoneos_arm64.log lru-dict-1.1.8-cp311-ios_12_0_iphonesimulator_arm64.log lru-dict-1.1.8-cp311-ios_12_0_iphonesimulator_x86_64.log

Additional context

No response

freakboy3742 commented 3 months ago

This is a weird one - I see the same problem, but I only get a warning, not a full error:

creating build/temp.ios-12.0-iphoneos-arm64-cpython-311
arm64-apple-ios12.0-clang -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -mios-version-min=12.0 -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -mios-version-min=12.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk/usr/include -I/Users/rkm/beeware/mobile-forge/build/cp311/lru-dict/1.1.8/venv3.11-ios_12_0_iphoneos_arm64/venv3.11-ios_12_0_iphoneos_arm64/include -I/Users/rkm/beeware/support/Python-Apple-support/install/iOS/iphoneos.arm64/python-3.11.6/include/python3.11 -c lru.c -o build/temp.ios-12.0-iphoneos-arm64-cpython-311/lru.o
lru.c:629:17: warning: incompatible function pointer types initializing 'PyCFunction' (aka 'struct _object *(*)(struct _object *, struct _object *)') with an expression of type 'PyCFunctionWithKeywords' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') [-Wincompatible-function-pointer-types]
{"popitem", (PyCFunctionWithKeywords)LRU_popitem, METH_VARARGS | METH_KEYWORDS,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

So - the result you're seeing is an expected problem, but manifesting harder than it should. Ordinarily, the warning should only be promoted to an error if you're passing in -WX or similar. Is there any possibility that you've got an environment variable that might be doing this?

The other possibility is that there's been a change in the iPhone SDK between 17.2 and 17.4... but that seems less likely.

One way to test this out - can you build a macOS wheel with your current environment? Can you unpack the lru-dict tarball somewhere locally and run python -m build --wheel from the root of the checkout?

noelmullankuzhy commented 3 months ago

I have unpacked the tarball to /Users/noelmullankuzhy/Tools/mobile-forge/downloads/lru-dict-1.1.8

In the venv3.11 I ran the following

cd /Users/noelmullankuzhy/Tools/mobile-forge/downloads/lru-dict-1.1.8 python -m build --wheel

Which resulted in following:

/Users/noelmullankuzhy/Tools/mobile-forge/venv3.11/bin/python: No module named build

Then I ran python -m pip install --upgrade build

which resulted in :

Collecting build

  Using cached build-1.1.1-py3-none-any.whl.metadata (4.2 kB)
Requirement already satisfied: packaging>=19.0 in /Users/noelmullankuzhy/Tools/mobile-forge/venv3.11/lib/python3.11/site-packages (from build) (24.0)
Collecting pyproject_hooks (from build)
  Using cached pyproject_hooks-1.0.0-py3-none-any.whl.metadata (1.3 kB)
Using cached build-1.1.1-py3-none-any.whl (19 kB)
Using cached pyproject_hooks-1.0.0-py3-none-any.whl (9.3 kB)
Installing collected packages: pyproject_hooks, build
Successfully installed build-1.1.1 pyproject_hooks-1.0.0

And then I ran python -m build --wheel

1 error generated.
error: command '/usr/bin/clang' failed with exit code 1

Here is the full terminal output: Terminal Output Build Lru-Dict Mac Wheel.txt

On your other point of whether any other environment variables are messing with the process, here is a list of my environment variables

(venv3.11) noelmullankuzhy@Noels-MacBook-Air mobile-forge % printenv
__CFBundleIdentifier=com.apple.Terminal
TMPDIR=/var/folders/nw/_1x8fxrx7ssfl5q84pn6033m0000gn/T/
XPC_FLAGS=0x0
TERM=xterm-256color
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.Y0FDhITxBw/Listeners
XPC_SERVICE_NAME=0
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=453
TERM_SESSION_ID=49954B9A-30B8-40F1-8A10-A52CCF59AC1A
SHELL=/bin/zsh
HOME=/Users/noelmullankuzhy
LOGNAME=noelmullankuzhy
USER=noelmullankuzhy
PATH=/Users/noelmullankuzhy/Tools/mobile-forge/venv3.11/bin:/opt/homebrew/lib/ruby/gems/3.3.0/bin:/opt/homebrew/opt/ruby/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/noelmullankuzhy/Tools/flutter/bin:/Users/noelmullankuzhy/Tools/Python-Apple-support/support/3.11/iOS/bin:/Users/noelmullankuzhy/Tools/mobile-forge/tools/CMake.app/Contents/bin
SHLVL=1
PWD=/Users/noelmullankuzhy/Tools/mobile-forge
OLDPWD=/Users/noelmullankuzhy
HOMEBREW_PREFIX=/opt/homebrew
HOMEBREW_CELLAR=/opt/homebrew/Cellar
HOMEBREW_REPOSITORY=/opt/homebrew
MANPATH=/opt/homebrew/share/man::
INFOPATH=/opt/homebrew/share/info:
PYTHON_APPLE_SUPPORT=/Users/noelmullankuzhy/Tools/Python-Apple-support
VIRTUAL_ENV=/Users/noelmullankuzhy/Tools/mobile-forge/venv3.11
PS1=(venv3.11) %n@%m %1~ %# 
VIRTUAL_ENV_PROMPT=(venv3.11) 
MOBILE_FORGE_IPHONEOS_ARM64=/Users/noelmullankuzhy/Tools/Python-Apple-support/install/iOS/iphoneos.arm64/python-3.11.6/bin/python3.11
MOBILE_FORGE_IPHONESIMULATOR_ARM64=/Users/noelmullankuzhy/Tools/Python-Apple-support/install/iOS/iphonesimulator.arm64/python-3.11.6/bin/python3.11
MOBILE_FORGE_IPHONESIMULATOR_X86_64=/Users/noelmullankuzhy/Tools/Python-Apple-support/install/iOS/iphonesimulator.x86_64/python-3.11.6/bin/python3.11
LC_CTYPE=UTF-8
_=/usr/bin/printenv
(venv3.11) noelmullankuzhy@Noels-MacBook-Air mobile-forge % 
noelmullankuzhy commented 3 months ago

Here is some more useful info.

running clang -v with following results.

Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Running xcode-select -v with following result

xcode-select version 2406
noelmullankuzhy commented 3 months ago

I did some more digging. It seems like lru-dict-1.1.8 which is being downloaded supports only upto Python 3.10 according to this Link. The current latest version lru-dict-1.3.0 supports upto Python 3.12 according to this Link. So I have manually downloaded the source files from Releases v1.3.0 which incidentally added ARM64 Support and tried to build this using python -m build --wheel on its root and the wheel was generated successfully.

Terminal Output lru-dict-1.3.0 Mac OS Wheel Success.txt

I have updated the recipe of to version lru-dict-1.3.0 and ran forge iOS lru-dict now everything is building correctly.

Terminal Output lru-dict-1.3.0 iOS Wheel Success.txt

freakboy3742 commented 3 months ago

Thanks for those details; and glad to hear you've got a working wheel for lru-dict 1.3.0.

It's still a little weird that you're seeing a hard error when I'm seeing a soft error, but I guess that could be chalked up to the minor clang discrepancy (I'm on 1500.1.0.2.5).

I'll leave this open as a marker for the fact that we should update the recipe for lru-dict; if you feel like contributing a PR, add Fixes #39 in the comment and it will auto-close this issue when the PR is merged.