Skip to content

Commit 19fcf31

Browse files
authored
Merge pull request below#35 from below/PythonIDE_Update
Chapter 9: The Phython.org IDLE can be used to test the library
2 parents 5b4fe5b + eb3686e commit 19fcf31

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@ Also, the size of one variable had to be changed from int to long to make the co
268268

269269
### Calling Assembly from Python
270270

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-
273271
### Listing 9-9
274272

275273
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
287285

288286
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).
289287

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+
![Figure 9-1. . Our Python program running in the IDLE IDE](images/Figure_9-1.png?raw=true "Our Python program running in the IDLE IDE")
291+
292+
***Figure 9-1.*** *Our Python program running in the IDLE IDE*
291293

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+
292296
```
293297
% python3 uppertst5.py
294298
b'This is a test!'
295299
b'THIS IS A TEST!'
296300
16
297301
```
298302

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+
299306
## Chapter 10: Interfacing with Kotlin and Swift
300307

301308
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.

images/Figure_9-1.png

69.6 KB
Loading

0 commit comments

Comments
 (0)