From 267337bd7b0c04e2772fd4a76f5d3105ffba1516 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Mon, 1 Jul 2024 14:20:58 -0700 Subject: [PATCH] use uv instead of pip everywhere --- mypy_primer/model.py | 20 ++++++++++++++------ mypy_primer/projects.py | 16 ++++++++-------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/mypy_primer/model.py b/mypy_primer/model.py index 9129760..4c40b56 100644 --- a/mypy_primer/model.py +++ b/mypy_primer/model.py @@ -27,7 +27,7 @@ class Project: mypy_cmd: str pyright_cmd: str | None - pip_cmd: str | None = None + install_cmd: str | None = None deps: list[str] | None = None needs_mypy_plugins: bool = False @@ -54,8 +54,8 @@ def __repr__(self) -> str: result += f", name_override={self.name_override!r}" if self.pyright_cmd: result += f", pyright_cmd={self.pyright_cmd!r}" - if self.pip_cmd: - result += f", pip_cmd={self.pip_cmd!r}" + if self.install_cmd: + result += f", install_cmd={self.install_cmd!r}" if self.deps: result += f", deps={self.deps!r}" if self.needs_mypy_plugins: @@ -119,11 +119,19 @@ async def setup(self) -> None: ) assert repo_dir == ctx.get().projects_dir / self.name await self.venv.make_venv() - if self.pip_cmd: - assert "{pip}" in self.pip_cmd + if self.install_cmd: + assert "{install}" in self.install_cmd try: + if has_uv(): + install_cmd = self.install_cmd.format( + install=f"uv pip install --python {quote_path(self.venv.python)}" + ) + else: + install_cmd = self.install_cmd.format( + install=f"{quote_path(self.venv.python)} -m pip install" + ) await run( - self.pip_cmd.format(pip=quote_path(self.venv.script("pip"))), + install_cmd, shell=True, cwd=repo_dir, output=True, diff --git a/mypy_primer/projects.py b/mypy_primer/projects.py index f598066..98c2587 100644 --- a/mypy_primer/projects.py +++ b/mypy_primer/projects.py @@ -86,7 +86,7 @@ def get_projects() -> list[Project]: location="https://github.com/psf/black", mypy_cmd="{mypy} src", pyright_cmd="{pyright} src", - deps=["aiohttp", "click", "pathspec", "tomli", "platformdirs"], + deps=["aiohttp", "click", "pathspec", "tomli", "platformdirs", "packaging"], expected_mypy_success=True, ), Project( @@ -129,7 +129,7 @@ def get_projects() -> list[Project]: mypy_cmd="{mypy} aiohttp", pyright_cmd="{pyright} aiohttp", deps=["pytest"], - pip_cmd="AIOHTTP_NO_EXTENSIONS=1 {pip} install -e .", + install_cmd="AIOHTTP_NO_EXTENSIONS=1 {install} -e .", expected_mypy_success=True, supported_platforms=["linux", "darwin"], ), @@ -767,7 +767,7 @@ def get_projects() -> list[Project]: location="https://github.com/pyppeteer/pyppeteer", mypy_cmd="{mypy} pyppeteer --config-file tox.ini", pyright_cmd="{pyright}", - pip_cmd="{pip} install .", + install_cmd="{install} .", ), Project( location="https://github.com/pypa/pip", @@ -904,9 +904,9 @@ def get_projects() -> list[Project]: location="https://github.com/common-workflow-language/schema_salad", mypy_cmd="MYPYPATH=$MYPYPATH:mypy-stubs {mypy} schema_salad", pyright_cmd=None, - pip_cmd=( - "{pip} install $(grep -v mypy mypy-requirements.txt) -r test-requirements.txt" - " -rrequirements.txt" + install_cmd=( + "{install} $(grep -v mypy mypy-requirements.txt)" + " -r requirements.txt" ), expected_mypy_success=True, supported_platforms=["linux", "darwin"], @@ -915,7 +915,7 @@ def get_projects() -> list[Project]: location="https://github.com/common-workflow-language/cwltool", mypy_cmd="MYPYPATH=$MYPYPATH:mypy-stubs {mypy} cwltool tests/*.py setup.py", pyright_cmd=None, - pip_cmd="{pip} install $(grep -v mypy mypy-requirements.txt) -r test-requirements.txt", + install_cmd="{install} $(grep -v mypy mypy-requirements.txt) -r requirements.txt", expected_mypy_success=True, cost={"mypy": 15}, supported_platforms=["linux", "darwin"], @@ -1005,7 +1005,7 @@ def get_projects() -> list[Project]: "MYPYPATH=$MYPYPATH:misc/python {mypy} --explicit-package-bases ci misc/python" ), pyright_cmd="{pyright}", - pip_cmd="{pip} install -r ci/builder/requirements.txt", + install_cmd="{install} -r ci/builder/requirements.txt", cost={"mypy": 20}, ), Project(