Skip to content

Commit

Permalink
chore: add --no-frozen-deps option to install-pdm.py
Browse files Browse the repository at this point in the history
Close #3213

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Oct 17, 2024
1 parent d5b0bc9 commit e6e041e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 61 deletions.
16 changes: 13 additions & 3 deletions install-pdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class Installer:
additional_deps: Sequence[str] = ()
skip_add_to_path: bool = False
output_path: str | None = None
frozen_deps: bool = True

def __post_init__(self):
self._path = self._decide_path()
Expand Down Expand Up @@ -290,19 +291,20 @@ def _install(self, venv_path: Path) -> None:
pass
_call_subprocess([str(venv_python), "-m", "pip", "install", "-IU", "pip"])

locked = "[locked]" if self.frozen_deps else ""
if self.version:
if self.version.upper() == "HEAD":
req = f"pdm[locked] @ git+{REPO}.git@main"
req = f"pdm{locked} @ git+{REPO}.git@main"
else:
try:
parsed = tuple(map(int, self.version.split(".")))
except ValueError:
extra = ""
else:
extra = "[locked]" if parsed >= (2, 17) else ""
extra = locked if parsed >= (2, 17) else ""
req = f"pdm{extra}=={self.version}"
else:
req = "pdm[locked]"
req = f"pdm{locked}"
args = [req] + [d for d in self.additional_deps if d]
pip_cmd = [str(venv_python), "-Im", "pip", "install", *args]
_call_subprocess(pip_cmd)
Expand Down Expand Up @@ -417,6 +419,13 @@ def main():
help="Allow prereleases to be installed",
default=os.getenv("PDM_PRERELEASE"),
)
parser.add_argument(
"--no-frozen-deps",
action="store_false",
dest="frozen_deps",
default=not bool(os.getenv("PDM_NO_FROZEN_DEPS")),
help="Do not install frozen dependency versions",
)
parser.add_argument(
"--remove",
action="store_true",
Expand Down Expand Up @@ -452,6 +461,7 @@ def main():
additional_deps=options.dep,
skip_add_to_path=options.skip_add_to_path,
output_path=options.output,
frozen_deps=options.frozen_deps,
)
if options.remove:
installer.uninstall()
Expand Down
2 changes: 1 addition & 1 deletion install-pdm.py.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cdaae475a16ae781e06c7211c7b075df1b508470b0dc144bbb73acf9a8389f91 install-pdm.py
07dacbddc508f70bc21347598b9764bc07440ebface340bdd1e96f7af9ea4267 install-pdm.py
1 change: 1 addition & 0 deletions news/3213.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `--no-frozen-deps` option to `install-pdm.py` script to allow installing newer versions of dependencies.
Loading

0 comments on commit e6e041e

Please sign in to comment.