diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..40d9d2c --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,63 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python application + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: astral-sh/setup-uv + # You may pin to the exact commit or the version. + # uses: astral-sh/setup-uv@887a942a15af3a7626099df99e897a18d9e5ab3a + uses: astral-sh/setup-uv@v5.1.0 + with: + # The version of uv to install + #version: # optional, default is latest + # The version of Python to set UV_PYTHON to + python-version: 3.10.6 + # The checksum of the uv version to install + #checksum: # optional + # Used to increase the rate limit when retrieving versions and downloading uv. + #github-token: # optional, default is ${{ github.token }} + # Enable caching of the uv cache + #enable-cache: # optional, default is auto + # Glob pattern to match files relative to the repository root to control the cache. + #cache-dependency-glob: # optional, default is **/uv.lock **/requirements*.txt + + # Suffix for the cache key + #cache-suffix: # optional + # Local path to store the cache. + #cache-local-path: # optional, default is + # Prune cache before saving. + #prune-cache: # optional, default is true + # Ignore when nothing is found to cache. + #ignore-nothing-to-cache: # optional, default is false + # Custom path to set UV_TOOL_DIR to. + #tool-dir: # optional + # Custom path to set UV_TOOL_BIN_DIR to. + #tool-bin-dir: # optional + - name: Install Dependencies + # Need to run lock or else it also tries to install Windows dependencies + run: | + uv lock + uv sync + - name: Test with pytest + run: | + uv run pytest tests diff --git a/pyproject.toml b/pyproject.toml index fc2608b..fdef273 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,9 +11,8 @@ dependencies = [ "attrs>=24.3.0", "pillow>=11.1.0", "pyuac>=0.0.3", - "pywin32>=308", "pywin32>=308 ; sys_platform == 'win32'", - "pywinpty>=2.0.14", + "pywinpty>=2.0.14 ; sys_platform == 'win32'", "sv-ttk>=2.6.0", "tk>=0.1.0", ] diff --git a/src/msix_global_installer/msix.py b/src/msix_global_installer/msix.py index 41571ce..9eb493f 100644 --- a/src/msix_global_installer/msix.py +++ b/src/msix_global_installer/msix.py @@ -1,13 +1,16 @@ from dataclasses import dataclass from math import ceil from msix_global_installer import events -from winpty import PtyProcess import logging import os import pathlib import re import xml.etree.ElementTree as ET import zipfile +import sys + +if sys.platform == "win32": + from winpty import PtyProcess logger = logging.getLogger(__name__) diff --git a/tests/test_msix.py b/tests/test_msix.py index d13f39e..11db8b1 100644 --- a/tests/test_msix.py +++ b/tests/test_msix.py @@ -16,11 +16,6 @@ def test_get_msix_metadata(self, tmpdir): assert data.publisher == 'Contoso Corporation' assert data.package_path == path - def test_install(self): - """Test we can install with a subprocess.""" - path = pathlib.Path("tests/TestMsixPackage.msix") - msix.install_msix(path) - def test_count_percentage(self): """Test we can count the progress.""" test_start = r" [ ] \r\n" diff --git a/uv.lock b/uv.lock index c9af7e5..b392bf7 100644 --- a/uv.lock +++ b/uv.lock @@ -79,8 +79,8 @@ dependencies = [ { name = "attrs" }, { name = "pillow" }, { name = "pyuac" }, - { name = "pywin32" }, - { name = "pywinpty" }, + { name = "pywin32", marker = "sys_platform == 'win32'" }, + { name = "pywinpty", marker = "sys_platform == 'win32'" }, { name = "sv-ttk" }, { name = "tk" }, ] @@ -97,9 +97,8 @@ requires-dist = [ { name = "attrs", specifier = ">=24.3.0" }, { name = "pillow", specifier = ">=11.1.0" }, { name = "pyuac", specifier = ">=0.0.3" }, - { name = "pywin32", specifier = ">=308" }, { name = "pywin32", marker = "sys_platform == 'win32'", specifier = ">=308" }, - { name = "pywinpty", specifier = ">=2.0.14" }, + { name = "pywinpty", marker = "sys_platform == 'win32'", specifier = ">=2.0.14" }, { name = "sv-ttk", specifier = ">=2.6.0" }, { name = "tk", specifier = ">=0.1.0" }, ]