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 support for iOS #1520

Open
cclauss opened this issue May 29, 2019 · 8 comments
Open

Add support for iOS #1520

cclauss opened this issue May 29, 2019 · 8 comments
Assignees

Comments

@cclauss
Copy link
Contributor

cclauss commented May 29, 2019

Can we get support on iOS?

pip install psutil on Python 3.7 on iOS Pyto results in...

Querying PyPI ... 
Downloading package ...

Extracting archive file ...
Running setup file ...
Traceback (most recent call last):
  File "Pyto.app/installer.py", line 6, in <module>
    main(sys.argv[1:])
  File "Pyto.app/site-packages/pip.py", line 1489, in main
    repository.install(pkg_name, ver_spec, dist=dist)
  File "Pyto.app/site-packages/pip.py", line 1079, in install
    self._install(pkg_name, pkg_info, archive_filename, dependency_dist=dist)
  File "Pyto.app/site-packages/pip.py", line 842, in _install
    files_installed, dependencies = self.installer.run(pkg_name, archive_filename)
  File "Pyto.app/site-packages/pip.py", line 525, in run
    return self._run_setup_file(setup_filename)
  File "Pyto.app/site-packages/pip.py", line 614, in _run_setup_file
    exec(codeobj, namespace, namespace)
  File "/private/var/mobile/Containers/Data/Application/88E244A6-EF98-4A77-937A-8D0C39208B36/tmp/41d21074d4e64594933bdfdc412410c2/psutil-5.6.2/setup.py", line 257, in <module>
SystemExit: platform ios is not supported

@ColdGrub1384

@ColdGrub1384
Copy link

Would it be possible to support iOS? If it’s possible (it seems some modifications are needed, not sure) I think I would need to compile it and include it in Pyto.

@giampaolo
Copy link
Owner

giampaolo commented May 29, 2019

I have an iphone but I don’t know anything about iOS development or Python on iOS. But this is interesting. Some preliminary noob questions:

  • how do you install Python on iOS?
  • how do you develop for iOS? Specifically: can you emulate it on Linux and setup a working environment?
  • assuming this is done, how are you supposed to install psutil on iOS? Via pip? Apple appstore?
  • any idea if macOS and iOS kernels are similar? I wonder if macOS implementation can be reused.

@cclauss
Copy link
Contributor Author

cclauss commented May 29, 2019

https://itunes.apple.com/us/app/pyto-python-ide/id1436650069 is how you install Python on your iPhone. You can edit Python files and run them directly on your iPhone — You don’t need Linux. Pip install is enabled.

@giampaolo giampaolo changed the title [iOS] SystemExit: platform ios is not supported Add support for iOS May 29, 2019
@ColdGrub1384
Copy link

We use Python C API, so no other process is spawned inside the app.

@ColdGrub1384
Copy link

With pip, only pure Python modules can be installed. So if a module has to be compiled, I have to compile it and include it in the app.

@cclauss
Copy link
Contributor Author

cclauss commented Jun 1, 2019

@giampaolo Were you able to get Python working on your iPhone?

@DaOfficialRolex
Copy link

DaOfficialRolex commented Apr 13, 2021

I was wondering if there was any interest in reviving support for iOS. Since I want to add psutil and bpytop to iOS and macOS. Currently when I try to build psutil for iOS. I get this error.
building 'psutil._psutil_osx' extension creating build/temp.macosx-11.0-x86_64-3.9 creating build/temp.macosx-11.0-x86_64-3.9/psutil creating build/temp.macosx-11.0-x86_64-3.9/psutil/arch creating build/temp.macosx-11.0-x86_64-3.9/psutil/arch/osx cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -O2 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=11.0 -isystem /Users/haydenseay/GitHub/Procursus/build_base/darwin-amd64/1700//opt/procursus/include -isystem /Users/haydenseay/GitHub/Procursus/build_base/darwin-amd64/1700//opt/procursus/include -F/Users/haydenseay/GitHub/Procursus/build_base/darwin-amd64/1700//opt/procursus/System/Library/Frameworks -F/Users/haydenseay/GitHub/Procursus/build_base/darwin-amd64/1700//opt/procursus/Library/Frameworks -O2 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=11.0 -isystem /Users/haydenseay/GitHub/Procursus/build_base/darwin-amd64/1700//opt/procursus/include -isystem /Users/haydenseay/GitHub/Procursus/build_base/darwin-amd64/1700//opt/procursus/include -F/Users/haydenseay/GitHub/Procursus/build_base/darwin-amd64/1700//opt/procursus/System/Library/Frameworks -F/Users/haydenseay/GitHub/Procursus/build_base/darwin-amd64/1700//opt/procursus/Library/Frameworks -O2 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk -miphoneos-version-min=14.0 -isystem /Users/rolex/Procursus/build_base/iphoneos-arm64/1700/usr/include -isystem /Users/rolex/Procursus/build_base/iphoneos-arm64/1700/usr/local/include -F/Users/rolex/Procursus/build_base/iphoneos-arm64/1700/System/Library/Frameworks -F/Users/rolex/Procursus/build_base/iphoneos-arm64/1700/Library/Frameworks -O2 -arch arm64 -miphoneos-version-min=14.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk -isystem /Users/rolex/Procursus/build_base/iphoneos-arm64/1700/usr/include -isystem /Users/rolex/Procursus/build_base/iphoneos-arm64/1700/usr/local/include -Wno-error-implicit-function-declaration -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=580 -DPSUTIL_OSX=1 -I/opt/procursus/include/python3.9 -c psutil/_psutil_common.c -o build/temp.macosx-11.0-x86_64-3.9/psutil/_psutil_common.o clang: error: invalid argument '-mmacosx-version-min=11.0' not allowed with '-miphoneos-version-min=14.0' clang: warning: using sysroot for 'iPhoneOS' but targeting 'MacOSX' [-Wincompatible-sysroot] clang: error: invalid argument '-mmacosx-version-min=11.0' not allowed with '-miphoneos-version-min=14.0' clang: warning: using sysroot for 'iPhoneOS' but targeting 'MacOSX' [-Wincompatible-sysroot] error: command '/usr/bin/cc' failed with exit code 1 gmake[1]: *** [python-psutil.mk:18: python-psutil] Error 1 gmake: *** [Makefile:749: rebuild-python-psutil-package] Error 2

I was able to successfully build psutil for macOS on both amd64 and arm64. I was hoping since arm64 for macOS and iOS are pretty similar. That clang was able to compile it correctly however it seems that assumption was wrong. I am guessing this means support for iOS needs to be added by the developers of psutil. If this is not case please let me know. I have very little knowledge on python. So I am sorry ahead of time if this is not the case.

Here is the little progress I made for psutil.

@Emasoft
Copy link

Emasoft commented Sep 28, 2024

I'm using a-Shell on iOS and I cannot install the psutil package (maybe because there is no precompiled wheel for ios?).
This is the error I got:

[~/Documents]$ pip -v --no-cache install psutil
Using pip 24.0 from /private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip (python 3.11)
Defaulting to user installation because normal site-packages is not writeable
Collecting psutil
  Downloading psutil-6.0.0.tar.gz (508 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 508.1/508.1 kB 6.2 MB/s eta 0:00:00
  Running command Preparing metadata (pyproject.toml)
  Traceback (most recent call last):
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
      return hook(metadata_directory, config_settings)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/setuptools/build_meta.py", line 366, in prepare_metadata_for_build_wheel
      self.run_setup()
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
      exec(code, locals())
    File "<string>", line 569, in <module>
    File "<string>", line 446, in main
    File "<string>", line 146, in get_long_description
  RuntimeError: Fatal Python error: pyinit_core_reconfigure: failed to read thread state
  Python runtime state: initialized

  Thread 0x000000016b1e3000 (most recent call first):
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/utils/subprocess.py", line 166 in call_subprocess
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/utils/subprocess.py", line 252 in runner
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_impl.py", line 311 in _call_hook
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_impl.py", line 186 in prepare_metadata_for_build_wheel
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/utils/misc.py", line 766 in prepare_metadata_for_build_wheel
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/operations/build/metadata.py", line 35 in generate_metadata
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/req/req_install.py", line 579 in prepare_metadata
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/distributions/sdist.py", line 67 in prepare_distribution_metadata
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 71 in _get_prepared_distribution
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 640 in _prepare_linked_requirement
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 525 in prepare_linked_requirement
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 301 in _prepare_distribution
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 222 in _prepare
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 156 in __init__
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 290 in __init__
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 228 in _make_base_candidate_from_link
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 182 in _make_candidate_from_link
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 47 in _iter_built
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143 in <genexpr>
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155 in __bool__
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_vendor/resolvelib/structs.py", line 156 in __bool__
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 173 in _add_to_criteria
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 397 in resolve
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 546 in resolve
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 95 in resolve
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/commands/install.py", line 377 in run
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/cli/req_command.py", line 245 in wrapper
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 180 in exc_logging_wrapper
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 234 in _main
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 101 in main
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_internal/cli/main.py", line 79 in main
    File "/private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/bin/pip", line 8 in <module>

  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: python3 /private/var/containers/Bundle/Application/221A037F-C78F-483C-9420-47A5B93DB81D/a-Shell.app/Library/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py prepare_metadata_for_build_wheel /private/var/mobile/Containers/Data/Application/226D3CE7-70FC-4A59-B446-75AD8149DEE8/tmp/tmp6qtmt_24
  cwd: /private/var/mobile/Containers/Data/Application/226D3CE7-70FC-4A59-B446-75AD8149DEE8/tmp/pip-install-3az_40w5/psutil_88019e69f6d04f65becbdcea4b7746a3
  Preparing metadata (pyproject.toml) ... error
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

a-Shell author says that he can solve this issue including the precompiled binaries of psutil into the app as he did for most python libs, but he needs a version of the lib that compiles for iOS, and at the moment psutil doesn't have one.

Please add support for iOS platform.

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

No branches or pull requests

5 participants