Skip to content

Commit

Permalink
fix: check-project command with reusable venv (#19)
Browse files Browse the repository at this point in the history
* fix(check-project): reuse existing venv from global cache if existing

* docs: the default mypy settings

* bump version to 1.1.2
  • Loading branch information
DavidVujic authored Dec 28, 2022
1 parent ae188bc commit 8b600a9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ the `poetry check-project` command will:
6. remove the temporary folder.


The default setting for the underlying `MyPy` configuration is:

``` shell
--explicit-package-bases --namespace-packages --no-error-summary --no-color-output
```


## How is it different from the "poetry build" command?
Poetry does not allow package includes outside of the __project__ root.

Expand Down
9 changes: 4 additions & 5 deletions poetry_multiproject_plugin/commands/checkproject/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from cleo.helpers import option
from cleo.io.outputs.output import Verbosity
from poetry.console.commands.build import BuildCommand
from poetry.console.commands.command import Command
from poetry.factory import Factory

from poetry_multiproject_plugin.components.check import check_for_errors
Expand All @@ -31,7 +31,7 @@ def run_check(destination: Path, pyproj: str, config_file: str) -> List[str]:
return [row.replace(dest, "") for row in flattened]


class ProjectCheckCommand(BuildCommand):
class ProjectCheckCommand(Command):
name = command_name

options = [
Expand Down Expand Up @@ -65,14 +65,13 @@ def handle(self):
self.prepare_for_build(project_path.absolute())

self.io.set_verbosity(Verbosity.QUIET)
super(ProjectCheckCommand, self).handle()

mypy_config = self.option("config-file")

cleanup.remove_file(project_path, "poetry.lock")
cleanup.remove_file(project_path, "poetry.toml")

install_deps(project_path)

mypy_config = self.option("config-file")
res = run_check(project_path, pyproj, mypy_config)

self.io.set_verbosity(Verbosity.NORMAL)
Expand Down
6 changes: 6 additions & 0 deletions poetry_multiproject_plugin/components/deps/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
from pathlib import Path


def ensure_reusable_venv():
subprocess.run(["poetry", "config", "--local", "virtualenvs.in-project", "false"])
subprocess.run(["poetry", "config", "--local", "virtualenvs.path", "--unset"])


def run_install_command():
subprocess.run(["poetry", "install", "--only", "main", "--quiet"])

Expand All @@ -15,6 +20,7 @@ def install_deps(destination: Path):
current_dir = Path.cwd()

navigate_to(destination)
ensure_reusable_venv()
run_install_command()

navigate_to(current_dir)
5 changes: 4 additions & 1 deletion poetry_multiproject_plugin/components/project/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ def remove_project(project_path: Path):


def remove_file(project_path: Path, file_name: str):
os.remove(project_path / file_name)
try:
os.remove(project_path / file_name)
except FileNotFoundError:
pass
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "poetry-multiproject-plugin"
version = "1.1.1"
version = "1.1.2"
description = "A Poetry plugin that makes it possible to use relative package includes."
authors = ["David Vujic"]
homepage = "https://github.com/davidvujic/poetry-multiproject-plugin"
Expand Down

0 comments on commit 8b600a9

Please sign in to comment.