From 7cdcf908438fd1e8b2370624ec80a9ee44a597ec Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 18 Oct 2023 14:55:03 -0700 Subject: [PATCH] Get mypy passing under Windows (#58) Closes #56 --- .github/workflows/ci.yml | 7 +++++-- microvenv/__main__.py | 8 ++++---- microvenv/__main__.pyi | 0 microvenv/_create.pyi | 10 ++++------ pyproject.toml | 4 ++-- tests/conftest.py | 5 ++++- 6 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 microvenv/__main__.pyi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c287b05..dfed6ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: ["ubuntu", "macos", "windows"] - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 @@ -20,7 +20,10 @@ jobs: # 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. lint: - runs-on: "ubuntu-latest" + runs-on: ${{ matrix.os }}-latest + strategy: + matrix: + os: ["ubuntu", "windows"] # Due to having different APIs. steps: - uses: actions/checkout@v3 diff --git a/microvenv/__main__.py b/microvenv/__main__.py index faa0527..a26368d 100644 --- a/microvenv/__main__.py +++ b/microvenv/__main__.py @@ -1,10 +1,10 @@ import sys -if sys.platform == "win32": - print("Microvenv's CLI is not supported on Windows", file=sys.stderr) - sys.exit(1) - from ._create import main if __name__ == "__main__": + if sys.platform == "win32": + print("Microvenv's CLI is not supported on Windows", file=sys.stderr) + sys.exit(1) + main() diff --git a/microvenv/__main__.pyi b/microvenv/__main__.pyi new file mode 100644 index 0000000..e69de29 diff --git a/microvenv/_create.pyi b/microvenv/_create.pyi index 6926ece..fa1b966 100644 --- a/microvenv/_create.pyi +++ b/microvenv/_create.pyi @@ -1,11 +1,9 @@ from os import PathLike -import sys from typing import Iterable DEFAULT_ENV_DIR: str -if sys.platform != "win32": - def create( - env_dir: str | PathLike[str] = ..., *, scm_ignore_files=Iterable[str] - ) -> None: ... - def main() -> None: ... +def create( + env_dir: str | PathLike[str] = ..., *, scm_ignore_files=Iterable[str] +) -> None: ... +def main() -> None: ... diff --git a/pyproject.toml b/pyproject.toml index d87f641..ca25e20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,14 +5,14 @@ build-backend = "hatchling.build" [project] name = "microvenv" -version = "2023.4" +version = "2023.5" description = "A minimal re-implementation of Python's venv module plus utilities" keywords = ["virtual environments", "venv"] readme = "README.md" license = { file = "LICENSE" } maintainers = [{ name = "Brett Cannon", email = "brett@python.org" }] authors = [{ name = "Brett Cannon", email = "brett@python.org" }] -requires-python = ">=3.7" +requires-python = ">=3.8" classifiers = [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", diff --git a/tests/conftest.py b/tests/conftest.py index ac04523..072619e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,6 +14,9 @@ def executable(): @pytest.fixture(scope="session") def full_venv(tmp_path_factory): """Create a virtual environment via venv.""" + symlinks = sys.platform != "win32" venv_path = tmp_path_factory.mktemp("venvs") / "full_venv" - venv.create(venv_path, symlinks=True, with_pip=False, system_site_packages=False) + venv.create( + venv_path, symlinks=symlinks, with_pip=False, system_site_packages=False + ) return venv_path