Skip to content

Commit a9374ff

Browse files
committed
prepare release
1 parent 5adb5e7 commit a9374ff

File tree

7 files changed

+91
-41
lines changed

7 files changed

+91
-41
lines changed

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020 Changbeom Ahn
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

Package.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
// swift-tools-version:5.3
2-
// The swift-tools-version declares the minimum version of Swift required to build this package.
32

43
import PackageDescription
54

65
let package = Package(
76
name: "Python-iOS",
7+
platforms: [.iOS(.v9)],
88
products: [
9-
// Products define the executables and libraries a package produces, and make them visible to other packages.
109
.library(
1110
name: "Python-iOS",
1211
targets: ["Symbols", "Python", "BZip2", "OpenSSL", "XZ", "Resources"]),
1312
],
1413
dependencies: [
15-
// Dependencies declare other packages that this package depends on.
16-
// .package(url: /* package url */, from: "1.0.0"),
1714
.package(url: "https://github.com/alloyapple/CSqlite3.git", .branch("master")),
1815
],
1916
targets: [

README.md

+2-23
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,11 @@ This swift package enables you to use python modules in your iOS apps.
1010

1111
## Usage
1212

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-
```
13+
See https://github.com/kewlbear/YoutubeDL.
3514

3615
## Credits
3716

38-
This package uses pre-built version of libraries downloaded from https://github.com/beeware/Python-Apple-support.
17+
This package uses pre-built version of Python downloaded from https://github.com/beeware/Python-Apple-support.
3918

4019
## License
4120

Sources/Resources/Resources.swift

+26-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
//
22
// Resources.swift
3-
//
43
//
5-
// Created by 안창범 on 2020/11/11.
4+
// Copyright (c) 2020 Changbeom Ahn
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
623
//
724

825
import Foundation
@@ -15,11 +32,7 @@ public func Init() {
1532
setenv("PYTHONDONTWRITEBYTECODE", "1", 1)
1633
setenv("PYTHONUNBUFFERED", "1", 1)
1734

18-
guard let pythonHome = Resources.libURL?
19-
.deletingLastPathComponent()
20-
.path else { fatalError() }
21-
let wHome = Py_DecodeLocale(pythonHome, nil)
22-
Py_SetPythonHome(wHome)
35+
SetPythonHome()
2336

2437
setenv("PYTHONPATH",
2538
FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].path,
@@ -29,3 +42,9 @@ public func Init() {
2942

3043
Py_Initialize()
3144
}
45+
46+
public func SetPythonHome() {
47+
let pythonHome = Bundle.module.bundleURL.path
48+
let wHome = Py_DecodeLocale(pythonHome, nil)
49+
Py_SetPythonHome(wHome)
50+
}

Sources/Symbols/Symbols.m

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
//
22
// Symbols.m
3-
//
43
//
5-
// Created by 안창범 on 2020/11/18.
4+
// Copyright (c) 2020 Changbeom Ahn
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
623
//
724

825
#import "Symbols.h"

Sources/Symbols/include/Symbols.h

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
//
22
// Symbols.h
3-
//
43
//
5-
// Created by 안창범 on 2020/11/18.
4+
// Copyright (c) 2020 Changbeom Ahn
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
623
//
724

825
#ifndef Symbols_h

Tests/PythonTests/PythonTests.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import XCTest
2-
@testable import Symbols
2+
@testable import Resources
33

44
final class PythonTests: XCTestCase {
55
func testExample() {
6-
let x = _Py_True
7-
PyNumber_Add(nil, nil)
6+
Init()
87
}
98

109
static var allTests = [

0 commit comments

Comments
 (0)