Skip to content

Commit f952f5a

Browse files
authored
Fix Python portability/module dependency issues (#159)
This PR improves Python portability by replacing collections.abc.Iterable with typing.Iterable for better compatibility with older Python 3 versions, and implements lazy imports for server services to eliminate unnecessary transitive dependencies when those services are not used.
1 parent 0e85325 commit f952f5a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lgl_android_install.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@
134134
from lglpy.android.utils import AndroidUtils, NamedTempFile
135135
from lglpy.android.filesystem import AndroidFilesystem
136136
from lglpy.comms import server
137-
from lglpy.comms import service_gpu_timeline
138-
from lglpy.comms import service_gpu_profile
139137
from lglpy.ui import console
140138

141139
# Android 9 is the minimum version supported for our method of enabling layers
@@ -612,10 +610,14 @@ def configure_server(conn: ADBConnect,
612610
instance = server.CommsServer(0)
613611

614612
if timeline_file:
613+
# Import late to avoid pulling in transitive deps when unused
614+
from lglpy.comms import service_gpu_timeline
615615
service_tl = service_gpu_timeline.GPUTimelineService(timeline_file)
616616
instance.register_endpoint(service_tl)
617617

618618
if profile_dir:
619+
# Import late to avoid pulling in transitive deps when unused
620+
from lglpy.comms import service_gpu_profile
619621
service_prof = service_gpu_profile.GPUProfileService(profile_dir)
620622
instance.register_endpoint(service_prof)
621623

lglpy/android/adb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626
line tool which can be used to run commands on a connected Android device.
2727
'''
2828

29-
from collections.abc import Iterable
3029
import os
3130
import shlex
3231
import shutil
3332
import subprocess as sp
34-
from typing import Optional
33+
from typing import Iterable, Optional
3534

3635

3736
class ADBConnect:

0 commit comments

Comments
 (0)