Skip to content

Commit

Permalink
fix: add python prefix to the self update command on Windows (pdm-pro…
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming authored Jun 4, 2023
1 parent 77190c4 commit 1209a0b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/1972.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show the specific install commands for different installations when checking update. This was removed before.
18 changes: 17 additions & 1 deletion src/pdm/cli/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,13 +734,29 @@ def check_update(project: Project) -> None:
"""Check if there is a new version of PDM available"""
from packaging.version import Version

from pdm.cli.utils import is_homebrew_installation, is_pipx_installation, is_scoop_installation

this_version = project.core.version
latest_version = get_latest_version(project)
if latest_version is None or Version(this_version) >= Version(latest_version):
return
install_command = "pdm self update" + (" --pre" if Version(latest_version).is_prerelease else "")
disable_command = "pdm config check_update false"

is_prerelease = Version(latest_version).is_prerelease

if is_pipx_installation():
install_command = f"pipx upgrade {'--pip-args=--pre ' if is_prerelease else ''}pdm"
elif is_homebrew_installation():
install_command = "brew upgrade pdm"
elif is_scoop_installation():
install_command = "scoop update pdm"
else:
install_command = "pdm self update" + (" --pre" if is_prerelease else "")
if os.name == "nt":
# On Windows, the executable can't replace itself, we add the python prefix to the command
# A bit ugly but it works
install_command = f"{sys.executable} -m {install_command}"

message = [
f"\nPDM [primary]{this_version}[/]",
f" is installed, while [primary]{latest_version}[/]",
Expand Down

0 comments on commit 1209a0b

Please sign in to comment.