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

fsencode TypeError when running `forge iOS lru-dict` #35

Closed noelmullankuzhy closed 3 months ago

noelmullankuzhy commented 3 months ago

Describe the bug

There is an issue when mobile-forge install steps are followed. Issue is happening when forging for any target.

env_list.append(k + b'=' + os.fsencode(v)) ^^^^^^^^^^^^^^ File "<frozen os>", line 812, in fsencode TypeError: expected str, bytes or os.PathLike object, not NoneType

Steps to reproduce

  1. Use the Python-Apple-Support branch 3.11
  2. Follow the instructions in readme of mobile-forge
  3. System is M1 MacBook Air

Expected behavior

Corresponding wheel is generated

Screenshots

No response

Environment

Logs


(venv3.11) noelmullankuzhy@Noels-MacBook-Air mobile-forge % forge iphonesimulator:12.0:arm64 lru-dict
Building lru-dict 1.1.8 for ios_12_0_iphonesimulator_arm64

[venv3.11-ios_12_0_iphonesimulator_arm64] Clean up old builds
Removing build/cp311/lru-dict/1.1.8...

[venv3.11-ios_12_0_iphonesimulator_arm64] Unpack sources
Unpacking downloads/lru-dict-1.1.8.tar.gz...

[venv3.11-ios_12_0_iphonesimulator_arm64] Apply patches
No patches to apply.

[venv3.11-ios_12_0_iphonesimulator_arm64] Create clean build environment
Creating venv3.11-ios_12_0_iphonesimulator_arm64...

Verifying cross-platform environment...
done.

Cross platform-environment venv3.11-ios_12_0_iphonesimulator_arm64 created.

[venv3.11-ios_12_0_iphonesimulator_arm64] Install forge host requirements
No host requirements.

[venv3.11-ios_12_0_iphonesimulator_arm64] Install forge build requirements
No build requirements.

[venv3.11-ios_12_0_iphonesimulator_arm64] Installing non-PEP517 build requirements

Requirement already satisfied: setuptools in ./build/cp311/lru-dict/1.1.8/venv3.11-ios_12_0_iphonesimulator_arm64/venv3.11-ios_12_0_iphonesimulator_arm64/lib/python3.11/site-packages (65.5.0)
Collecting setuptools
Obtaining dependency information for setuptools from https://files.pythonhosted.org/packages/c0/7a/3da654f49c95d0cc6e9549a855b5818e66a917e852ec608e77550c8dc08b/setuptools-69.1.1-py3-none-any.whl.metadata
Using cached setuptools-69.1.1-py3-none-any.whl.metadata (6.2 kB)
Using cached setuptools-69.1.1-py3-none-any.whl (819 kB)
Installing collected packages: setuptools
Attempting uninstall: setuptools
Found existing installation: setuptools 65.5.0
Uninstalling setuptools-65.5.0:
Successfully uninstalled setuptools-65.5.0
Successfully installed setuptools-69.1.1

Collecting build
Obtaining dependency information for build from https://files.pythonhosted.org/packages/4f/81/4849059526d02fcc9708e19346dd740e8b9edd2f0675ea7c38302d6729df/build-1.1.1-py3-none-any.whl.metadata
Using cached build-1.1.1-py3-none-any.whl.metadata (4.2 kB)
Collecting wheel
Obtaining dependency information for wheel from https://files.pythonhosted.org/packages/7d/cd/d7460c9a869b16c3dd4e1e403cce337df165368c71d6af229a74699622ce/wheel-0.43.0-py3-none-any.whl.metadata
Using cached wheel-0.43.0-py3-none-any.whl.metadata (2.2 kB)
Collecting packaging>=19.0 (from build)
Obtaining dependency information for packaging>=19.0 from https://files.pythonhosted.org/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl.metadata
Using cached packaging-24.0-py3-none-any.whl.metadata (3.2 kB)
Collecting pyproject_hooks (from build)
Obtaining dependency information for pyproject_hooks from https://files.pythonhosted.org/packages/d5/ea/9ae603de7fbb3df820b23a70f6aff92bf8c7770043254ad8d2dc9d6bcba4/pyproject_hooks-1.0.0-py3-none-any.whl.metadata
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 wheel-0.43.0-py3-none-any.whl (65 kB)
Using cached packaging-24.0-py3-none-any.whl (53 kB)
Using cached pyproject_hooks-1.0.0-py3-none-any.whl (9.3 kB)
Installing collected packages: wheel, pyproject_hooks, packaging, build
Successfully installed build-1.1.1 packaging-24.0 pyproject_hooks-1.0.0 wheel-0.43.0

Requirement already satisfied: setuptools in ./build/cp311/lru-dict/1.1.8/venv3.11-ios_12_0_iphonesimulator_arm64/build/lib/python3.11/site-packages (65.5.0)
Collecting setuptools
Obtaining dependency information for setuptools from https://files.pythonhosted.org/packages/c0/7a/3da654f49c95d0cc6e9549a855b5818e66a917e852ec608e77550c8dc08b/setuptools-69.1.1-py3-none-any.whl.metadata
Using cached setuptools-69.1.1-py3-none-any.whl.metadata (6.2 kB)
Using cached setuptools-69.1.1-py3-none-any.whl (819 kB)
Installing collected packages: setuptools
Attempting uninstall: setuptools
Found existing installation: setuptools 65.5.0
Uninstalling setuptools-65.5.0:
Successfully uninstalled setuptools-65.5.0
Successfully installed setuptools-69.1.1

Collecting build
Obtaining dependency information for build from https://files.pythonhosted.org/packages/4f/81/4849059526d02fcc9708e19346dd740e8b9edd2f0675ea7c38302d6729df/build-1.1.1-py3-none-any.whl.metadata
Using cached build-1.1.1-py3-none-any.whl.metadata (4.2 kB)
Collecting wheel
Obtaining dependency information for wheel from https://files.pythonhosted.org/packages/7d/cd/d7460c9a869b16c3dd4e1e403cce337df165368c71d6af229a74699622ce/wheel-0.43.0-py3-none-any.whl.metadata
Using cached wheel-0.43.0-py3-none-any.whl.metadata (2.2 kB)
Collecting packaging>=19.0 (from build)
Obtaining dependency information for packaging>=19.0 from https://files.pythonhosted.org/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl.metadata
Using cached packaging-24.0-py3-none-any.whl.metadata (3.2 kB)
Collecting pyproject_hooks (from build)
Obtaining dependency information for pyproject_hooks from https://files.pythonhosted.org/packages/d5/ea/9ae603de7fbb3df820b23a70f6aff92bf8c7770043254ad8d2dc9d6bcba4/pyproject_hooks-1.0.0-py3-none-any.whl.metadata
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 wheel-0.43.0-py3-none-any.whl (65 kB)
Using cached packaging-24.0-py3-none-any.whl (53 kB)
Using cached pyproject_hooks-1.0.0-py3-none-any.whl (9.3 kB)
Installing collected packages: wheel, pyproject_hooks, packaging, build
Successfully installed build-1.1.1 packaging-24.0 pyproject_hooks-1.0.0 wheel-0.43.0

********************************************************************************
Failed build: lru-dict 1.1.8 for iphonesimulator 12.0 on arm64
********************************************************************************
Traceback (most recent call last):
  File "/Users/noelmullankuzhy/Tools/mobile-forge/src/forge/build.py", line 267, in build
    self._build()
  File "/Users/noelmullankuzhy/Tools/mobile-forge/src/forge/build.py", line 510, 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 39, in run
    with stdlib_subprocess.Popen(*args, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noelmullankuzhy/Tools/Python-Apple-support/install/macOS/macosx/python-3.11.6/lib/python3.11/subprocess.py", line 1030, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/noelmullankuzhy/Tools/Python-Apple-support/install/macOS/macosx/python-3.11.6/lib/python3.11/subprocess.py", line 1874, in _execute_child
    env_list.append(k + b'=' + os.fsencode(v))
                               ^^^^^^^^^^^^^^
  File "<frozen os>", line 812, in fsencode
TypeError: expected str, bytes or os.PathLike object, not NoneType

Failed builds for:
 * lru-dict (default version) (ios_12_0_iphonesimulator_arm64)

(venv3.11) noelmullankuzhy@Noels-MacBook-Air mobile-forge % 

Additional context

No response

freakboy3742 commented 3 months ago

Thanks for the report; unfortunately, I can't reproduce what you're seeing - a clean 3.11 build of lru-dict for iOS simulator arm64 completes successfully.

I suspect the problem might be something I've assumed about the build environment; the error would be consistent with a None value being passed in as an argument to a build call. Can I ask you to share the log file that was generated in errors for this build? That might give a hint as to where things have gone wrong.

noelmullankuzhy commented 3 months ago

Here are the log files.

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

noelmullankuzhy commented 3 months ago

By the way I had faced another issue while setting up mobile-forge. The issue and the steps I have taken to solve it are mentioned in #36. Please read through that also. I suspect the issues could be related. When running source ./setup-iOS.sh 3.11 the script make_dep_wheels.py fails and I had to manually copy files to Dist folder to make it work. Your suspicion regarding assumptions about build environment could be true.

freakboy3742 commented 3 months ago

As I suspected, the issue is an assumption about the build environment. The compiler environment is copying over some "useful default" values for HOME, TMPDIR, and a couple of other variables - but if those aren't present in the user's environment, they're passed in as None, which causes the error you're seeing. The problem value in this case is LANG - I thought that it was safe to assume that was set, but apparently not.

I've corrected this in #38. Thanks for the report, and apologies for the inconvenience.