conda / conda-package-handling

Create and extract conda packages of various formats
https://conda.github.io/conda-package-handling/
BSD 3-Clause "New" or "Revised" License
26 stars 37 forks source link

cph create is broken when --out-fn includes any sort of path #251

Closed FaustinCarter closed 3 weeks ago

FaustinCarter commented 3 months ago

Checklist

What happened?

Attempting to round-trip a .conda package using the cph CLI resulted in a .conda package that was unextractable.

Example (using noarch/uncertainties-3.2.0-pyhd8ed1ab_0.conda):

cph extract uncertainties-3.2.0-pyhd8ed1ab_0.conda
rm uncertainties-3.2.0-pyhd8ed1ab_0.conda
cph create uncertainties-3.2.0-pyhd8ed1ab_0 ./uncertainties-3.2.0-pyhd8ed1ab_0.conda # note the relative path here
rm -rf uncertainties-3.2.0-pyhd8ed1ab_0
cph extract uncertainties-3.2.0-pyhd8ed1ab_0.conda # Crashes here

The fundamental issue appears to be that an additional pair of folders got created in the .conda archive called "info-." and "pkg-." and the info and pkg tar.zst files are inside those two additional folders.

In other words, the original .conda package, prior to extraction, contains the following two paths:

The ruined .conda package after round-trip contains the following two paths:

After some more testing, it appears that the culprit is https://github.com/conda/conda-package-handling/blob/ee025e5259a031a093123920096481cafd9ff2a2/src/conda_package_handling/conda_fmt.py#L67. This line naively includes the entire file path as part of the internal info/pkg archive names.

Suggested fix:

- file_id = out_fn.replace(".conda", "")
+ file_id = os.path.basename(out_fn).replace(".conda", "")

Conda Info

No response

Conda Config

No response

Conda list

No response

Additional Context

No response

dholth commented 1 month ago

Thanks