@@ -23,8 +23,8 @@ guides:
23
23
* [ iOS] ( https://docs.python.org/3/using/ios.html#adding-python-to-an-ios-project )
24
24
25
25
For tvOS, watchOS, and visionOS, you should be able to broadly follow the instructions
26
- in the iOS guide. The testbed projects generated on iOS and visionOS may be used as
27
- rough references as well.
26
+ in the iOS guide, changing some platform names in the first script. The testbed projects
27
+ generated on iOS and visionOS may be used as rough references as well.
28
28
29
29
### Using Objective C
30
30
@@ -45,19 +45,15 @@ As a *bare minimum*, you can do the following:
45
45
``` objc
46
46
NSString *resourcePath = [[NSBundle mainBundle ] resourcePath ];
47
47
NSString *pythonHome = [NSString stringWithFormat: @"%@/python", resourcePath, nil] ;
48
- NSString * pythonPath = [ NSString stringWithFormat:@"%@/lib/python3.13", python_home, nil] ;
49
- NSString * libDynloadPath = [ NSString stringWithFormat:@"%@/lib/python3.13/lib-dynload", python_home, nil] ;
50
48
NSString * appPath = [ NSString stringWithFormat:@"%@/app", resourcePath, nil] ;
51
49
52
- setenv ("PYTHONHOME", pythonHome, 1);
53
- setenv ("PYTHONPATH", [ NSString stringWithFormat:@"%@:%@:%@", pythonpath, libDynloadPath, appPath, nil ] );
50
+ setenv ("PYTHONHOME", [ pythonHome UTF8String ] , 1);
51
+ setenv ("PYTHONPATH", [ appPath UTF8String ] , 1 );
54
52
55
53
Py_Initialize ();
56
54
57
55
// we now have a Python interpreter ready to be used
58
56
```
59
- References to a specific Python version should reflect the version of
60
- Python you are using.
61
57
62
58
Again - this is the *bare minimum* initialization. In practice, you will likely
63
59
need to configure other aspects of the Python interpreter using the
@@ -81,12 +77,10 @@ code will look something like this:
81
77
2 . Initialize the Python interpreter:
82
78
``` swift
83
79
guard let pythonHome = Bundle.main.path (forResource : " python" , ofType : nil ) else { return }
84
- guard let pythonPath = Bundle.main.path (forResource : " python/lib/python3.13" , ofType : nil ) else { return }
85
- guard let libDynloadPath = Bundle.main.path (forResource : " python/lib/python3.13/lib-dynload" , ofType : nil ) else { return }
86
80
let appPath = Bundle.main .path (forResource : " app" , ofType : nil )
87
81
88
82
setenv (" PYTHONHOME" , pythonHome, 1 )
89
- setenv (" PYTHONPATH" , [pythonPath, libDynloadPath, appPath]. compactMap { $0 }. joined ( separator : " : " ) , 1 )
83
+ setenv (" PYTHONPATH" , appPath, 1 )
90
84
Py_Initialize ()
91
85
// we now have a Python interpreter ready to be used
92
86
```
0 commit comments