typemytype / drawbot

http://www.drawbot.com
Other
393 stars 61 forks source link

Upgrading to Python 3.12 and building a universal app (Intel + Apple Silicon) #560

Closed justvanrossum closed 5 months ago

justvanrossum commented 6 months ago

The build works on both Intel and Apple Silicon: https://github.com/typemytype/drawbot/actions/runs/7681596610

import sys, platform
print(sys.version)
print(platform.platform())

Intel:

3.12.1 (v3.12.1:2305ca5144, Dec  7 2023, 17:23:39) [Clang 13.0.0 (clang-1300.0.29.30)]
macOS-14.2.1-x86_64-i386-64bit

Apple Silicon:

3.12.1 (v3.12.1:2305ca5144, Dec  7 2023, 17:23:38) [Clang 13.0.0 (clang-1300.0.29.30)]
macOS-14.2.1-arm64-arm-64bit
justvanrossum commented 6 months ago

gif and mp4 export work, but the embedded tools are still Intel. We should track down Universal builds for ffmpeg, gifsicle, potrace, etc.

justvanrossum commented 6 months ago

If it wasn't for PIL, DrawBot would still run on macOS 10.10...

3.12.1 (v3.12.1:2305ca5144, Dec  7 2023, 17:23:39) [Clang 13.0.0 (clang-1300.0.29.30)]
macOS-10.10.5-x86_64-i386-64bit

I'm trying to find out what it is lowest macOS that current PIL/Pillow is expected to run on: https://github.com/python-pillow/Pillow/issues/6862#issuecomment-1913552472

justvanrossum commented 6 months ago

With Pillow 10.1.0, DrawBot actually works on macOS 10.10: image

justvanrossum commented 6 months ago

Hm, this seems an official source for ffmpeg, and they don't seem to intend to provide Apple Silicon binaries: https://evermeet.cx/ffmpeg/apple-silicon-arm

Tangentially, I found this blog post that shows how to speed up h264 encoding on Apple Silicon: https://www.learnwithjason.dev/blog/hardware-acceleration-ffmpeg-apple-silicon/

typemytype commented 6 months ago

super mega cool!!

that statement related to ffmpeg seems not sustainable in the long run... there will be no intel mac in a few years...

a quick test leads to this error, it will not be the only one I guess:

from fontTools import bezierTools
Traceback (most recent call last):
  File "<untitled>", line 1, in <module>
ImportError: cannot import name 'bezierTools' from 'fontTools' (/private/var/folders/qy/sv345q756dg_jsx6jg2tf6240000gn/T/AppTranslocation/874D5ABD-17F6-463E-9CCB-6A63FAA449DB/d/DrawBot.app/Contents/Resources/lib/python3.12/fontTools/__init__.py)

this happens cause pip checks the arch, you force the arch somewhere, if I remember it correctly

justvanrossum commented 6 months ago

a quick test leads to this error

Argh yes, it is because if x84 and universal2 wheels are available, it picks x84 :(

We may have to work around it with a script downloading wheels from pypi directly.

justvanrossum commented 6 months ago

that statement related to ffmpeg seems not sustainable in the long run

Interesting (and sad) to see that providing binaries for this hugely successful tool seems to depend on one guy...

justvanrossum commented 6 months ago

I think this may be a possible approach:

justvanrossum commented 6 months ago

I think this may be a possible approach

I did that and it seems to work correctly on M123 and Intel, down to macOS 10.10:

justvanrossum commented 6 months ago

@typemytype, this is ready for review/merge.