Skip to content

Commit

Permalink
fix: don't use install cache when installing build requirements to av…
Browse files Browse the repository at this point in the history
…oid race condition

Fixes #1869

Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed May 22, 2023
1 parent cea0958 commit f283354
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/1869.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't use install cache when installing build requirements to avoid race condition.
4 changes: 3 additions & 1 deletion src/pdm/cli/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def install_plugins(self, project: Project) -> None:
environment = PythonEnvironment(project, python=sys.executable, prefix=str(plugin_root))
with project.core.ui.open_spinner("[success]Installing plugins...[/]"):
with project.core.ui.logging("install-plugins"):
install_requirements(plugins, environment, clean=True)
install_requirements(
plugins, environment, clean=True, use_install_cache=project.config["install.cache"]
)
if not plugin_root.joinpath(".gitignore").exists():
plugin_root.joinpath(".gitignore").write_text("*\n")
project.core.ui.echo("Plugins are installed successfully into [primary].pdm-plugins[/].")
Expand Down
4 changes: 2 additions & 2 deletions src/pdm/installers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def install_requirements(
reqs: list[Requirement], environment: BaseEnvironment, clean: bool = False
reqs: list[Requirement], environment: BaseEnvironment, clean: bool = False, use_install_cache: bool = False
) -> None: # pragma: no cover
"""Resolve and install the given requirements into the environment."""
project = environment.project
Expand All @@ -28,5 +28,5 @@ def install_requirements(
environment.python_requires,
max_rounds=resolve_max_rounds,
)
syncer = BaseSynchronizer(resolved, environment, clean=clean, retry_times=0)
syncer = BaseSynchronizer(resolved, environment, clean=clean, retry_times=0, use_install_cache=use_install_cache)
syncer.synchronize()
5 changes: 4 additions & 1 deletion src/pdm/installers/synchronizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def __init__(
reinstall: bool = False,
only_keep: bool = False,
fail_fast: bool = False,
use_install_cache: bool | None = None,
) -> None:
self.requested_candidates = candidates
self.environment = environment
Expand All @@ -119,7 +120,9 @@ def __init__(
self.retry_times = retry_times
self.no_editable = no_editable
self.install_self = install_self
self.use_install_cache = environment.project.config["install.cache"]
if use_install_cache is None:
use_install_cache = environment.project.config["install.cache"]
self.use_install_cache = use_install_cache
self.reinstall = reinstall
self.only_keep = only_keep
self.parallel = environment.project.config["install.parallel"]
Expand Down

0 comments on commit f283354

Please sign in to comment.