commit | 57e6e3b019bd6ff8354efb6977212aeec2288fcf | [log] [tgz] |
---|---|---|
author | Allen Li <ayatane@google.com> | Tue Dec 06 17:49:17 2016 -0800 |
committer | chrome-bot <chrome-bot@chromium.org> | Fri Dec 09 18:25:31 2016 -0800 |
tree | 765c5c8add20abca7d7310846233f4bd8d9f10c6 | |
parent | 8e70ce20c5936c8beb5a744c3f63addfde0783b3 [diff] |
Add support for recursive requirements Add a script to expand recursive requirements. This allows recursive requirements to be tracked and updated; otherwise, we wouldnt know about new requirements in included subfiles. We do this because: 1. We cannot reliably check whether we need to update if we dont expand included dependencies. 2. Not checking if we need to update and always updating adds 2+ seconds to each call to create_venv, which is also run under an exclusive lock, significantly increasing the cost of virtualenv commands. The current implementation is a balance between simplicity, performance, and maintainability. If more additions are added, we should consider rewriting in Python. BUG=chromium:645611 TEST=Run locally with recursive requirements.txt Change-Id: Iffffa7348fade4113439fd4e372b3009090e2a47 Reviewed-on: https://chromium-review.googlesource.com/417248 Commit-Ready: Allen Li <ayatane@chromium.org> Tested-by: Allen Li <ayatane@chromium.org> Reviewed-by: Aviv Keshet <akeshet@chromium.org>
This repository provides a common Python virtualenv interface that infra code (such as chromite) can depend on. At this point, it is experimental and not yet used in production.
Virtualenv users should create a requirements.txt
file listing the packages that they need and use the wrapper scripts (described below) to create the virtualenv and run commands within it.
To add packages to this repository, run:
$ pip wheel -w path/to/pip_packages -r path/to/requirements.txt
Commit the changes and make a CL.
For example for chromite, from within chromite/virtualenv
, run:
$ pip wheel -w pip_packages -r requirements.txt
This repository contains two scripts for working with Python virtualenvs.
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:
$ venv_command path/to/venv python
create_venv
creates or updates a virtualenv using a requirements.txt
file.
$ create_venv path/to/venv path/to/requirements.txt
Here’s a complete example:
$ echo mock=2.0.0 > requirements.txt $ ./create_venv venv requirements.txt $ ./venv_command venv 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 mock >>>