Skip to content

Commit

Permalink
Get rid of distutils to support Python 3.12
Browse files Browse the repository at this point in the history
Fix #1962
  • Loading branch information
FeodorFitsner committed Oct 26, 2023
1 parent e19887f commit e0bec9d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
23 changes: 23 additions & 0 deletions sdk/python/packages/flet-runtime/src/flet_runtime/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import re
import shutil
import socket
import sys
from pathlib import Path
Expand Down Expand Up @@ -258,3 +259,25 @@ def patch_manifest_json(

with open(manifest_path, "w") as f:
f.write(json.dumps(manifest, indent=2))


def copy_tree(src, dst):
"""Recursively copy a directory tree using shutil.copy2().
Arguments:
src -- source directory path
dst -- destination directory path
Return a list of files that were copied or might have been copied.
"""
if not os.path.isdir(src):
raise OSError("Source is not a directory")

os.makedirs(dst, exist_ok=True)
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
copy_tree(s, d)
else:
shutil.copy2(s, d)
3 changes: 1 addition & 2 deletions sdk/python/packages/flet/src/flet/__pyinstaller/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import os
import tempfile
import uuid
from distutils.dir_util import copy_tree
from pathlib import Path

from flet_runtime.utils import get_package_bin_dir
from flet_runtime.utils import copy_tree, get_package_bin_dir


def get_flet_bin_path():
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/packages/flet/src/flet/cli/commands/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import sys
import tarfile
import tempfile
from distutils.dir_util import copy_tree
from pathlib import Path

from flet.cli.commands.base import BaseCommand
from flet_core.types import WebRenderer
from flet_core.utils import random_string
from flet_runtime.utils import (
copy_tree,
get_package_web_dir,
is_within_directory,
patch_index_html,
Expand Down

0 comments on commit e0bec9d

Please sign in to comment.