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

visionOS support #207

Open
efroemling opened this issue Feb 21, 2024 · 7 comments
Open

visionOS support #207

efroemling opened this issue Feb 21, 2024 · 7 comments
Labels
enhancement New features, or improvements to existing features.

Comments

@efroemling
Copy link
Contributor

efroemling commented Feb 21, 2024

I know visionOS itself is pretty new, but I'm curious if this is on the radar? I'd be happy to try and put together a PR myself if not, as this would be fun to play with. I'd hope it wouldn't require a ton of work to adapt the iOS targets?..

@efroemling efroemling added the enhancement New features, or improvements to existing features. label Feb 21, 2024
@freakboy3742
Copy link
Member

It's not on my own radar (unless someone wants to donate an Apple Vision to the cause... 😄)

If someone wants to contribute a patch, I'll take a look at it. I suspect you're right that the amount of work should be minimal - the build process should be largely compatible with the iOS build process. I suspect the biggest complication will be the fixes to CPython itself - you'll need to patch a bunch of things (mostly in configure, but a few other places as well) to accomodate visionOS as a build target.

@sheikheddy
Copy link

Hey, I have an Apple Vision Pro and have some experience with CPython, but I'm completely new to BeeWare (only found it via PEP 730) so wouldn't be comfortable committing to writing a patch to add visionOS 2.0 support.

My understanding is that visionOS is a fork of iPadOS, so I'm happy to clone this repo and swap some names in config and using ChatGPT to work through initial issues to test whether make visionOS works.

Would you suggest doing that with 3.13.0 candidate 2, or waiting till 3.13.0 final?

@freakboy3742
Copy link
Member

My understanding is also that visionOS is essentially "iPadOS on different hardware", so making modifications to support visionOS is likely not that complicated.

There are two sets of changes that are required.

The first is changes to the makefile in this repo to add visionOS support. That's mostly a case of "add visionOS to the list of tags"; the hardest part is working out exactly what Apple "calls" visionOS and the visionOS simulator (there's some weird inconsistencies - it's iphoneos, but then iphonesimulator; appletvos but then watchos).

The second is to modify the patch to the CPython sources. The patch that is applied to the CPython sources is currently based on 3.13.0rc2; the CPython core team decided that there will be an rc3 due to a couple of last minute issues that have been discovered, but those shouldn't affect anything on the Apple mobile platforms. The patch is generated using the 3.13-patched branch from my fork of the CPython repo; it's literally the 3.13.0rc2 sources, plus 2 patches for adding tvOS and watchOS support. If you wanted to try adding an additional patch for visionOS support, it will mostly be a case of "everywhere the patch says "tvOS", "watchOS", add "visionOS"", then re-running autoconf to get an updated configure script.

If you need any further pointers, let me know; I'm happy to help get someone up to speed to work on this.

@sheikheddy
Copy link

sheikheddy commented Sep 28, 2024

Thanks for the thorough response!

  1. The first part sounds feasible: I can grep for all the places with lists of tags, and add ones for visionOS and the visionOS simulator. I'll try my best to get all of them, but if I don't succeed, that can be caught at review time. I read a news article which said that the old name for visionOS was xros, but I'm not sure if that is still in use. I can confirm this experimentally or ask around in a discord with visionOS devs.

  2. I wasn't aware that there was going to be an rc3. I took 5 minutes to check if this information was public, but it doesn't seem to be. Hopefully someone is assigned to update PEP 719, but it's alright if that's low priority.

  3. I can add a release.visionOS.exclude copying the iOS one (i.e, only exclude __pycache__). I don't fully understand what is going on in sitecustomize, but I think I'll need to create a sitecustomize.visionOS.py and include it in my PYTHONPATH. I read the blog post linked, it didn't seem to imply there was anything additional I'd need to change, though I can try and find out.

  4. What options would I need to pass to autoconf? Are they the same on all runs, or different in the first and subsequent runs? I googled and read a tutorial, but did not find an existing configure.ac file to use.

  • I had a look at /patch/Python/Python.patch, under "How do I build Python for watchOS" (lines 1592 to 1596)
    + $ ./configure \
    + --enable-framework=/path/to/install \
    + --host=aarch64-apple-watchos \
    + --build=aarch64-apple-darwin \
    + --with-build-python=/path/to/python.exe
    . This references a ./configure command, though I don't have more context.
  • For --with-build-python I can use the 3.13 patched branch you shared, and specify some arbitrary path for --with-framework-name to place the Python.framework build for visionOS.

Does that sound okay so far? Let me know if I'm on the right track.

@freakboy3742
Copy link
Member

  1. The first part sounds feasible: I can grep for all the places with lists of tags, and add ones for visionOS and the visionOS simulator. I'll try my best to get all of them, but if I don't succeed, that can be caught at review time. I read a news article which said that the old name for visionOS was xros, but I'm not sure if that is still in use. I can confirm this experimentally or ask around in a discord with visionOS devs.

The way to check this is to see how xcrun —show-sdk-path —sdk <visionOS?> responds. If you get a path that is clearly a Vision OS SDK, you’re on the right track.

  1. I wasn't aware that there was going to be an rc3. I took 5 minutes to check if this information was public, but it doesn't seem to be. Hopefully someone is assigned to update PEP 719, but it's alright if that's low priority.

The RC3 decision that was made late Friday afternoon as the core team sprint was wrapping up. I imagine PEP 719 will be updated as soon as everyone returns from their various flights. I believe the plan is to cut the release on Monday.

  1. I can add a release.visionOS.exclude copying the iOS one (i.e, only exclude __pycache__). I don't fully understand what is going on in sitecustomize, but I think I'll need to create a sitecustomize.visionOS.py and include it in my PYTHONPATH. I read the blog post linked, it didn't seem to imply there was anything additional I'd need to change, though I can try and find out.

IIRC, the sitecustomize file is the same on all mobile platforms - if it’s isn’t, the changes are minimal. It’s an implementation of a trick that fools pip into thinking it’s running on the device; it’s needed until pip is able to support a platform - pypa/pip#12962 will do this for iOS, but the sitecustomize will be needed for tvOS, watchOS and visionOS until they become Tier 3 Python platforms.

  1. What options would I need to pass to autoconf? Are they the same on all runs, or different in the first and subsequent runs? I googled and read a tutorial, but did not find an existing configure.ac file to use.

autoconf has no options - it’s a script that compiles configure.ac into configure. The only thing you’ll need to watch is that you have the right version of autoconf installed - as of Python 3.13, you need to have 2.71. You only need to invoke autoconf if you modify configure.ac… but you’ll need to do that to add a new platform.

  • I had a look at /patch/Python/Python.patch, under "How do I build Python for watchOS" ...
    . This references a ./configure command, though I don't have more context.

There an analogous guide for iOS and tvOS as well; the iOS one (which is in 3.13 proper) will be the most reliable guide. Those READMEs are essentially the long form documentation version of what Python-Apple-support encodes as a Makefile.

  • For --with-build-python I can use the 3.13 patched branch you shared, and specify some arbitrary path for --with-framework-name to place the Python.framework build for visionOS.

You can use any recent 3.13 release as the build python - the official rc2 binaries are fine (and are what the Makefile in this repo defaults to).

Adding a new OS to the list on L36 of the makefile, plus the corresponding TARGETS- and VERSION_MIN- definitions should be all you need to get the Python-Apple-support Makefile to trigger a build for that platform. The only question then is whether there is a need for any additional autoconf overrides.

Does that sound okay so far? Let me know if I'm on the right track.

Broadly, yes; however, my first suggestion would be to get familiar with how configure.ac, configure, and Makefile work in the CPython repo itself, on a “vanilla” macOS build. It’s a lot easier to work out what is going on when you don’t have cross-platform issues to deal with; but once you’ve got those fundamentals in place, fitting cross-compilation into the picture will be easier. The CPython dev guide (https://devguide.python.org) may be helpful here.

@rmartin16
Copy link
Member

2. I wasn't aware that there was going to be an rc3. I took 5 minutes to check if this information was public, but it doesn't seem to be. Hopefully someone is assigned to update PEP 719, but it's alright if that's low priority.

The RC3 decision that was made late Friday afternoon as the core team sprint was wrapping up. I imagine PEP 719 will be updated as soon as everyone returns from their various flights. I believe the plan is to cut the release on Monday.

FYI: Thomas made an announcement on Discourse.

@sheikheddy
Copy link

@rmartin16 Thanks for the link to Discourse. I made an account and just caught up on the historical PEP 730 discussions from last year, which was very helpful reading (even though some of it may be out of date by now due to more recent changes).

@freakboy3742 I appreciate the suggestion to check out the devguide! The background I was looking for was at https://devguide.python.org/getting-started/setup-building/#regenerate-configure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features.
Projects
None yet
Development

No branches or pull requests

4 participants