Skip to content

Commit

Permalink
improve mypyc build
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Oct 24, 2024
1 parent 17dd6bc commit d1e847e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions mypy_primer/type_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,21 @@ async def pip_install(*targets: str) -> None:
repo_dir = await ensure_repo_at_revision(repo, mypy_dir, revision_like)
if mypyc_compile_level is not None:
env = os.environ.copy()
env["MYPYC_OPT_LEVEL"] = str(mypyc_compile_level)
await pip_install("typing_extensions", "mypy_extensions")
env["MYPY_USE_MYPYC"] = "1"
env["MYPYC_OPT_LEVEL"] = str(mypyc_compile_level) # can be zero
await pip_install("typing_extensions", "mypy_extensions", "tomli", "types-psutil", "types-setuptools")
await run(
[str(venv.python), "setup.py", "--use-mypyc", "build_ext", "--inplace"],
[str(venv.python), "-m", "pip", "install", ".", "--no-build-isolation"],
cwd=repo_dir,
env=env,
)
targets = []
if editable:
targets.append("--editable")
targets.append(str(repo_dir))
targets.append("tomli")
await pip_install(*targets)
else:
targets = []
if editable:
targets.append("--editable")
targets.append(str(repo_dir))
targets.append("tomli")
await pip_install(*targets)

with open(venv.site_packages / "primer_plugin.pth", "w") as f:
# pth file that lets us let mypy import plugins from another venv
Expand Down

0 comments on commit d1e847e

Please sign in to comment.