You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-3Lines changed: 10 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -268,8 +268,6 @@ Also, the size of one variable had to be changed from int to long to make the co
268
268
269
269
### Calling Assembly from Python
270
270
271
-
Note that as of this writing, all Python IDEs for macOS attempt to load x86\_64 libraries, even when the app itself is universal. So currently the only way to run the sample is on the command line. Also, as of macOS 12.3, Apple [removed Python 2](https://developer.apple.com/documentation/macos-release-notes/macos-12_3-release-notes), and developers should use Python 3.
272
-
273
271
### Listing 9-9
274
272
275
273
While the `uppertst5.py` file only needed a minimal change, calling the code is a little more challenging. On Apple Silicon Macs, Python is a Mach-O universal binary with two architectures, x86\_64 and arm64e:
@@ -287,15 +285,24 @@ So, what to do? We could compile everything as arm64e, but that would make the l
287
285
288
286
Above, you read something about a _universal binary_. For a very long time, the Mach-O executable format was supporting several processor architectures in a single file. This includes, but is not limited to, Motorola 68k (on NeXT computers), PowerPC, Intel x86, as well ARM code, each with their 32 and 64 bit variantes where applicable. In this case, I am building a universal dynamic library which includes both arm64 and arm64e code. More information can be found [here](https://developer.apple.com/documentation/xcode/building_a_universal_macos_binary).
289
287
290
-
As mentioned above, no currently available Python IDE on macOS will load the ARM64 library, so use the command line to run your code:
288
+
While most of the Python IDEs that work for Linux are also avilable for macOS, as of this writing, the only Python IDEs which itself runs as arm64 — and thus will load arm64 libraries — is Python.org [IDLE](https://www.python.org/downloads/macos/), version 3.10 or newer.
289
+
290
+

291
+
292
+
***Figure 9-1.****Our Python program running in the IDLE IDE*
291
293
294
+
Alternatively, you can use the command line to test the program. (As of macOS 12.3, Apple [removed Python 2](https://developer.apple.com/documentation/macos-release-notes/macos-12_3-release-notes) and developers should use Python 3)
295
+
292
296
```
293
297
% python3 uppertst5.py
294
298
b'This is a test!'
295
299
b'THIS IS A TEST!'
296
300
16
297
301
```
298
302
303
+
A final note: While the Apple python3 binary is arm64e, the Python Framework used by IDLE is arm64. The fact that the library built in this chapter is a universal binary containing both architectures allows it to be used in either environment.
304
+
305
+
299
306
## Chapter 10: Interfacing with Kotlin and Swift
300
307
301
308
No changes in the core code were required, but instead of just an iOS app I created a SwiftUI app that will work on macOS, iOS, watchOS (Series 4 and later), and tvOS.
0 commit comments