Skip to content

Commit 5aeebdf

Browse files
Linux ARM64 support for Flet runner app (#189)
* Build on ARM64 * Disable python stack * python_stack * Build all * Simplify binaries download * Update flet.py * Fix artifact deployment name
1 parent 47935c1 commit 5aeebdf

File tree

3 files changed

+80
-69
lines changed

3 files changed

+80
-69
lines changed

.appveyor.yml

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ skip_commits:
1111
environment:
1212
GO_VERSION: 1.19
1313
GO_TAGS: --tags release
14-
python_version: 3.10
14+
python_stack: python 3.10
1515
GITHUB_TOKEN:
1616
secure: doX0dwjWhBmT56aJqR9NCbtMFJpDpdYxPCIB4vQoHfSR+nTa+pLCo6Yv5qWpD/90
1717
DOCKER_REGISTRY_USER:
@@ -32,6 +32,11 @@ environment:
3232
job_group: build_flet
3333
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
3434

35+
- job_name: Build Flet for Linux ARM64
36+
job_group: build_flet
37+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004-arm
38+
python_stack: ""
39+
3540
- job_name: Build Flet for iOS
3641
job_group: build_flet
3742
APPVEYOR_BUILD_WORKER_IMAGE: macos-monterey
@@ -43,25 +48,25 @@ environment:
4348
- job_name: Test Python 3.7
4449
job_group: python_tests
4550
job_depends_on: build_flet
46-
python_version: 3.7
51+
python_stack: python 3.7
4752
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
4853

4954
- job_name: Test Python 3.8
5055
job_group: python_tests
5156
job_depends_on: build_flet
52-
python_version: 3.8
57+
python_stack: python 3.8
5358
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
5459

5560
- job_name: Test Python 3.9
5661
job_group: python_tests
5762
job_depends_on: build_flet
58-
python_version: 3.9
63+
python_stack: python 3.9
5964
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
6065

6166
- job_name: Test Python 3.10
6267
job_group: python_tests
6368
job_depends_on: build_flet
64-
python_version: 3.10
69+
python_stack: python 3.10
6570
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
6671

6772
- job_name: Build Python wheels
@@ -78,7 +83,7 @@ environment:
7883
matrix:
7984
fast_finish: true
8085

81-
stack: python $python_version
86+
stack: $python_stack
8287

8388
for:
8489
# ======================================
@@ -109,13 +114,13 @@ for:
109114
- dir %RELEASE_DIR%
110115
- ren build\windows\runner\Release flet
111116
- cd build\windows\runner
112-
- 7z a flet.zip flet
117+
- 7z a flet-windows.zip flet
113118
- cd %APPVEYOR_BUILD_FOLDER%
114119

115120
test: off
116121

117122
artifacts:
118-
- path: client\build\windows\runner\flet.zip
123+
- path: client\build\windows\runner\flet-windows.zip
119124
name: flet_windows
120125

121126
deploy:
@@ -149,10 +154,10 @@ for:
149154
- cd client
150155
- flutter test
151156
- flutter build macos
152-
- tar -czvf flet.app.tar.gz -C build/macos/Build/Products/Release Flet.app
157+
- tar -czvf flet-macos-amd64.tar.gz -C build/macos/Build/Products/Release Flet.app
153158

154159
artifacts:
155-
- path: client/flet.app.tar.gz
160+
- path: client/flet-macos-amd64.tar.gz
156161
name: flet_macos
157162

158163
deploy:
@@ -183,17 +188,51 @@ for:
183188
- flutter test
184189
- flutter build linux
185190
- mv build/linux/x64/release/bundle build/linux/x64/release/flet
186-
- tar -czvf flet.tar.gz -C build/linux/x64/release flet
191+
- tar -czvf flet-linux-amd64.tar.gz -C build/linux/x64/release flet
192+
193+
artifacts:
194+
- path: client/flet-linux-amd64.tar.gz
195+
name: flet_linux_amd64
196+
197+
deploy:
198+
provider: GitHub
199+
auth_token: $(GITHUB_TOKEN)
200+
release: $(APPVEYOR_REPO_TAG_NAME)
201+
artifact: flet_linux_amd64
202+
on:
203+
APPVEYOR_REPO_TAG: true
204+
205+
# ======================================
206+
# Build Flet View for Linux ARM64
207+
# ======================================
208+
209+
- matrix:
210+
only:
211+
- job_name: Build Flet for Linux ARM64
212+
213+
install:
214+
# Flutter SDK
215+
- sudo snap install flutter --classic
216+
- flutter channel beta
217+
- flutter upgrade
218+
- flutter sdk-path
219+
220+
build_script:
221+
- cd client
222+
- flutter test
223+
- flutter build linux
224+
- mv build/linux/arm64/release/bundle build/linux/arm64/release/flet
225+
- tar -czvf flet-linux-arm64.tar.gz -C build/linux/arm64/release flet
187226

188227
artifacts:
189-
- path: client/flet.tar.gz
190-
name: flet_linux
228+
- path: client/flet-linux-arm64.tar.gz
229+
name: flet_linux_arm64
191230

192231
deploy:
193232
provider: GitHub
194233
auth_token: $(GITHUB_TOKEN)
195234
release: $(APPVEYOR_REPO_TAG_NAME)
196-
artifact: flet_linux
235+
artifact: flet_linux_arm64
197236
on:
198237
APPVEYOR_REPO_TAG: true
199238

sdk/python/build-wheels.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"fletd_exec": "fletd.exe",
2323
"flet_client_job": "Build Flet for Windows",
2424
"flet_client_artifact": "flet_windows",
25-
"flet_client_filename": "flet.zip",
25+
"flet_client_filename": "flet-windows.zip",
2626
"wheel_tags": ["py3-none-win_amd64"],
2727
"file_suffix": "py3-none-win_amd64",
2828
},
@@ -31,7 +31,7 @@
3131
"fletd_exec": "fletd.exe",
3232
"flet_client_job": "Build Flet for Windows",
3333
"flet_client_artifact": "flet_windows",
34-
"flet_client_filename": "flet.zip",
34+
"flet_client_filename": "flet-windows.zip",
3535
"wheel_tags": ["py3-none-win32"],
3636
"file_suffix": "py3-none-win32",
3737
},
@@ -45,8 +45,8 @@
4545
"fletd_asset": "linux_amd64",
4646
"fletd_exec": "fletd",
4747
"flet_client_job": "Build Flet for Linux",
48-
"flet_client_artifact": "flet_linux",
49-
"flet_client_filename": "flet.tar.gz",
48+
"flet_client_artifact": "flet_linux_amd64",
49+
"flet_client_filename": "flet-linux-amd64.tar.gz",
5050
"wheel_tags": [
5151
"py3-none-manylinux_2_17_x86_64",
5252
"py3-none-manylinux2014_x86_64",
@@ -56,6 +56,9 @@
5656
"Linux arm64": {
5757
"fletd_asset": "linux_arm64",
5858
"fletd_exec": "fletd",
59+
"flet_client_job": "Build Flet for Linux ARM64",
60+
"flet_client_artifact": "flet_linux_arm64",
61+
"flet_client_filename": "flet-linux-arm64.tar.gz",
5962
"wheel_tags": [
6063
"py3-none-manylinux_2_17_aarch64",
6164
"py3-none-manylinux2014_aarch64",
@@ -76,7 +79,7 @@
7679
"fletd_exec": "fletd",
7780
"flet_client_job": "Build Flet for macOS",
7881
"flet_client_artifact": "flet_macos",
79-
"flet_client_filename": "flet.tar.gz",
82+
"flet_client_filename": "flet-macos-amd64.tar.gz",
8083
"wheel_tags": ["py3-none-macosx_10_14_x86_64"],
8184
"file_suffix": "py3-none-macosx_10_14_x86_64",
8285
},
@@ -85,7 +88,7 @@
8588
"fletd_exec": "fletd",
8689
"flet_client_job": "Build Flet for macOS",
8790
"flet_client_artifact": "flet_macos",
88-
"flet_client_filename": "flet.tar.gz",
91+
"flet_client_filename": "flet-macos-amd64.tar.gz",
8992
"wheel_tags": ["py3-none-macosx_12_0_arm64"],
9093
"file_suffix": "py3-none-macosx_12_0_arm64",
9194
},

sdk/python/flet/flet.py

Lines changed: 18 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ def _open_flet_view(page_url):
337337

338338
if is_windows():
339339
flet_exe = "flet.exe"
340+
temp_flet_dir = Path(tempfile.gettempdir()).joinpath(f"flet-{version.version}")
340341

341342
# check if flet_view.exe exists in "bin" directory (user mode)
342343
p = Path(__file__).parent.joinpath("bin", "flet", flet_exe)
@@ -349,7 +350,14 @@ def _open_flet_view(page_url):
349350
if flet_path:
350351
logging.info(f"Flet View found in PATH: {flet_path}")
351352
else:
352-
flet_path = _download_flet_view_windows()
353+
if not temp_flet_dir.exists():
354+
zip_file = _download_flet_client("flet-windows.zip")
355+
356+
logging.info(f"Extracting flet.exe from archive to {temp_flet_dir}")
357+
temp_flet_dir.mkdir(parents=True, exist_ok=True)
358+
with zipfile.ZipFile(zip_file, "r") as zip_arch:
359+
zip_arch.extractall(str(temp_flet_dir))
360+
app_path = temp_flet_dir.joinpath("flet", flet_exe)
353361
args = [flet_path, page_url]
354362
elif is_macos():
355363
# build version-specific path to Flet.app
@@ -358,16 +366,17 @@ def _open_flet_view(page_url):
358366
# check if flet_view.app exists in a temp directory
359367
if not temp_flet_dir.exists():
360368
# check if flet.tar.gz exists
361-
tar_file = Path(__file__).parent.joinpath("bin", "flet.tar.gz")
369+
gz_filename = "flet-macos-amd64.tar.gz"
370+
tar_file = Path(__file__).parent.joinpath("bin", gz_filename)
362371
if not tar_file.exists():
363-
tar_file = _download_flet_view_macos()
372+
tar_file = _download_flet_client(gz_filename)
364373

365374
logging.info(f"Extracting Flet.app from archive to {temp_flet_dir}")
366375
temp_flet_dir.mkdir(parents=True, exist_ok=True)
367376
with tarfile.open(str(tar_file), "r:gz") as tar_arch:
368377
tar_arch.extractall(str(temp_flet_dir))
369378
else:
370-
logging.info(f"Flet View found in PATH: {temp_flet_dir}")
379+
logging.info(f"Flet View found in: {temp_flet_dir}")
371380

372381
app_path = temp_flet_dir.joinpath("Flet.app")
373382
args = ["open", str(app_path), "-W", "--args", page_url]
@@ -378,16 +387,17 @@ def _open_flet_view(page_url):
378387
# check if flet_view.app exists in a temp directory
379388
if not temp_flet_dir.exists():
380389
# check if flet.tar.gz exists
381-
tar_file = Path(__file__).parent.joinpath("bin", "flet.tar.gz")
390+
gz_filename = f"flet-linux-{get_arch()}.tar.gz"
391+
tar_file = Path(__file__).parent.joinpath("bin", gz_filename)
382392
if not tar_file.exists():
383-
tar_file = _download_flet_view_linux()
393+
tar_file = _download_flet_client(gz_filename)
384394

385395
logging.info(f"Extracting Flet from archive to {temp_flet_dir}")
386396
temp_flet_dir.mkdir(parents=True, exist_ok=True)
387397
with tarfile.open(str(tar_file), "r:gz") as tar_arch:
388398
tar_arch.extractall(str(temp_flet_dir))
389399
else:
390-
logging.info(f"Flet View found in PATH: {temp_flet_dir}")
400+
logging.info(f"Flet View found in: {temp_flet_dir}")
391401

392402
app_path = temp_flet_dir.joinpath("flet", "flet")
393403
args = [str(app_path), page_url]
@@ -441,52 +451,11 @@ def _download_fletd():
441451
return str(temp_fletd_dir.joinpath(flet_exe))
442452

443453

444-
def _download_flet_view_windows():
445-
ver = version.version
446-
447-
# build version-specific path to Flet
448-
temp_flet_dir = Path(tempfile.gettempdir()).joinpath(f"flet-{ver}")
449-
450-
if not temp_flet_dir.exists():
451-
print(f"Downloading Flet v{ver} to {temp_flet_dir}")
452-
temp_flet_dir.mkdir(parents=True, exist_ok=True)
453-
file_name = "flet.zip"
454-
flet_url = (
455-
f"https://github.com/flet-dev/flet/releases/download/v{ver}/{file_name}"
456-
)
457-
458-
temp_arch = Path(tempfile.gettempdir()).joinpath(file_name)
459-
try:
460-
urllib.request.urlretrieve(flet_url, temp_arch)
461-
with zipfile.ZipFile(temp_arch, "r") as zip_arch:
462-
zip_arch.extractall(str(temp_flet_dir))
463-
finally:
464-
os.remove(temp_arch)
465-
else:
466-
logging.info(f"Flet v{version.version} is already installed in {temp_flet_dir}")
467-
return str(temp_flet_dir.joinpath("flet", "flet.exe"))
468-
469-
470-
def _download_flet_view_macos():
471-
ver = version.version
472-
473-
file_name = "flet.app.tar.gz"
474-
temp_arch = Path(tempfile.gettempdir()).joinpath(file_name)
475-
print(f"Downloading Flet v{ver} to {temp_arch}")
476-
flet_url = f"https://github.com/flet-dev/flet/releases/download/v{ver}/{file_name}"
477-
478-
urllib.request.urlretrieve(flet_url, temp_arch)
479-
return str(temp_arch)
480-
481-
482-
def _download_flet_view_linux():
454+
def _download_flet_client(file_name):
483455
ver = version.version
484-
485-
file_name = "flet.tar.gz"
486456
temp_arch = Path(tempfile.gettempdir()).joinpath(file_name)
487457
print(f"Downloading Flet v{ver} to {temp_arch}")
488458
flet_url = f"https://github.com/flet-dev/flet/releases/download/v{ver}/{file_name}"
489-
490459
urllib.request.urlretrieve(flet_url, temp_arch)
491460
return str(temp_arch)
492461

0 commit comments

Comments
 (0)