artefactual-sdps / enduro

A tool to support ingest and automation in digital preservation workflows
https://enduro.readthedocs.io/
Apache License 2.0
4 stars 3 forks source link

Add path activation script #838

Closed sevein closed 8 months ago

sevein commented 8 months ago

This pull request includes a path activation script for the fish shell inspired by Python's virtual environments.

Usage:

source hack/activate.fish

It adds the local binary cache directory of the project to the PATH environment string. Now you can use tools like ent, goa, golangci-lint, gomajor, gosec, gotestsum, mockgen, shfmt or tparse with the confidence of using the versions required by this project as opposed to any global version you have installed previously.

If you're using devbox, the equivalent would be to execute devbox shell.

djjuhasz commented 8 months ago

@sevein would a similar script be helpful for Bash, or are the tool versions already handled in Bash by the Makefile? I use Zsh and I don't want to introduce spurious changes because I have the wrong tool version.

Diogenesoftoronto commented 8 months ago

@sevein would a similar script be helpful for Bash, or are the tool versions already handled in Bash by the Makefile? I use Zsh and I don't want to introduce spurious changes because I have the wrong tool version.

zsh can run the normal source activate code that fish cannot. The reason is that fish is not posix complaint shell at all. for example in fish a variable is defined via the set command. This breaks almost all bash scripts when porting to fish. it is why i usually just execute bash scripts on my fish shell via bash -c "".

sevein commented 8 months ago

Virtual environments created with python3 -m venv populate four activate bin scripts for different shell types. I've uploaded an example from my a3m venv: https://gist.github.com/sevein/0f4f072143f6eb38954867282c56ec1c. Perhaps we should have: hack/activate/bash and hack/activate/fish? Sounds like that'd cover all our use cases. Let me know and I'll do it.

djjuhasz commented 8 months ago

@sevein I don't know if hack/fish is necessary because the binary version control in the individual make scripts (e.g. hack/make/dep_mockgen.mk) doesn't work in fish, or if hack/fish has some other purpose. If the fish activation script provides extra functionality, then yes, I'd like to have it for bash/zsh as well. :)