Skip to content

Commit a041905

Browse files
authored
Remove some useless PATHs in Usage.md (#284)
Updated example configuration to remove paths implied by a normal PYTHONHOME configuration.
1 parent 6583edf commit a041905

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

USAGE.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ guides:
2323
* [iOS](https://docs.python.org/3/using/ios.html#adding-python-to-an-ios-project)
2424

2525
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.
2828

2929
### Using Objective C
3030

@@ -45,19 +45,15 @@ As a *bare minimum*, you can do the following:
4545
```objc
4646
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
4747
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];
5048
NSString *appPath = [NSString stringWithFormat:@"%@/app", resourcePath, nil];
5149

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);
5452

5553
Py_Initialize();
5654

5755
// we now have a Python interpreter ready to be used
5856
```
59-
References to a specific Python version should reflect the version of
60-
Python you are using.
6157
6258
Again - this is the *bare minimum* initialization. In practice, you will likely
6359
need to configure other aspects of the Python interpreter using the
@@ -81,12 +77,10 @@ code will look something like this:
8177
2. Initialize the Python interpreter:
8278
```swift
8379
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 }
8680
let appPath = Bundle.main.path(forResource: "app", ofType: nil)
8781

8882
setenv("PYTHONHOME", pythonHome, 1)
89-
setenv("PYTHONPATH", [pythonPath, libDynloadPath, appPath].compactMap { $0 }.joined(separator: ":"), 1)
83+
setenv("PYTHONPATH", appPath, 1)
9084
Py_Initialize()
9185
// we now have a Python interpreter ready to be used
9286
```

0 commit comments

Comments
 (0)