From 7b9ca8aff40eda2495a130453b8586646398d157 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 11 Oct 2023 18:36:09 -0700 Subject: [PATCH] Add support for Windows (except for `create()`) (#55) Also add Python 3.12 support. Closes #46 --- .github/workflows/ci.yml | 9 ++++++--- docs/api.rst | 2 ++ docs/cli.rst | 2 ++ microvenv/__init__.py | 4 +++- microvenv/__init__.pyi | 2 -- microvenv/_create.pyi | 10 ++++++---- noxfile.py | 2 +- tests/test_cli.py | 4 ++++ tests/test_create.py | 3 +++ 9 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db38435..c287b05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,12 +7,15 @@ jobs: runs-on: ${{ matrix.os }}-latest strategy: matrix: - os: ["ubuntu", "macos"] + os: ["ubuntu", "macos", "windows"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 - - uses: wntrblm/nox@main - - run: nox -s test + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - run: pipx run nox -s test-${{ matrix.python-version }} # Set up as a separate job for a very small amount of parallelism and to # avoid running multiple times under each OS like we do for testing. diff --git a/docs/api.rst b/docs/api.rst index a4366e3..f1f528e 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -25,3 +25,5 @@ API Analogous to calling :py:func:`venv.create` as ``venv.create(..., symlinks=True, with_pip=False)``. + + .. note:: Not available on Windows. diff --git a/docs/cli.rst b/docs/cli.rst index acaa239..ab4ee95 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -1,5 +1,7 @@ CLI ==== +.. note:: Not available on Windows. + .. include:: help.txt :literal: diff --git a/microvenv/__init__.py b/microvenv/__init__.py index 7ea281d..9d39b67 100644 --- a/microvenv/__init__.py +++ b/microvenv/__init__.py @@ -4,7 +4,9 @@ # Exported as part of the public API. from ._create import DEFAULT_ENV_DIR as DEFAULT_ENV_DIR -from ._create import create as create + +if sys.platform != "win32": + from ._create import create as create # https://docs.python.org/3/library/venv.html#how-venvs-work IN_VIRTUAL_ENV = sys.prefix != sys.base_prefix diff --git a/microvenv/__init__.pyi b/microvenv/__init__.pyi index 5612712..5e9e574 100644 --- a/microvenv/__init__.pyi +++ b/microvenv/__init__.pyi @@ -3,8 +3,6 @@ from typing import TypedDict IN_VIRTUAL_ENV: bool -DEFAULT_ENV_DIR: str - class ActivationError(Exception): ... def parse_config(env_dir: str | PathLike[str]) -> dict[str, str]: ... diff --git a/microvenv/_create.pyi b/microvenv/_create.pyi index fa1b966..6926ece 100644 --- a/microvenv/_create.pyi +++ b/microvenv/_create.pyi @@ -1,9 +1,11 @@ from os import PathLike +import sys from typing import Iterable DEFAULT_ENV_DIR: str -def create( - env_dir: str | PathLike[str] = ..., *, scm_ignore_files=Iterable[str] -) -> None: ... -def main() -> None: ... +if sys.platform != "win32": + def create( + env_dir: str | PathLike[str] = ..., *, scm_ignore_files=Iterable[str] + ) -> None: ... + def main() -> None: ... diff --git a/noxfile.py b/noxfile.py index 7a41bed..0a3350e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -4,7 +4,7 @@ import nox # type: ignore -@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"]) +@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]) def test(session): session.install(".[test]") session.run("pytest") diff --git a/tests/test_cli.py b/tests/test_cli.py index 31ae935..f1eaaf2 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,10 +1,14 @@ import os import subprocess +import sys import pytest import microvenv +if sys.platform == "win32": + pytest.skip("Windows is not supported.", allow_module_level=True) + @pytest.fixture def CLI(executable): diff --git a/tests/test_create.py b/tests/test_create.py index 1bf6fea..352ce5c 100644 --- a/tests/test_create.py +++ b/tests/test_create.py @@ -8,6 +8,9 @@ import microvenv import microvenv._create +if sys.platform == "win32": + pytest.skip("Windows is not supported.", allow_module_level=True) + @pytest.fixture def base_executable():