conda-package-handling icon indicating copy to clipboard operation
conda-package-handling copied to clipboard

Exploring package contents easily

Open jakirkham opened this issue 5 years ago • 19 comments

One thing that I really enjoy about the current format is how easy it is to unpack a package and inspect its contents. This is really great as a packager to make sure I'm really producing what I think I am or aid in debugging build issues I'm encountering. While I can certainly appreciate the gains made by compressing packages more efficiently and organizing things a bit, I'd be curious to know what recommendations the Conda team has to packagers trying to quickly inspect package contents.

jakirkham avatar Mar 21 '19 22:03 jakirkham

cph x filename will extract either format. How is that any worse that tar -jxvf filename?

msarahan avatar Mar 21 '19 22:03 msarahan

Well now I just double click. 😄 That's not really the point though.

I can make some suggestions if you prefer. Was trying to leave it open ended in case you had your own thoughts here.

jakirkham avatar Mar 21 '19 23:03 jakirkham

sure, if you have suggestions, please post them. Double-clicking is nice, but I'm willing to sacrifice it for 10x decompress/extraction speed.

msarahan avatar Mar 21 '19 23:03 msarahan

I think maybe you're overestimating the timeline for .tar.bz2 files going away. They're not going away any time soon. Right now, things are built as .tar.bz2 and then converted to .conda files later. You can still download .tar.bz2 files for your package. In fact, that's all you'll get unless you do extra work to produce the .conda files.

It would be nice if .conda files were also double-clickable, for sure.

msarahan avatar Mar 26 '19 17:03 msarahan

If they have a useful magic in the beginning, it should be easy to link an application to the file type. You'd probably want an installer to open though, not a content viewer.

epruesse avatar Mar 26 '19 18:03 epruesse

Well one suggestion would be to have this information accessible on Anaconda.org. That would avoid needing to download the package at all (unless the specific package contents need to be checked more closely).

jakirkham avatar Mar 31 '19 20:03 jakirkham

Hi there, thank you for your contribution!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs.

If you would like this issue to remain open please:

  1. Verify that you can still reproduce the issue at hand
  2. Comment that the issue is still reproducible and include: - What OS and version you reproduced the issue on - What steps you followed to reproduce the issue

NOTE: If this issue was closed prematurely, please leave a comment.

Thanks!

github-actions[bot] avatar Mar 31 '22 04:03 github-actions[bot]

Would be good to keep this open

jakirkham avatar Mar 31 '22 05:03 jakirkham

This came up again in this comment ( https://github.com/conda-forge/conda-forge.github.io/issues/1586#issuecomment-1319340949 )

cc @dhirschfeld

jakirkham avatar Nov 17 '22 23:11 jakirkham

One trick that might help would be to have a separate CI job which unpacked the contents of the just-built package and called tree on it. With GitHub Actions you could even output the result as a job summary - something like:

cph x mypkg.conda
contents=$(tree ./mypkg)
echo "### Package Contents" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "${contents}"  >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

dhirschfeld avatar Nov 17 '22 23:11 dhirschfeld

One trick that might help would be to have a separate CI job which unpacked the contents of the just-built package and called tree on it. With GitHub Actions you could even output the result as a job summary - something like:

This information is already in https://github.com/regro/libcfgraph

chrisburr avatar Nov 18 '22 07:11 chrisburr

Yeah think it depends on what question one is asking. If it is, does this package contain <file> or which pack contains <file>, agree the web interface is the better way to go. If it is, did my build produce the package expected or why is the package produced from this build not behaving, then one wants tools to inspect things locally.

jakirkham avatar Nov 18 '22 08:11 jakirkham

FWIW one option might be to use PeaZip. Maybe this is worth packaging ourselves ( https://github.com/conda-forge/staged-recipes/issues/21563 )?

jakirkham avatar Dec 16 '22 21:12 jakirkham

Like tar -tvf somefile?

Could we re-use part of Python's built-in tar command line utility? % python -m tarfile -l iniconfig-1.1.1-pyhd3eb1b0_0.tar.bz2

dholth avatar Apr 01 '24 14:04 dholth

Adding cph list in https://github.com/conda/conda-package-handling/pull/236, which should make things super easy to set up a CI step like proposed above (with no extraction cost).

jaimergp avatar Apr 02 '24 18:04 jaimergp

While researching for that PR also found out that you can use tar for this too:

# .tar.bz2:
tar tvf path/to/artifact.tar.bz2  
# .conda: package contents
tar xOf path/to/artifact.conda "pkg-*.tar.zst" | tar tv 
# .conda: info/ metadata
tar xOf path/to/artifact.conda "info-*.tar.zst" | tar tv 

In case it varies across platforms, this is on macOS with:

$ tar --version
bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.12 liblzma/5.0.5 bz2lib/1.0.8 

jaimergp avatar Apr 02 '24 19:04 jaimergp

Mind blown, extracting .zip with the libarchive tar command! 🤯

dholth avatar Apr 02 '24 21:04 dholth

Adding cph list in #236, which should make things super easy to set up a CI step like proposed above (with no extraction cost).

Nice! Thanks Jaime 🙏

Wonder if it would be worth adding a cph tree (like Linux's tree) to get a better sense of layout

jakirkham avatar Apr 03 '24 20:04 jakirkham

Turns out you can use tree for this too!

$ cph list ~/Downloads/conda-22.9.0+93_gb267263a0-py38_0.tar.bz2 | tree --fromfile
.
├── bin
│   ├── activate
│   ├── conda
│   ├── conda-env
│   └── deactivate
├── condabin
│   └── conda
├── etc
│   ├── fish
│   │   └── conf.d
│   │       └── conda.fish
│   └── profile.d
│       ├── conda.csh
│       └── conda.sh
├── info
│   ├── about.json
│   ├── files
│   ├── git
│   ├── has_prefix
│   ├── hash_input.json
│   ├── index.json
│   ├── licenses
│   │   └── LICENSE.txt
│   ├── paths.json
│   ├── recipe
...

jaimergp avatar Apr 29 '24 12:04 jaimergp

@jaimergp fixed?

dholth avatar Sep 09 '24 14:09 dholth

I think so! The only thing missing is some documentation, I'd say? I can open a PR if you agree.

jaimergp avatar Sep 10 '24 07:09 jaimergp