title: Pipenv lock: how to cache downloads for transfer to an offline machine
body: <p>I am looking for a way to create a self-contained archive of all dependencies required to satisfy a <code>Pipfile.lock</code>. One way to achieve this would be to point <code>PIPENV_CACHE_DIR</code> at an empty temporary directory, run <code>pipenv install</code>, ship the contents of that directory, and use it on the offline machine.</p>
  <p>E.g., this should work:</p>
  <pre class="lang-sh prettyprint-override"><code>tmpdir=$(mktemp -d)
  if [ -n &quot;$offline&quot; ]; then
      tar -xf pipenv_cache.tar -C &quot;$tmpdir&quot;
  fi
  pipenv --rm
  PIPENV_CACHE_DIR=&quot;$tmpdir&quot; PIP_CACHE_DIR=&quot;$tmpdir&quot; pipenv install
  if [ -n &quot;$online&quot; ]; then
      tar -cf pipenv_cache.tar -C &quot;$tmpdir&quot; .
  fi
  </code></pre>
  <p>However, there are a number of problems with this script, one being that it can’t use the online machine’s cache, having to download everything every time instead.</p>
  <p>The question is, is there a better way, that doesn’t involve a custom script? Maybe some documented community best practices?</p>
  <p>Ideally, there would exist an interface like:</p>
  <pre class="lang-sh prettyprint-override"><code>pipenv lock --create-archive &lt;file_name&gt;
  pipenv install --from-archive &lt;file_name&gt;
  </code></pre>