Skip to content

Commit 9f8cbd6

Browse files
committed
Compile all Python files
1 parent 4d40ceb commit 9f8cbd6

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## 0.1.3
22

33
* Add app's path to `PYTHONPATH`.
4-
* Compile Python app to bytecode.
4+
* Compile Python app to a bytecode.
5+
* Compile Python system standard libraries to a bytecode.
56

67
## 0.1.2
78

example/flask_example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ EXTERNAL SOURCES:
2222
SPEC CHECKSUMS:
2323
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
2424
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
25-
serious_python: 11f4ce79371037a06e96c78c8ed9b30cd7d0b6f7
25+
serious_python: b60f5767ef0da134102ba0ca241e59ca11b889ce
2626

2727
PODFILE CHECKSUM: 7be2f5f74864d463a8ad433546ed1de7e0f29aef
2828

ios/serious_python.podspec

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Pod::Spec.new do |s|
3939
tar -xzf $PYTHON_DIST_FILE
4040
rm $PYTHON_DIST_FILE
4141
fi
42+
ROOT=`pwd`
4243
rm -rf #{python_framework}
4344
mkdir -p #{python_framework}
4445
cp -R pod_templates/Python.xcframework/* #{python_framework}
@@ -47,17 +48,29 @@ Pod::Spec.new do |s|
4748
cp -R dist/root/python3/include/python3.10/* #{python_framework}/ios-arm64/Headers
4849
cp -R dist/root/python3/include/python3.10/* #{python_framework}/ios-arm64_x86_64-simulator/Headers
4950
51+
# compile python310.zip
52+
PYTHON310_ZIP=$ROOT/dist/root/python3/lib/python310.zip
53+
unzip $PYTHON310_ZIP -d python310_temp
54+
rm $PYTHON310_ZIP
55+
pushd python310_temp
56+
$ROOT/dist/hostpython3/bin/python -m compileall -b .
57+
find . \\( -name '*.so' -or -name '*.py' -or -name '*.typed' \\) -type f -delete
58+
zip -r $PYTHON310_ZIP .
59+
popd
60+
rm -rf python310_temp
61+
5062
# fix import subprocess, asyncio
5163
cp -R pod_templates/site-packages/* dist/root/python3/lib/python3.10/site-packages
5264
5365
# zip site-packages
5466
pushd dist/root/python3/lib/python3.10/site-packages
55-
zip -r ../../site-packages.zip .
67+
$ROOT/dist/hostpython3/bin/python -m compileall -b .
68+
find . \\( -name '*.so' -or -name '*.py' -or -name '*.typed' \\) -type f -delete
69+
zip -r $ROOT/dist/root/python3/lib/site-packages.zip .
5670
popd
57-
rm -rf dist/root/python3/lib/python3.10
58-
71+
5972
# remove junk
60-
rm -rf dist/root/python3/lib/python3.10/config-3.10-darwin
73+
rm -rf dist/root/python3/lib/python3.10
6174
CMD
6275

6376
s.libraries = 'z', 'bz2', 'c++', 'sqlite3'

0 commit comments

Comments
 (0)