Skip to content

Commit e0bec9d

Browse files
committed
Get rid of distutils to support Python 3.12
Fix #1962
1 parent e19887f commit e0bec9d

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

sdk/python/packages/flet-runtime/src/flet_runtime/utils.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import os
33
import re
4+
import shutil
45
import socket
56
import sys
67
from pathlib import Path
@@ -258,3 +259,25 @@ def patch_manifest_json(
258259

259260
with open(manifest_path, "w") as f:
260261
f.write(json.dumps(manifest, indent=2))
262+
263+
264+
def copy_tree(src, dst):
265+
"""Recursively copy a directory tree using shutil.copy2().
266+
267+
Arguments:
268+
src -- source directory path
269+
dst -- destination directory path
270+
271+
Return a list of files that were copied or might have been copied.
272+
"""
273+
if not os.path.isdir(src):
274+
raise OSError("Source is not a directory")
275+
276+
os.makedirs(dst, exist_ok=True)
277+
for item in os.listdir(src):
278+
s = os.path.join(src, item)
279+
d = os.path.join(dst, item)
280+
if os.path.isdir(s):
281+
copy_tree(s, d)
282+
else:
283+
shutil.copy2(s, d)

sdk/python/packages/flet/src/flet/__pyinstaller/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import os
22
import tempfile
33
import uuid
4-
from distutils.dir_util import copy_tree
54
from pathlib import Path
65

7-
from flet_runtime.utils import get_package_bin_dir
6+
from flet_runtime.utils import copy_tree, get_package_bin_dir
87

98

109
def get_flet_bin_path():

sdk/python/packages/flet/src/flet/cli/commands/publish.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import sys
77
import tarfile
88
import tempfile
9-
from distutils.dir_util import copy_tree
109
from pathlib import Path
1110

1211
from flet.cli.commands.base import BaseCommand
1312
from flet_core.types import WebRenderer
1413
from flet_core.utils import random_string
1514
from flet_runtime.utils import (
15+
copy_tree,
1616
get_package_web_dir,
1717
is_within_directory,
1818
patch_index_html,

0 commit comments

Comments
 (0)