Skip to content

Commit 15afd56

Browse files
committed
revert the eager wheel_name inference to fix caching.
1 parent 3d71ae9 commit 15afd56

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

metaflow/plugins/pypi/conda_environment.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,17 @@ def _datastore_url(url, local_path):
133133
# Cache only those packages that manifest is unaware of
134134
local_packages.pop(package["url"], None)
135135
else:
136+
pkg_path = urlparse(package["url"]).path
136137
# TODO: Match up with CONDA_DATASTORE_ROOT so that cache
137138
# gets invalidated when DATASTORE is moved.
139+
# We might have built the wheel during resolving,
140+
# in which case we need to pull the actual package name from the local path
141+
if package.get("require_build", False):
142+
local_path = local_packages[package["url"]]["local_path"]
143+
pkg_path = local_path
138144
package["path"] = _datastore_url(
139145
package["url"],
140-
package.get("wheel_name", urlparse(package["url"]).path),
146+
pkg_path,
141147
)
142148
dirty.add(id_)
143149

metaflow/plugins/pypi/pip.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,8 @@ def solve(self, id_, packages, python, platform):
8383
def _format_item(item):
8484
dl_info = item["download_info"]
8585
res = {k: v for k, v in dl_info.items() if k in ["url"]}
86-
# Infer wheel name from url
87-
res["wheel_name"] = res["url"].split("/")[-1]
88-
res["require_build"] = False
89-
# If wheel name is not a wheel, we need to build the target. Construct a wheel name and add a build flag
90-
if not res["wheel_name"].endswith(".whl"):
91-
res["wheel_name"] = "{name}-{version}.whl".format(
92-
name=item["metadata"]["name"],
93-
version=item["metadata"]["version"],
94-
)
95-
res["require_build"] = True
86+
# If source url is not a wheel, we need to build the target. Add a build flag.
87+
res["require_build"] = not res["url"].endswith(".whl")
9688

9789
# reconstruct the VCS url and pin to current commit_id
9890
# so using @branch as a version acts somewhat as expected.
@@ -191,7 +183,6 @@ def download(self, id_, packages, python, platform):
191183
"download",
192184
"--no-deps",
193185
"--no-index",
194-
"--no-build-isolation", # required when using --no-index for setuptools to be found.
195186
"--progress-bar=off",
196187
# if packages are present in Pip cache, this will be a local copy
197188
"--dest=%s/.pip/wheels" % prefix,
@@ -210,7 +201,7 @@ def download(self, id_, packages, python, platform):
210201
cmd.append(package["url"])
211202
# record the url-to-path mapping fo wheels in metadata file.
212203
metadata[package["url"]] = "{prefix}/.pip/wheels/{wheel}".format(
213-
prefix=prefix, wheel=package["wheel_name"]
204+
prefix=prefix, wheel=package["url"].split("/")[-1]
214205
)
215206
self._call(prefix, cmd)
216207
# write the url to wheel mappings in a magic location
@@ -243,7 +234,7 @@ def create(self, id_, packages, python, platform):
243234

244235
def metadata(self, id_, packages, python, platform):
245236
# read the url to wheel mappings from a magic location.
246-
# Combine the metadata and build_metadata files, allowing build_metadata mappings to override.
237+
# Combine the metadata and build_metadata files (these should be disjoint sets).
247238
prefix = self.micromamba.path_to_environment(id_)
248239
metadata_file = METADATA_FILE.format(prefix=prefix)
249240
build_metadata_file = BUILD_METADATA_FILE.format(prefix=prefix)

0 commit comments

Comments
 (0)