From 4d8ccde513ba2d951b766e72eff4352949d9a437 Mon Sep 17 00:00:00 2001 From: Abdullah Alfaraj <7842232+AbdullahAlfaraj@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:42:05 +0300 Subject: [PATCH] =?UTF-8?q?Reverted=20httpx=20to=20version=200.24.1=20to?= =?UTF-8?q?=20address=20the=20=E2=80=98socket=5Foptions=E2=80=99=20issue.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.py | 61 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/install.py b/install.py index 2121db60..6c94cfc7 100644 --- a/install.py +++ b/install.py @@ -19,18 +19,27 @@ print("[Auto-Photoshop-SD] Attempting auto-update...") try: + checkout_result = run( + f'"{git}" -C "{REPO_LOCATION}" checkout {extension_branch}', + "[Auto-Photoshop-SD] switch branch to extension branch.", + ) + print("checkout_result:", checkout_result) - checkout_result = run(f'"{git}" -C "{REPO_LOCATION}" checkout {extension_branch}', "[Auto-Photoshop-SD] switch branch to extension branch.") - print("checkout_result:",checkout_result) + branch_result = run( + f'"{git}" -C "{REPO_LOCATION}" branch', + "[Auto-Photoshop-SD] Current Branch.", + ) + print("branch_result:", branch_result) - branch_result = run(f'"{git}" -C "{REPO_LOCATION}" branch', "[Auto-Photoshop-SD] Current Branch.") - print("branch_result:",branch_result) + fetch_result = run( + f'"{git}" -C "{REPO_LOCATION}" fetch', "[Auto-Photoshop-SD] Fetch upstream." + ) + print("fetch_result:", fetch_result) - fetch_result = run(f'"{git}" -C "{REPO_LOCATION}" fetch', "[Auto-Photoshop-SD] Fetch upstream.") - print("fetch_result:",fetch_result) - - pull_result = run(f'"{git}" -C "{REPO_LOCATION}" pull', "[Auto-Photoshop-SD] Pull upstream.") - print("pull_result:",pull_result) + pull_result = run( + f'"{git}" -C "{REPO_LOCATION}" pull', "[Auto-Photoshop-SD] Pull upstream." + ) + print("pull_result:", pull_result) except Exception as e: print("[Auto-Photoshop-SD] Auto-update failed:") @@ -39,15 +48,27 @@ # print("Auto-Photoshop-SD plugin is installing") +import pkg_resources + + +def install_or_update_package(package_name, package_version): + if not launch.is_installed(package_name): + launch.run_pip( + f"install {package_name}=={package_version}", + "requirements for Auto-Photoshop Image Search", + ) + else: # it's installed but we need to check for update + version = pkg_resources.get_distribution(package_name).version + if version != package_version: + print( + f"{package_name} version: {version} will update to version: {package_version}" + ) + launch.run_pip( + f"install {package_name}=={package_version}", + "update requirements for Auto-Photoshop Image Search", + ) + -package_name = 'duckduckgo_search' -package_version= '3.9.9' -if not launch.is_installed(package_name): - launch.run_pip(f"install {package_name}=={package_version}", "requirements for Auto-Photoshop Image Search") -else:# it's installed but we need to check for update - import pkg_resources - - version = pkg_resources.get_distribution(package_name).version - if(version != package_version): - print(f'{package_name} version: {version} will update to version: {package_version}') - launch.run_pip(f"install {package_name}=={package_version}", "update requirements for Auto-Photoshop Image Search") +# Now we can use this function to install or update the packages +install_or_update_package("duckduckgo_search", "3.9.9") +install_or_update_package("httpx", "0.24.1")