From 7f19683b88e821bb64913a67fedc6c16b3096f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Tue, 20 Feb 2024 13:33:38 -0800 Subject: [PATCH] Support Windows (#19) --- .github/workflows/check.yml | 29 +++++++++++++++++++++-------- src/tox_uv/_venv.py | 12 ++++++------ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 7a3e034..592bff2 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -27,7 +27,7 @@ jobs: - "3.8" os: - ubuntu-latest -# - windows-latest + - windows-latest - macos-latest steps: - name: setup python for tox @@ -35,12 +35,25 @@ jobs: with: python-version: "3.12" - uses: actions/checkout@v4 - - name: Install uv - run: python -m pip install uv - - name: Uninstall pip - run: python -m pip uninstall pip -y - - name: Active uv for global env - run: echo "VIRTUAL_ENV=${Python_ROOT_DIR}" >> $GITHUB_ENV + - name: Set up Python ${{ matrix.py }} on ${{ matrix.os }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.py }} + allow-prereleases: true + - name: Create and activate a virtual environment (Windows) + if: ${{ runner.os == 'Windows' }} + run: | + irm https://astral.sh/uv/install.ps1 | iex + uv venv .venv + "VIRTUAL_ENV=.venv" | Out-File -FilePath $env:GITHUB_ENV -Append + "$PWD/.venv/Scripts" | Out-File -FilePath $env:GITHUB_PATH -Append + - name: Create and activate a virtual environment (Unix) + if: ${{ runner.os != 'Windows' }} + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + uv venv .venv + echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV + echo "$PWD/.venv/bin" >> $GITHUB_PATH - name: Install self run: uv pip install tox-uv@. - name: setup python for test ${{ matrix.py }} @@ -56,7 +69,7 @@ jobs: file_handler.write(env) shell: python - name: setup test suite - run: tox -vv --notest + run: tox -vvvv --notest - name: run test suite run: tox --skip-pkg-install diff --git a/src/tox_uv/_venv.py b/src/tox_uv/_venv.py index 2a322b8..cf7e1f2 100644 --- a/src/tox_uv/_venv.py +++ b/src/tox_uv/_venv.py @@ -127,8 +127,8 @@ def prepend_env_var_path(self) -> list[Path]: def env_bin_dir(self) -> Path: if sys.platform == "win32": # pragma: win32 cover return self.venv_dir / "Scripts" - # pragma: win32 no cover - return self.venv_dir / "bin" + else: # pragma: win32 no cover # noqa: RET505 + return self.venv_dir / "bin" def env_python(self) -> Path: suffix = ".exe" if sys.platform == "win32" else "" @@ -137,10 +137,10 @@ def env_python(self) -> Path: def env_site_package_dir(self) -> Path: if sys.platform == "win32": # pragma: win32 cover return self.venv_dir / "Lib" / "site-packages" - # pragma: win32 no cover - assert self.base_python.version_info.major is not None # noqa: S101 - assert self.base_python.version_info.minor is not None # noqa: S101 - return self.venv_dir / "lib" / f"python{self.base_python.version_dot}" / "site-packages" + else: # pragma: win32 no cover # noqa: RET505 + assert self.base_python.version_info.major is not None # noqa: S101 + assert self.base_python.version_info.minor is not None # noqa: S101 + return self.venv_dir / "lib" / f"python{self.base_python.version_dot}" / "site-packages" __all__ = [