matthewfeickert / venv-activate Goto Github PK
View Code? Open in Web Editor NEWBash creation and tab completion of activation of Python virtual environments
License: BSD 3-Clause "New" or "Revised" License
Bash creation and tab completion of activation of Python virtual environments
License: BSD 3-Clause "New" or "Revised" License
Using Shellcheck on _venv-activate.sh
reveals the following issues:
$ shellcheck _venv-activate.sh
In _venv-activate.sh line 8:
prev="${COMP_WORDS[COMP_CWORD-1]}"
^-- SC2034: prev appears unused. Verify it or export it.
In _venv-activate.sh line 9:
opts="$(echo $($(which ls) -1 ${HOME}/venvs/ | sed 's/^//'))"
^-- SC2046: Quote this to prevent word splitting.
^-- SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.
^-- SC2086: Double quote to prevent globbing and word splitting.
In _venv-activate.sh line 12:
COMPREPLY=($(compgen -W "${opts}" $cur))
^-- SC2086: Double quote to prevent globbing and word splitting.
In _venv-activate.sh line 19:
$(which ls) -1 ${HOME}/venvs/ | sed 's/^/* /'
^-- SC2086: Double quote to prevent globbing and word splitting.
In _venv-activate.sh line 28:
printf "\n$1 is not a valid virtual environment."
^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
These should be addressed and fixed. ๐
Given _VENV_ACTIVATE_HOME
and the name of the virtual environment to query/use the full path to any Python and pip runtime for any virtual environment is know. Given this, without having to activate the virtual environment information on it can be queried. For venv ${name}
the full paths are:
"${_VENV_ACTIVATE_HOME}"/${name}/bin/python
"${_VENV_ACTIVATE_HOME}"/${name}/bin/pip
So something like venv-info
could give information on Python and pip version
$ venv-info sandbox
Python: v3.7.5
pip: v19.3.1
packages installed: 37
and then mirroring pip
one could do
$ venv-pip list sandbox
<output of sandbox's pip list>
$ venv-pip freeze sandbox
<output of sandbox's pip freeze>
$ venv-pip show numpy sandbox
Name: numpy
Version: 1.17.4
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: /home/feickert/.venvs/sandbox/lib/python3.7/site-packages
Requires:
Required-by: tensorflow-gpu, tensorboard, scipy, opt-einsum, Keras-Preprocessing, Keras-Applications, jaxlib, jax, h5py
The API could be improved though.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.