Skip to content

Commit c570d18

Browse files
committed
extract Swift packages
1 parent abe4809 commit c570d18

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

Package.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ let package = Package(
1414
dependencies: [
1515
// Dependencies declare other packages that this package depends on.
1616
// .package(url: /* package url */, from: "1.0.0"),
17-
.package(url: "https://github.com/rderik/Csqlite3", .branch("master")),
1817
],
1918
targets: [
2019
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
2120
// Targets can depend on other targets in this package, and on products in packages this package depends on.
2221
.target(name: "PythonKit", dependencies: [
23-
"CPython", "BZip2", "OpenSSL", "XZ",
24-
.product(name: "Csqlite3", package: "Csqlite3")]),
22+
"CPython", "BZip2", "OpenSSL", "XZ"]),
2523
.binaryTarget(name: "CPython", path: "Frameworks/CPython.xcframework"),
2624
.binaryTarget(name: "BZip2", path: "Frameworks/BZip2.xcframework"),
2725
.binaryTarget(name: "OpenSSL", path: "Frameworks/OpenSSL.xcframework"),

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
11
# Python-iOS
22

3-
A description of this package.
3+
This swift package enables you to use python modules in your iOS apps.
4+
5+
## Installation
6+
7+
```
8+
.package(url: "https://github.com/kewlbear/Python-iOS.git", from: "0.0.1")
9+
```
10+
11+
## Usage
12+
13+
```
14+
import CPython
15+
import Resources
16+
17+
setenv("PYTHONOPTIMIZE", "1", 1)
18+
setenv("PYTHONDONTWRITEBYTECODE", "1", 1)
19+
setenv("PYTHONUNBUFFERED", "1", 1)
20+
21+
guard let pythonHome = Resources.libURL?
22+
.deletingLastPathComponent()
23+
.path else { fatalError() }
24+
let wHome = Py_DecodeLocale(pythonHome, nil)
25+
Py_SetPythonHome(wHome)
26+
27+
setenv("PYTHONPATH",
28+
FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].path,
29+
1)
30+
31+
setenv("TMP", NSTemporaryDirectory(), 1)
32+
33+
Py_Initialize()
34+
```
35+
36+
## Credits
37+
38+
This package uses pre-built version of libraries downloaded from https://github.com/beeware/Python-Apple-support.
39+
40+
## License
41+
42+
MIT

0 commit comments

Comments
 (0)