Deprecate venv_command
BUG=chromium:674687
TEST=Run virtualenvs locally
Change-Id: I42c0007ca012ca46ee6cbba80ac94a2570b8d262
Reviewed-on: https://chromium-review.googlesource.com/423334
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
diff --git a/README.md b/README.md
index 8dc9c2c..620899b 100644
--- a/README.md
+++ b/README.md
@@ -22,25 +22,28 @@
Wrapper scripts
---------------
-This repository contains two scripts for working with Python virtualenvs.
+`create_venv` creates or updates a virtualenv using a
+`requirements.txt` file.
-`venv_command` runs a command in a virtualenv environment. This is more
-convenient than having to start a shell and source `bin/activate`.
-For example, to start Python inside the virtualenv:
+ $ create_venv .venv requirements.txt
- $ venv_command path/to/venv python
+To run the virtualenv python, use:
-`create_venv` creates or updates a virtualenv using a `requirements.txt` file.
+ $ .venv/bin/python
- $ create_venv path/to/venv path/to/requirements.txt
+NOTE: it is not generally safe to run the other scripts in `.venv/bin`
+due to the hard-coded paths in the virtualenv. Instead of running
+`.venv/bin/pip` for example, use `.venv/bin/python -m pip`.
Here’s a complete example:
- $ echo mock=2.0.0 > requirements.txt
- $ ./create_venv venv requirements.txt
- $ ./venv_command venv python
+ $ echo mock==2.0.0 > requirements.txt
+ $ ./create_venv .venv requirements.txt
+ $ .venv/bin/python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
+ >>> import sys
+ >>> sys.prefix # This points to the virtualenv now
+ '/usr/local/google/home/ayatane/src/chromiumos/infra_virtualenv/.venv'
>>> import mock
- >>>
diff --git a/create_venv b/create_venv
index cc07e34..7840136 100755
--- a/create_venv
+++ b/create_venv
@@ -96,12 +96,8 @@
venv_pip_install() {
local venv_dir=$1
shift 1
- venv_command "$venv_dir" \
- pip install --no-index -f "file://$pkgdir" "$@"
-}
-
-venv_command() {
- "$basedir/venv_command" "$@"
+ "$venv_dir/bin/python" \
+ -m pip install --no-index -f "file://$pkgdir" "$@"
}
main "$@"
diff --git a/venv_command b/venv_command
index b99c0bf..f95e2af 100755
--- a/venv_command
+++ b/venv_command
@@ -6,6 +6,10 @@
# Run a command in a virtualenv environment.
#
# $ venv_command path/to/venv command [args...]
+#
+# Note: This is deprecated in favor of running the virtualenv python directly:
+#
+# $ path/to/venv/bin/python
set -eu
main() {