Skip to content

Commit b855a63

Browse files
authored
Merge pull request #160 from sbidoul/uv-refresh-package
[FIX] force refreshing of project metadata when using uv
2 parents fcdf0b2 + 8794a20 commit b855a63

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies=[
3131
"typer[all] >=0.3.2",
3232
# installers
3333
"pip >=22.2",
34-
"uv >=0.1.12",
34+
"uv >=0.2.37",
3535
# compat
3636
"importlib_resources>=1.3 ; python_version<'3.9'",
3737
"tomli ; python_version<'3.11'",

src/pip_deepfreeze/pip.py

+29-7
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ class Installer(ABC):
6161
@abstractmethod
6262
def install_cmd(self, python: str) -> List[str]: ...
6363

64+
def editable_install_cmd(
65+
self,
66+
python: str,
67+
project_root: Path,
68+
project_name: str,
69+
extras: Optional[Sequence[NormalizedName]],
70+
) -> List[str]:
71+
cmd = self.install_cmd(python)
72+
cmd.append("-e")
73+
if extras:
74+
extras_str = ",".join(extras)
75+
cmd.append(f"{project_root}[{extras_str}]")
76+
else:
77+
cmd.append(f"{project_root}")
78+
return cmd
79+
6480
@abstractmethod
6581
def uninstall_cmd(self, python: str) -> List[str]: ...
6682

@@ -101,6 +117,18 @@ class UvpipInstaller(Installer):
101117
def install_cmd(self, python: str) -> List[str]:
102118
return [sys.executable, "-m", "uv", "pip", "install", "--python", python]
103119

120+
def editable_install_cmd(
121+
self,
122+
python: str,
123+
project_root: Path,
124+
project_name: str,
125+
extras: Optional[Sequence[NormalizedName]],
126+
) -> List[str]:
127+
cmd = super().editable_install_cmd(python, project_root, project_name, extras)
128+
# https://github.com/astral-sh/uv/issues/5484
129+
cmd.append(f"--refresh-package={project_name}")
130+
return cmd
131+
104132
def uninstall_cmd(self, python: str) -> List[str]:
105133
return [sys.executable, "-m", "uv", "pip", "uninstall", "--python", python]
106134

@@ -191,7 +219,7 @@ def pip_upgrade_project(
191219
# 4. install project with constraints
192220
project_name = get_project_name(python, project_root)
193221
log_info(f"Installing/updating {project_name}")
194-
cmd = installer.install_cmd(python)
222+
cmd = installer.editable_install_cmd(python, project_root, project_name, extras)
195223
if installer_options:
196224
cmd.extend(installer_options)
197225
cmd.extend(
@@ -201,12 +229,6 @@ def pip_upgrade_project(
201229
*editable_constraints,
202230
]
203231
)
204-
cmd.append("-e")
205-
if extras:
206-
extras_str = ",".join(extras)
207-
cmd.append(f"{project_root}[{extras_str}]")
208-
else:
209-
cmd.append(f"{project_root}")
210232
log_debug(f"Running {shlex.join(cmd)}")
211233
constraints = constraints_without_editables_filename.read_text(
212234
encoding="utf-8"

0 commit comments

Comments
 (0)