Skip to content

Commit

Permalink
use uv instead of pip everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Jul 1, 2024
1 parent 1e7407a commit 267337b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
20 changes: 14 additions & 6 deletions mypy_primer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions mypy_primer/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"],
),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"],
Expand All @@ -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"],
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 267337b

Please sign in to comment.