Skip to content

Commit

Permalink
Expand variables when calculation hash. Fix #861.
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Jan 20, 2022
1 parent ff3b845 commit afb3244
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/861.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the hash calculation when generating `direct_url.json` for a local pre-built wheel.
16 changes: 12 additions & 4 deletions pdm/models/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,24 @@ def direct_url(self) -> dict[str, Any] | None:
"subdirectory": req.subdirectory,
}
)
url = expand_env_vars_in_auth(
req.url.replace(
"${PROJECT_ROOT}",
self.environment.project.root.as_posix().lstrip( # type: ignore
"/"
),
)
)
with self.environment.get_finder() as finder:
hash_cache = self.environment.project.make_hash_cache()
hash_cache.session = finder.session # type: ignore
return _filter_none(
{
"url": url_without_fragments(req.url),
"url": url_without_fragments(url),
"archive_info": {
"hash": hash_cache.get_hash(
pip_shims.Link(req.url)
).replace(":", "=")
"hash": hash_cache.get_hash(pip_shims.Link(url)).replace(
":", "="
)
},
"subdirectory": req.subdirectory,
}
Expand Down

0 comments on commit afb3244

Please sign in to comment.