saulpw / visidata

A terminal spreadsheet multitool for discovering and arranging data
http://visidata.org
GNU General Public License v3.0
7.94k stars 283 forks source link

[installation] Add instructions for how to use VisiData with UV #2591

Open frosencrantz opened 1 month ago

frosencrantz commented 1 month ago

@reagle recently had an issue with installing VisiData with uv https://github.com/saulpw/visidata/issues/2560 that turned out to be an issue with the 3.1 release. I think the amazing thing from his bug was how easy it was to run Visidata with the latest release.

uv is easy to use, and can quickly install a usable version of VisiData. As @reagle showed, it is as simple as:

uvx visidata

If you want to add some additional packages you need to add --with flags per package. There might be an easier way to make uv install VisiData with a fuller set of packages than the default, so users can work with more than the default file formats.

Feature request: Update the instructions in https://github.com/saulpw/visidata/blob/develop/README.md to include uv instructions.

reagle commented 1 month ago

I won't speak to whether uvx or pipx merit special mention, but I don't think uv tool/uvx permits optional dependencies beyond those specified via --with. pipx can Install extras (in brackets, as defined by the packager) akin to what pip does.

frosencrantz commented 4 weeks ago

It looks like you can do a one-time--with for uv tool/uvx, but you need to do uv install tool first.

https://docs.astral.sh/uv/concepts/tools/#the-uv-tool-interface says:

Tools can be invoked without installation using uv tool run, in which case their dependencies are installed in a temporary virtual environment isolated from the current project.

Because it is very common to run tools without installing them, a uvx alias is provided for uv tool run — the two commands are exactly equivalent. ...

Tools can also be installed with uv tool install, in which case their executables are available on the PATH — an isolated virtual environment is still used, but it is not removed when the command completes.

It is a good question should uvor pipx deserve special mention. I do not know, it does feel relevant right now. The uv tool is impressively fast. If someone is using that as one of their installation tools, it is fast and easy to try out VisiData. That seems useful for new and existing users.

frosencrantz commented 4 weeks ago

With uv it is as simple as running:

uvx visidata https://raw.githubusercontent.com/jsvine/intro-to-visidata/refs/heads/master/datasets/faa-wildlife-strikes.csv

If you want to load additional file formats, you will need to install the necessary modules:

uv tool install visidata --with lxml --with zstandard
uvx visidata https://www.visidata.org/docs/formats/
daviewales commented 2 weeks ago

If you document uv tool you might consider documenting pipx too while you're at it.

Also note, if you are using uv tool install, it adds the executable to the PATH, so you can just call it directly without uvx:

The example above should be:

uv tool install visidata --with lxml --with zstandard
visidata https://www.visidata.org/docs/formats/

The same with pipx:

pipx install visidata --preinstall lxml --preinstall zstandard
visidata https://www.visidata.org/docs/formats/

Or alternatively, you can inject the optional dependencies after installing as required:

pipx install visidata
pipx inject visidata lxml zstandard
visidata https://www.visidata.org/docs/formats/
anjakefala commented 2 weeks ago

If you document uv tool you might consider documenting pipx too while you're at it.

This is probably the biggest reason we're not going to document it. =( There are a lot of pip alternative tools (poetry is another example), and I don't know if it's necessary for, or the place of, our documentation to cover them.

daviewales commented 2 weeks ago

That's fair. Although I wouldn't consider most of the others to be in the same category as pipx and uv tool. The others are generally project management tools, while pipx and uv tool are mainly useful to add executables to your PATH.

frosencrantz commented 2 weeks ago

@daviewales thank you I did not know that the command will be in my path. I was trying uv with its builtin pip, but it does seem like the "uvx" format makes it easy to use.

@anjakefala if the main README.md is not a good location, maybe the github wiki or visidata.org might be a good place for these additional instructions. Also, thank you for considering this.

daviewales commented 2 weeks ago

uvx is essentially a shortcut for uv tool run, which is similar to pipx run. Both these run an uninstalled command directly without permanently installing it or adding it to the PATH. But uv tool install and pipx install are more permanent and add the scripts to PATH.