From ecdf642aa76a15aa868cbfa07d560b8560a8c5ec Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Wed, 26 Mar 2025 22:34:44 +0530 Subject: [PATCH 1/5] Add tests for mlc-scripts installation --- .github/workflows/test-mlc-script-pip.yml | 59 +++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/test-mlc-script-pip.yml diff --git a/.github/workflows/test-mlc-script-pip.yml b/.github/workflows/test-mlc-script-pip.yml new file mode 100644 index 000000000..6e93af9c5 --- /dev/null +++ b/.github/workflows/test-mlc-script-pip.yml @@ -0,0 +1,59 @@ +name: Test pip installation for mlc-script + +on: + pull_request: + branches: [ "main", "dev" ] + paths: + - '.github/workflows/test-mlc-script-pip.yml' + - '**' + - '!**.md' + +jobs: + test_mlc_script_install_pypi: + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: ["3.12", "3.8"] + os: ["ubuntu-latest", "windows-latest", "macos-latest"] + exclude: + - os: windows-latest + - os: macos-latest + + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: install mlc-scripts + run: | + pip install mlc-scripts + - name: run detect-os script + run: | + mlcr detect-os -j + + test_mlc_script_install_pull_request_source: + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: ["3.12", "3.8"] + os: ["ubuntu-latest", "windows-latest", "macos-latest"] + exclude: + - os: windows-latest + - os: macos-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: install mlc-scripts from source repo + run: | + pip install . + - name: run detect-os script + run: | + mlcr detect-os -j From 48f01153ac45bdcbb94f9427abe6ed9d389412f5 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Wed, 26 Mar 2025 22:40:55 +0530 Subject: [PATCH 2/5] fix reading the pyproject.toml --- setup.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 0ba25f32d..1b402af26 100644 --- a/setup.py +++ b/setup.py @@ -21,20 +21,21 @@ def get_project_meta(file_path="pyproject.toml"): dict: Dictionary containing the project metadata. """ try: - with open(file_path, "rb") as f: + with open(file_path, "r") as f: + content_tmp = f.read() if 'tomllib' in globals(): - project_data = tomllib.load(f) # Use tomllib for Python 3.11+ + project_data = tomllib.loads(content_tmp) # Use tomllib for Python 3.11+ else: - project_data = toml.load(f) # Use toml for older versions + project_data = toml.loads(content_tmp) # Use toml for older versions # Extract metadata under [project] project_meta = project_data.get("project", {}) return project_meta except FileNotFoundError: - print(f"Error: {file_path} not found.") + raise FileNotFoundError(f"Error: {file_path} not found.") except Exception as e: - print(f"Error reading {file_path}: {e}") + raise RuntimeError(f"Error reading {file_path}: {e}") return {} @@ -77,9 +78,9 @@ def run(self): 'branch': branch, # 'checkout': commit_hash }) - print(res) + if res['return'] > 0: - return res['return'] + return Exception(f"Return code:{res['return']} with error:{res.get('error')}") # subprocess.run(["echo", "Custom command executed!"], check=True) except Exception as e: From 4d23ca5b4eba527b488796d2d7d633615af1c41c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 26 Mar 2025 17:11:07 +0000 Subject: [PATCH 3/5] [Automated Commit] Format Codebase [skip ci] --- setup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 1b402af26..2649a3b42 100644 --- a/setup.py +++ b/setup.py @@ -24,9 +24,11 @@ def get_project_meta(file_path="pyproject.toml"): with open(file_path, "r") as f: content_tmp = f.read() if 'tomllib' in globals(): - project_data = tomllib.loads(content_tmp) # Use tomllib for Python 3.11+ + # Use tomllib for Python 3.11+ + project_data = tomllib.loads(content_tmp) else: - project_data = toml.loads(content_tmp) # Use toml for older versions + # Use toml for older versions + project_data = toml.loads(content_tmp) # Extract metadata under [project] project_meta = project_data.get("project", {}) @@ -78,9 +80,10 @@ def run(self): 'branch': branch, # 'checkout': commit_hash }) - + if res['return'] > 0: - return Exception(f"Return code:{res['return']} with error:{res.get('error')}") + return Exception( + f"Return code:{res['return']} with error:{res.get('error')}") # subprocess.run(["echo", "Custom command executed!"], check=True) except Exception as e: From 1ea4cfa1b183fe5ddba3a7786b316d38b9564675 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Wed, 26 Mar 2025 22:42:32 +0530 Subject: [PATCH 4/5] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2649a3b42..952cbb79a 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ def get_project_meta(file_path="pyproject.toml"): def check_prerequisites(): - """Check if Git and python-venv are installed on the system.""" + """Check if Git and python-venv are installed on the system. """ try: # Check for Git subprocess.run(["git", "--version"], check=True, From 3b1359114ceb00c960bde324535455391a493a32 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Wed, 26 Mar 2025 22:52:03 +0530 Subject: [PATCH 5/5] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 952cbb79a..311c51537 100644 --- a/setup.py +++ b/setup.py @@ -82,7 +82,7 @@ def run(self): }) if res['return'] > 0: - return Exception( + raise Exception( f"Return code:{res['return']} with error:{res.get('error')}") # subprocess.run(["echo", "Custom command executed!"], check=True)