Package: exec-wrappers
A command line tool to create wrappers around executable filesRationaleexec-wrappersis useful whenever you need a single executable file, but have to do some setup
before executing it.If you develop using some kind of environment isolation likeconda,schroot,virtualenvyou probably wanted to configure a GUI application like an IDE to use the executables
available inside these environments.But you normally have to create a script that do some setup/activation step and then run the command
but creating such a script for each executable is tedious.exec-wrappershelps automating that as it detects executable files and create a wrapper for each
of them. It also already provides some wrappers for common tools.Also, as the wrappers are intended to be used non-interactively, they are normally much simpler than
the interactive counterpart.For example, the conda wrappers are much faster than doing an activate and executing the command:Regular activate:$echo'source activate test 2> /dev/null; "$@"'>/tmp/activate-and-run&&chmoda+x/tmp/activate-and-run$time/tmp/activate-and-runpython--versionPython2.7.11::ContinuumAnalytics,Inc.real0m0.354suser0m0.288ssys0m0.040sUsing python wrapper created byexec-wrappers:$time/tmp/conda_wrappers/python--versionPython2.7.11::ContinuumAnalytics,Inc.real0m0.003suser0m0.000ssys0m0.000sHaving a low overhead is very important if you are executing the command non-interactively.Featuresautomatically detect executables in a given directorywrappers written in plain shell and batch scriptslow overhead (as low as possible)built-in wrappers for common toolsRequirementspythonis the only dependency to create wrappers.
To properly use the generated wrappers you need the tool used by the wrapper (conda, schroot, etc.).Installation$ python setup.py installHow it worksCreatingcondawrappers:$create-wrappers-tconda--bin-dir~/miniconda/envs/test/bin--dest-dir/tmp/conda_wrappers--conda-env-dir~/miniconda/envs/testThis will create in/tmp/conda_wrappersa wrapper for each executable found in~/miniconda/envs/test/bin.
So if you run the python wrapper:$/tmp/conda_wrappers/python-c"import sys; print(sys.executable)"/home/username/miniconda/envs/test/bin/pythonIt will actually activate the conda environment and set necessary variables, and then execute the
realpythoninterpreter. So you can use the wrapper to configure you IDE, for example.Also arun-inscript will be created, which you can use to run any arbitrary command:$/tmp/conda_wrappers/run-inbash-c'echo $CONDA_DEFAULT_ENV'/home/username/miniconda/envs/testExamplesconda:$create-wrappers-tconda-b~/miniconda/envs/test/bin-d/tmp/conda_wrappers--conda-env-dir~/miniconda/envs/testvirtualenv:$create-wrappers-tvirtualenv-b~/python3-env/bin-d/tmp/virtualenv_wrappers--virtual-env-dir~/python3-envschroot:$create-wrappers-tschroot-b~/chroots/centos5/bin-d/tmp/schroot_wrappers--schroot-namecentos5$create-wrappers-tschroot-b~/chroots/centos5/bin-d/tmp/schroot_wrappers--schroot-namecentos5--schroot-options="-p -d /"custom:$echo-e'#!/bin/sh\necho "$@"'>/tmp/custom-script&&chmoda+x/tmp/custom-script$create-wrappers-tcustom--custom-script=/tmp/custom-script-b/usr/bin-d/tmp/custom_wrapperswrap only specified files:$create-wrappers-tschroot-fgcc:gdb-d/tmp/schroot_wrappers--schroot-namecentos5chain multiple wrappers:$create-wrappers-tconda-b~/miniconda/envs/test/bin-d/tmp/conda_wrappers--conda-env-dir~/miniconda/envs/test$create-wrappers-tschroot-b/tmp/conda_wrappers-d/tmp/schroot_wrappers--schroot-namecentos5LicenseDistributed under the terms of theMITlicense,exec-wrappersis free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.