Package: vrun
vrunAdds Python’s bin/Scripts directory toPATHbefore executing a command.
Primarily used with Python virtual environments.OverviewA small Python helper tool that will modify thePATHin the environment
before executing the executable provided as the first argument. This is useful
when programs expect certain binaries to be available inPATHso they can
execute them usingos.popen()and friends or even for shell scripts that
are executing Python tools that one would prefer to not globally install.Scripts may detect that vrun has been used by looking for the environment
variableVRUN_ACTIVATEDwhich is set to1when run. It is not
recommended that script writers do this.UseOn macOS/FreeBSD/Linux/Unix:$ python3 -mvenv ./env/
$ ./env/bin/pip install vrun
$ ./env/bin/vrun /bin/bash -c 'echo $PATH'On Windows:C:\> python3.exe -mvenv env
C:\> env\Scripts\pip.exe install vrun
C:\> env\Scripts\vrun.exe python -c "import os; print(os.environ['PATH'])"If for example there is a script that executespipwithout explicitly
providing a PATH that includes a virtual environment the system installedpipmay accidentally be invoked instead. With vrun the virtual environment
will come first in the search path and thuspipwill be safely executed
within the context of the virtual environment.Such as a shell script:$ ./env/bin/vrun ./myscript.shOr executing a Windows batch script:C:\> env\Scripts\vrun.exe script.batCommand aliasesvrun allows you to define command aliases in a configuration file, eithervrun.cfg,vrun.iniorsetup.cfg.These configuration files must contain at least avrunsection, then using standard ini format you may specify key/value pairs:[vrun]
python.version = python --version
shell = /bin/bash
echo = /bin/bash -c 'echo ${@}' _ {posargs} echo off the bare wallsNow you may run these commands using:vrun python.versionWhich will return something similar to:Python 3.6.2Then you can do positional argument interpolation:vrun echo the soft voiceswill output:the soft voices echo off the bare wallsInterpolationSo long as the keyword{posargs}is stand-alone, and surrounded by spaces
(and not inside of a quoted segment)vrunwill replace it with any
positonal arguments provided on the command line. If not positional arguments
are provided, it will remove the{posargs}placeholder and remove it as an
argument.If there is no{posargs}provided in the command alias, all extra arguments
provided after the initial command will be passed as positional arguments.Using theshellexample from above, you may do:vrun shell -c 'echo $PATH'which will execute:/bin/bash -c 'echo $PATH'Within the virtual environment as expected. This can be useful to allow you to
predefine certain longer commands, but still allow the user on the fly on the
command line to add additional parameters as necessary.vrun or vexecvrun installs itself as bothvrunandvexec. The later may be typed
with the left hand only and is slightly faster to roll off the keyboard!LicensePlease see theLICENSEfile in the source
code repository0.4 (2017-09-27)You may now create command aliases by creating a new configuration file namedvrun.cfgor adding a section to an existingsetup.cfgnamed[vrun].[vrun]
python.version = python --version
shell = /bin/bash
echo = /bin/bash -c 'echo ${@}' _ {posargs} echo off the bare wallsWhich may then be used like so:vrun python.version
vrun echo the soft voices
vrun shell -c 'echo $PATH'New tests have been added, and coverage is now 100%. All new features from
now on will have to meet the same coverage requirements to verify there are
no breaking changes.0.3 (2017-06-13)Adds Windows support, so now you can use:Script\vrun.exe python -c "import os; print(os.environ['PATH'])"To run Windows binaries with their%PATH%modified.vrun will also automatically add the.exewhen passing the name of a script
that exists in theScriptsfolder.So the following are the same:Script\vrun.exe pythonand:Script\vrun.exe python.exe0.2 (2017-06-08)Also export the environment variableVIRTUAL_ENVpointing to the virtual
environment.0.1 (2017-06-08)Initial release and implementation of the vrun functionality