From 913c4bfc54df34b9f600dcc1ee0611803be43694 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Tue, 5 Dec 2023 09:46:13 +0200 Subject: [PATCH 01/21] initial implementation --- mxpy-up.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mxpy-up.py b/mxpy-up.py index 8cfacc3e..195ea44c 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -189,6 +189,21 @@ def install_mxpy(exact_version: str, from_branch: str, verbose: bool): st = os.stat(shortcut_path) os.chmod(shortcut_path, st.st_mode | stat.S_IEXEC) + update_shortcut_path = sdk_path / "mxpy-update" + + try: + update_shortcut_path.unlink() + logger.debug(f"Removed existing shortcut: {update_shortcut_path}") + except FileNotFoundError: + logger.debug(f"Shortcut does not exist yet: {update_shortcut_path}") + pass + + update_shortcut_content = get_mxpy_update_shortcut_content() + update_shortcut_path.write_text(update_shortcut_content) + + st = os.stat(update_shortcut_path) + os.chmod(update_shortcut_path, st.st_mode | stat.S_IEXEC) + logger.info("You have successfully installed mxpy.") @@ -206,6 +221,19 @@ def get_mxpy_shortcut_content(): """ +def get_mxpy_update_shortcut_content(): + # operating_system = get_operating_system() + + # if operating_system == "windows": + # return f"""#!/bin/sh + # . "{venv_path / 'Scripts' / 'activate'}" && python3 -m multiversx_sdk_cli.cli "$@" && deactivate + # """ + + return f"""#!/bin/sh +wget -O ~/mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/main/mxpy-up.py && python3 mxpy-up.py "$@" +""" + + def run_in_venv(args: List[str], venv_path: Path, verbose: bool): env = os.environ.copy() From 6a6bb9b32aaed0cc196629fe15725d49c35464a8 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Tue, 5 Dec 2023 10:56:34 +0200 Subject: [PATCH 02/21] fix auto-update on linux --- mxpy-up.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxpy-up.py b/mxpy-up.py index 195ea44c..891b71f4 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -230,7 +230,7 @@ def get_mxpy_update_shortcut_content(): # """ return f"""#!/bin/sh -wget -O ~/mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/main/mxpy-up.py && python3 mxpy-up.py "$@" +wget -O ~/mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/main/mxpy-up.py && python3 ~/mxpy-up.py "$@" """ From 8f85c522eac3378afda6fdcbade89f7001d9d915 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Tue, 5 Dec 2023 12:18:27 +0200 Subject: [PATCH 03/21] add update command on windows --- mxpy-up.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mxpy-up.py b/mxpy-up.py index 891b71f4..556b2402 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -222,12 +222,12 @@ def get_mxpy_shortcut_content(): def get_mxpy_update_shortcut_content(): - # operating_system = get_operating_system() + operating_system = get_operating_system() - # if operating_system == "windows": - # return f"""#!/bin/sh - # . "{venv_path / 'Scripts' / 'activate'}" && python3 -m multiversx_sdk_cli.cli "$@" && deactivate - # """ + if operating_system == "windows": + return f"""#!/bin/sh +curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/main/mxpy-up.py && python mxpy-up.py %* +""" return f"""#!/bin/sh wget -O ~/mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/main/mxpy-up.py && python3 ~/mxpy-up.py "$@" From 6d2ba3d71f251446d2fc2d35822368a6df2d2ae3 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 13:12:00 +0200 Subject: [PATCH 04/21] add auto-update workflow for ubuntu --- .github/workflows/auto-update-ubuntu.yml | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/auto-update-ubuntu.yml diff --git a/.github/workflows/auto-update-ubuntu.yml b/.github/workflows/auto-update-ubuntu.yml new file mode 100644 index 00000000..dd9590d0 --- /dev/null +++ b/.github/workflows/auto-update-ubuntu.yml @@ -0,0 +1,35 @@ +name: Auto-Update mxpy (Ubuntu) + +on: + pull_request: + branches: [main, feat/*] + workflow_dispatch: + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + +jobs: + install: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [3.11] + + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install + run: | + wget -O mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/$BRANCH_NAME/mxpy-up.py + python3 mxpy-up.py --exact-version=9.0.0 --not-interactive + - name: Smoke test + run: | + export PATH="~/multiversx-sdk:${PATH}" + mxpy --version + - name: Auto-Update + run: | + mxpy-update + mxpy --version From cd6529a8141d9e253f12a433d1c616871f469327 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 13:25:35 +0200 Subject: [PATCH 05/21] get file from current branch (testing) --- mxpy-up.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxpy-up.py b/mxpy-up.py index 556b2402..b7b7c591 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -230,7 +230,7 @@ def get_mxpy_update_shortcut_content(): """ return f"""#!/bin/sh -wget -O ~/mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/main/mxpy-up.py && python3 ~/mxpy-up.py "$@" +wget -O ~/mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py && python3 ~/mxpy-up.py "$@" """ From a1403e00b015b877d006618a04cd774ae2254c31 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 13:35:25 +0200 Subject: [PATCH 06/21] testing #2 --- .github/workflows/auto-update-ubuntu.yml | 1 + mxpy-up.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-update-ubuntu.yml b/.github/workflows/auto-update-ubuntu.yml index dd9590d0..a14431e2 100644 --- a/.github/workflows/auto-update-ubuntu.yml +++ b/.github/workflows/auto-update-ubuntu.yml @@ -25,6 +25,7 @@ jobs: run: | wget -O mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/$BRANCH_NAME/mxpy-up.py python3 mxpy-up.py --exact-version=9.0.0 --not-interactive + cat mxpy-up.py - name: Smoke test run: | export PATH="~/multiversx-sdk:${PATH}" diff --git a/mxpy-up.py b/mxpy-up.py index b7b7c591..4a9a6f2a 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -230,7 +230,7 @@ def get_mxpy_update_shortcut_content(): """ return f"""#!/bin/sh -wget -O ~/mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py && python3 ~/mxpy-up.py "$@" +wget -O mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py && python3 mxpy-up.py "$@" """ From 9177ee9a17861296a4ad9d0993a78c19138330fe Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 13:45:26 +0200 Subject: [PATCH 07/21] restart user session after installing --- .github/workflows/auto-update-ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-update-ubuntu.yml b/.github/workflows/auto-update-ubuntu.yml index a14431e2..361e0c05 100644 --- a/.github/workflows/auto-update-ubuntu.yml +++ b/.github/workflows/auto-update-ubuntu.yml @@ -25,12 +25,12 @@ jobs: run: | wget -O mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/$BRANCH_NAME/mxpy-up.py python3 mxpy-up.py --exact-version=9.0.0 --not-interactive - cat mxpy-up.py - name: Smoke test run: | export PATH="~/multiversx-sdk:${PATH}" mxpy --version - name: Auto-Update run: | + . ~/.profile mxpy-update mxpy --version From 544e7b0961c9cc9180cd2f75b12111d3ebbcc632 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 13:49:18 +0200 Subject: [PATCH 08/21] export path --- .github/workflows/auto-update-ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-update-ubuntu.yml b/.github/workflows/auto-update-ubuntu.yml index 361e0c05..8af4a8a0 100644 --- a/.github/workflows/auto-update-ubuntu.yml +++ b/.github/workflows/auto-update-ubuntu.yml @@ -31,6 +31,6 @@ jobs: mxpy --version - name: Auto-Update run: | - . ~/.profile + export PATH="~/multiversx-sdk:${PATH}" mxpy-update mxpy --version From ec737969b2f36740de5f771256ed6195ef6fcd09 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 13:51:56 +0200 Subject: [PATCH 09/21] add flag for installer --- mxpy-up.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxpy-up.py b/mxpy-up.py index 4a9a6f2a..c718c5a7 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -230,7 +230,7 @@ def get_mxpy_update_shortcut_content(): """ return f"""#!/bin/sh -wget -O mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py && python3 mxpy-up.py "$@" +wget -O mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py && python3 mxpy-up.py --not-interactive "$@" """ From bbea24864a513e68c4a45083f982b524f700bd86 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 14:46:01 +0200 Subject: [PATCH 10/21] auto-update workflow for windows --- .github/workflows/auto-update-windows.yml | 39 +++++++++++++++++++++++ mxpy-up.py | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/auto-update-windows.yml diff --git a/.github/workflows/auto-update-windows.yml b/.github/workflows/auto-update-windows.yml new file mode 100644 index 00000000..68f7869e --- /dev/null +++ b/.github/workflows/auto-update-windows.yml @@ -0,0 +1,39 @@ +name: Auto-Update mxpy (Windows) + +on: + pull_request: + branches: [main, feat/*] + workflow_dispatch: + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + +jobs: + install: + runs-on: windows-2019 + + strategy: + matrix: + python-version: [3.11] + + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install + shell: bash + run: | + curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/$BRANCH_NAME/mxpy-up.py + python3 mxpy-up.py --exact-versin=9.0.0 --not-interactive + - name: Smoke test + shell: bash + run: | + export PATH="~/multiversx-sdk:${PATH}" + mxpy --version + - name: Auto-Update + shell: bash + run: | + export PATH="~/multiversx-sdk:${PATH}" + mxpy-update + mxpy --version diff --git a/mxpy-up.py b/mxpy-up.py index c718c5a7..0f0c84bd 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -226,7 +226,7 @@ def get_mxpy_update_shortcut_content(): if operating_system == "windows": return f"""#!/bin/sh -curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/main/mxpy-up.py && python mxpy-up.py %* +curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py && python mxpy-up.py --not-interactive %* """ return f"""#!/bin/sh From af98e24bafb71c6f8a555056effc51b55b1cefc6 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 14:47:18 +0200 Subject: [PATCH 11/21] fix typo --- .github/workflows/auto-update-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-update-windows.yml b/.github/workflows/auto-update-windows.yml index 68f7869e..04288880 100644 --- a/.github/workflows/auto-update-windows.yml +++ b/.github/workflows/auto-update-windows.yml @@ -25,7 +25,7 @@ jobs: shell: bash run: | curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/$BRANCH_NAME/mxpy-up.py - python3 mxpy-up.py --exact-versin=9.0.0 --not-interactive + python3 mxpy-up.py --exact-version=9.0.0 --not-interactive - name: Smoke test shell: bash run: | From 5ac8b35d9faec7c1afa68c06af34ba17342f9e59 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 14:56:26 +0200 Subject: [PATCH 12/21] auto-update for windows (take 2) --- mxpy-up.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mxpy-up.py b/mxpy-up.py index 0f0c84bd..8aa8f7fd 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -226,7 +226,9 @@ def get_mxpy_update_shortcut_content(): if operating_system == "windows": return f"""#!/bin/sh -curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py && python mxpy-up.py --not-interactive %* +set "python_script=%~dp0mxpy-up.py" +curl.exe --output "%python_script%" --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py +python "%python_script%" --not-interactive %* """ return f"""#!/bin/sh From b09c132f0334d9826e2a1cf8f85c1e443ce36fb4 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 15:01:15 +0200 Subject: [PATCH 13/21] auto-update on windows (take 3) --- mxpy-up.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mxpy-up.py b/mxpy-up.py index 8aa8f7fd..1893b8d3 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -226,9 +226,8 @@ def get_mxpy_update_shortcut_content(): if operating_system == "windows": return f"""#!/bin/sh -set "python_script=%~dp0mxpy-up.py" -curl.exe --output "%python_script%" --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py -python "%python_script%" --not-interactive %* +curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py +python mxpy-up.py --not-interactive %* """ return f"""#!/bin/sh From a7b9d9765dcbd175692b4bd7a3f00bad0134d8f2 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 15:05:01 +0200 Subject: [PATCH 14/21] remove args --- mxpy-up.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxpy-up.py b/mxpy-up.py index 1893b8d3..57e64ded 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -227,7 +227,7 @@ def get_mxpy_update_shortcut_content(): if operating_system == "windows": return f"""#!/bin/sh curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py -python mxpy-up.py --not-interactive %* +python mxpy-up.py --not-interactive* """ return f"""#!/bin/sh From 85abc1bc32608981fa727cdc53e4f4ad058d07e5 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 15:08:51 +0200 Subject: [PATCH 15/21] fix typo --- mxpy-up.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxpy-up.py b/mxpy-up.py index 57e64ded..c7e50af7 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -227,7 +227,7 @@ def get_mxpy_update_shortcut_content(): if operating_system == "windows": return f"""#!/bin/sh curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py -python mxpy-up.py --not-interactive* +python mxpy-up.py --not-interactive """ return f"""#!/bin/sh From 12582fc9b7b46299fac421b7f4622145db5a5d14 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 15:55:52 +0200 Subject: [PATCH 16/21] echo cd --- .github/workflows/auto-update-ubuntu.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/auto-update-ubuntu.yml b/.github/workflows/auto-update-ubuntu.yml index 8af4a8a0..efbc49f3 100644 --- a/.github/workflows/auto-update-ubuntu.yml +++ b/.github/workflows/auto-update-ubuntu.yml @@ -23,6 +23,8 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install run: | + echo "cd:" + echo %cd% wget -O mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/$BRANCH_NAME/mxpy-up.py python3 mxpy-up.py --exact-version=9.0.0 --not-interactive - name: Smoke test @@ -31,6 +33,7 @@ jobs: mxpy --version - name: Auto-Update run: | + echo %cd% export PATH="~/multiversx-sdk:${PATH}" mxpy-update mxpy --version From 7c5f0a10bbc096aebeb87577bbb8045927d1388f Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 15:58:57 +0200 Subject: [PATCH 17/21] echo cd in correct file --- .github/workflows/auto-update-ubuntu.yml | 3 --- .github/workflows/auto-update-windows.yml | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto-update-ubuntu.yml b/.github/workflows/auto-update-ubuntu.yml index efbc49f3..8af4a8a0 100644 --- a/.github/workflows/auto-update-ubuntu.yml +++ b/.github/workflows/auto-update-ubuntu.yml @@ -23,8 +23,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install run: | - echo "cd:" - echo %cd% wget -O mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/$BRANCH_NAME/mxpy-up.py python3 mxpy-up.py --exact-version=9.0.0 --not-interactive - name: Smoke test @@ -33,7 +31,6 @@ jobs: mxpy --version - name: Auto-Update run: | - echo %cd% export PATH="~/multiversx-sdk:${PATH}" mxpy-update mxpy --version diff --git a/.github/workflows/auto-update-windows.yml b/.github/workflows/auto-update-windows.yml index 04288880..e354c239 100644 --- a/.github/workflows/auto-update-windows.yml +++ b/.github/workflows/auto-update-windows.yml @@ -24,6 +24,8 @@ jobs: - name: Install shell: bash run: | + echo "cd:" + echo %cd% curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/$BRANCH_NAME/mxpy-up.py python3 mxpy-up.py --exact-version=9.0.0 --not-interactive - name: Smoke test @@ -34,6 +36,8 @@ jobs: - name: Auto-Update shell: bash run: | + echo "cd:" + echo %cd% export PATH="~/multiversx-sdk:${PATH}" mxpy-update mxpy --version From 774e15ef711d31b5388425e82f7676fe833e74dc Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 16:47:47 +0200 Subject: [PATCH 18/21] use chmod --- .github/workflows/auto-update-windows.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/auto-update-windows.yml b/.github/workflows/auto-update-windows.yml index e354c239..a97b000f 100644 --- a/.github/workflows/auto-update-windows.yml +++ b/.github/workflows/auto-update-windows.yml @@ -24,8 +24,6 @@ jobs: - name: Install shell: bash run: | - echo "cd:" - echo %cd% curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/$BRANCH_NAME/mxpy-up.py python3 mxpy-up.py --exact-version=9.0.0 --not-interactive - name: Smoke test @@ -36,8 +34,7 @@ jobs: - name: Auto-Update shell: bash run: | - echo "cd:" - echo %cd% export PATH="~/multiversx-sdk:${PATH}" + chmod +x mxpy-update mxpy-update mxpy --version From 321a904eae67900f4bdb415dcb614d12cc8d5a8e Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Dec 2023 16:57:20 +0200 Subject: [PATCH 19/21] try to set permission for file --- .github/workflows/auto-update-windows.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-update-windows.yml b/.github/workflows/auto-update-windows.yml index a97b000f..8c6e82c4 100644 --- a/.github/workflows/auto-update-windows.yml +++ b/.github/workflows/auto-update-windows.yml @@ -35,6 +35,8 @@ jobs: shell: bash run: | export PATH="~/multiversx-sdk:${PATH}" - chmod +x mxpy-update + user=$(whoami) + echo $user + chmod +x C:\\Users\\${user}\\multiversx-sdk\\mxpy-update mxpy-update mxpy --version From 37b7a4ccd703e4b515ac6be683ae56ff6b0b52ba Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Fri, 8 Dec 2023 11:27:59 +0200 Subject: [PATCH 20/21] add file extension for windows --- .github/workflows/auto-update-windows.yml | 3 --- mxpy-up.py | 17 +++++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/auto-update-windows.yml b/.github/workflows/auto-update-windows.yml index 8c6e82c4..04288880 100644 --- a/.github/workflows/auto-update-windows.yml +++ b/.github/workflows/auto-update-windows.yml @@ -35,8 +35,5 @@ jobs: shell: bash run: | export PATH="~/multiversx-sdk:${PATH}" - user=$(whoami) - echo $user - chmod +x C:\\Users\\${user}\\multiversx-sdk\\mxpy-update mxpy-update mxpy --version diff --git a/mxpy-up.py b/mxpy-up.py index c7e50af7..99e54233 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -183,13 +183,17 @@ def install_mxpy(exact_version: str, from_branch: str, verbose: bool): logger.debug(f"Shortcut does not exist yet: {shortcut_path}") pass - shortcut_content = get_mxpy_shortcut_content() + operating_system = get_operating_system() + shortcut_content = get_mxpy_shortcut_content(operating_system) shortcut_path.write_text(shortcut_content) st = os.stat(shortcut_path) os.chmod(shortcut_path, st.st_mode | stat.S_IEXEC) - update_shortcut_path = sdk_path / "mxpy-update" + if operating_system == "windows": + update_shortcut_path = sdk_path / "mxpy-update.exe" + else: + update_shortcut_path = sdk_path / "mxpy-update" try: update_shortcut_path.unlink() @@ -198,7 +202,7 @@ def install_mxpy(exact_version: str, from_branch: str, verbose: bool): logger.debug(f"Shortcut does not exist yet: {update_shortcut_path}") pass - update_shortcut_content = get_mxpy_update_shortcut_content() + update_shortcut_content = get_mxpy_update_shortcut_content(operating_system) update_shortcut_path.write_text(update_shortcut_content) st = os.stat(update_shortcut_path) @@ -207,8 +211,7 @@ def install_mxpy(exact_version: str, from_branch: str, verbose: bool): logger.info("You have successfully installed mxpy.") -def get_mxpy_shortcut_content(): - operating_system = get_operating_system() +def get_mxpy_shortcut_content(operating_system: str): venv_path = get_mxpy_venv_path() if operating_system == "windows": @@ -221,9 +224,7 @@ def get_mxpy_shortcut_content(): """ -def get_mxpy_update_shortcut_content(): - operating_system = get_operating_system() - +def get_mxpy_update_shortcut_content(operating_system: str): if operating_system == "windows": return f"""#!/bin/sh curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py From 35891ed1a715db626733b8792a5bf353c556d2e8 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Fri, 8 Dec 2023 14:52:07 +0200 Subject: [PATCH 21/21] code cleanup --- .github/workflows/auto-update-windows.yml | 39 ----------------------- mxpy-up.py | 11 +------ 2 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 .github/workflows/auto-update-windows.yml diff --git a/.github/workflows/auto-update-windows.yml b/.github/workflows/auto-update-windows.yml deleted file mode 100644 index 04288880..00000000 --- a/.github/workflows/auto-update-windows.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Auto-Update mxpy (Windows) - -on: - pull_request: - branches: [main, feat/*] - workflow_dispatch: - -env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - -jobs: - install: - runs-on: windows-2019 - - strategy: - matrix: - python-version: [3.11] - - steps: - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install - shell: bash - run: | - curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/$BRANCH_NAME/mxpy-up.py - python3 mxpy-up.py --exact-version=9.0.0 --not-interactive - - name: Smoke test - shell: bash - run: | - export PATH="~/multiversx-sdk:${PATH}" - mxpy --version - - name: Auto-Update - shell: bash - run: | - export PATH="~/multiversx-sdk:${PATH}" - mxpy-update - mxpy --version diff --git a/mxpy-up.py b/mxpy-up.py index 99e54233..316c3b7e 100644 --- a/mxpy-up.py +++ b/mxpy-up.py @@ -190,10 +190,7 @@ def install_mxpy(exact_version: str, from_branch: str, verbose: bool): st = os.stat(shortcut_path) os.chmod(shortcut_path, st.st_mode | stat.S_IEXEC) - if operating_system == "windows": - update_shortcut_path = sdk_path / "mxpy-update.exe" - else: - update_shortcut_path = sdk_path / "mxpy-update" + update_shortcut_path = sdk_path / "mxpy-update" try: update_shortcut_path.unlink() @@ -225,12 +222,6 @@ def get_mxpy_shortcut_content(operating_system: str): def get_mxpy_update_shortcut_content(operating_system: str): - if operating_system == "windows": - return f"""#!/bin/sh -curl.exe --output mxpy-up.py --url https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py -python mxpy-up.py --not-interactive -""" - return f"""#!/bin/sh wget -O mxpy-up.py https://raw.githubusercontent.com/multiversx/mx-sdk-py-cli/mxpy-update/mxpy-up.py && python3 mxpy-up.py --not-interactive "$@" """