python - Why doesn't virtualenv virtualize arbitrary directories? -
so have python script i'm trying distribute linux hosts.
in accordance current best practices, i'm trying deploy script within virtualenv sandbox. however, noticed virtualenv doesn't virtualize directories such /usr/sbin, /var/lib , /etc. in accordance linux best practices, need write various files , configurations directories mentioned above.
how can create sandboxed deployment if virtualenv doesn't virtualize these directories?
simple "install copy/move" procedure
the procedure simple:
set virtualenv install in script of interest move directory like, e.g. /usr/binthe trick is, script gets encoded path virtualized python inside, when phone call it, using virtualized environment.
usually, encoding absolute path, moving script file not harm anything.
however, directory virtual env (where python) must remain is, prerequisite script run.
installing script must go via setup.py , must utilize parameter entry_point. using scripts not work, takes referenced file , makes simple re-create only.
setup.py alternative --install-scripts setup.py allows specifying, install script. might seek using (but not requirement).
$ python setup.py install -h mutual commands: (see '--help-commands' more) setup.py build build bundle underneath 'build/' setup.py install install bundle global options: --verbose (-v) run verbosely (default) .... options 'install' command: .... --install-scripts installation directory python scripts usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help conclusions virtualenv allows isolation of python environment installed script while allowing simple copy/move of script whatever location incl. scheme directories. above possible, if script installed using standard setup.py, puts around script references virtualenv python. copying plain python file fail. setup.py allows straight specifying install script. python linux python-2.7 virtualenv
No comments:
Post a Comment