diff --git a/Lib/idlelib/idle.py b/Lib/idlelib/idle.py index 485d5a75a29c1a..95f0ecb6fb6a98 100644 --- a/Lib/idlelib/idle.py +++ b/Lib/idlelib/idle.py @@ -1,14 +1,27 @@ -import os.path +import os import sys +def add_idlelib_to_path(): + """ + Adds the parent directory of the current file's parent directory + to sys.path to allow running IDLE from a non-standard location. + """ + idlelib_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) + if idlelib_dir not in sys.path: + sys.path.insert(0, idlelib_dir) + return idlelib_dir -# Enable running IDLE with idlelib in a non-standard location. -# This was once used to run development versions of IDLE. -# Because PEP 434 declared idle.py a public interface, -# removal should require deprecation. -idlelib_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -if idlelib_dir not in sys.path: - sys.path.insert(0, idlelib_dir) +def main(): + """ + Import and run IDLE's main shell. + """ + add_idlelib_to_path() + try: + from idlelib.pyshell import main as idle_main + except ImportError as e: + print("Could not import idlelib.pyshell:", e) + sys.exit(1) + idle_main() -from idlelib.pyshell import main # This is subject to change -main() +if __name__ == "__main__": + main() diff --git a/README.rst b/README.rst index baea5e0978d8fa..f050e44cb256c2 100644 --- a/README.rst +++ b/README.rst @@ -232,4 +232,4 @@ This Python distribution contains *no* GNU General Public License (GPL) code, so it may be used in proprietary projects. There are interfaces to some GNU code but these are entirely optional. -All trademarks referenced herein are property of their respective holders. \ No newline at end of file +All trademarks referenced herein are property of their respective holders. diff --git a/iOS/testbed/__main__.py b/iOS/testbed/__main__.py index 6a4d9c76d162b4..9862e8d75fe799 100644 --- a/iOS/testbed/__main__.py +++ b/iOS/testbed/__main__.py @@ -99,6 +99,7 @@ def clone_testbed( print(f"{target} already exists; aborting without creating project.") sys.exit(10) + if framework is None: if not ( source / "Python.xcframework/ios-arm64_x86_64-simulator/bin"