2016-04-01 00:12:08 +00:00
|
|
|
******************************************
|
2016-03-23 01:18:49 +00:00
|
|
|
How To Build Tahoe-LAFS On A Desert Island
|
2016-04-01 00:12:08 +00:00
|
|
|
******************************************
|
2016-03-23 01:18:49 +00:00
|
|
|
|
|
|
|
(or an airplane, or anywhere else without internet connectivity)
|
|
|
|
|
2016-04-01 00:12:08 +00:00
|
|
|
Here's the story: you leave for the airport in an hour, you know you want to
|
|
|
|
do some Tahoe hacking on the flight. What can you grab right now that will
|
|
|
|
let you install the necessary dependencies later, when you are offline?
|
2016-03-23 01:18:49 +00:00
|
|
|
|
|
|
|
Pip can help, with a technique described in the pip documentation
|
|
|
|
https://pip.pypa.io/en/stable/user_guide/#installing-from-local-packages .
|
|
|
|
|
2016-04-01 00:12:08 +00:00
|
|
|
First, do two setup steps:
|
|
|
|
|
|
|
|
* ``mkdir ~/.pip/wheels``
|
|
|
|
* edit ``~/.pip/pip.conf`` to set ``[global] find-links = ~/.pip/wheels``
|
|
|
|
|
|
|
|
(the filename may vary on non-unix platforms: check the pip documentation for
|
|
|
|
details)
|
|
|
|
|
|
|
|
This instructs all ``pip install`` commands to look in your local directory
|
|
|
|
for compiled wheels, in addition to asking PyPI and the normal wheel cache.
|
|
|
|
|
2016-03-23 01:18:49 +00:00
|
|
|
Before you get shipwrecked (or leave the internet for a while), do this from
|
2016-04-01 00:12:08 +00:00
|
|
|
your tahoe source tree (or any python source tree that you want to hack on):
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-04-01 00:12:08 +00:00
|
|
|
* ``pip wheel -w ~/.pip/wheels .``
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-04-01 00:12:08 +00:00
|
|
|
That command will require network and time: it will download and compile
|
|
|
|
whatever is necessary right away. Schedule your shipwreck for *after* it
|
|
|
|
completes.
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-04-01 00:12:08 +00:00
|
|
|
Specifically, it will get wheels for everything that the current project
|
|
|
|
(".", i.e. tahoe) needs, and write them to the ``~/.pip/wheels`` directory.
|
|
|
|
It will query PyPI to learn the current version of every dependency, then
|
|
|
|
acquire wheels from the first source that has one:
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-04-01 00:12:08 +00:00
|
|
|
* copy from our ``~/.pip/wheels`` directory
|
|
|
|
* copy from the local wheel cache (see below for where this lives)
|
|
|
|
* download a wheel from PyPI
|
|
|
|
* build a wheel from a tarball (cached or downloaded)
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-04-01 00:12:08 +00:00
|
|
|
Later, on the plane, do this:
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-04-01 00:12:08 +00:00
|
|
|
* ``virtualenv --no-download ve``
|
|
|
|
* ``. ve/bin/activate``
|
|
|
|
* ``pip install --no-index --editable .``
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-04-01 00:12:08 +00:00
|
|
|
That tells virtualenv/pip to not try to contact PyPI, and your ``pip.conf``
|
|
|
|
"find-links" tells them to use the wheels in ``~/.pip/wheels/`` instead.
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-04-01 00:12:08 +00:00
|
|
|
How This Works
|
|
|
|
==============
|
2016-03-23 01:18:49 +00:00
|
|
|
|
|
|
|
The pip wheel cache
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
Modern versions of pip and setuptools will, by default, cache both their HTTP
|
|
|
|
downloads and their generated wheels. When pip is asked to install a package,
|
|
|
|
it will first check with PyPI. If the PyPI index says it needs to download a
|
|
|
|
newer version, but it can find a copy of the tarball/zipball/wheel in the
|
|
|
|
HTTP cache, it will not actually download anything. Then it tries to build a
|
|
|
|
wheel: if it already has one in the wheel cache (downloaded or built
|
|
|
|
earlier), it will not actually build anything.
|
|
|
|
|
2016-03-30 07:55:21 +00:00
|
|
|
If it cannot contact PyPI, it will fail. The ``--no-index`` above is to tell
|
|
|
|
it to skip the PyPI step, but that leaves it with no source of packages. The
|
2016-04-01 00:12:08 +00:00
|
|
|
``find-links`` setting is what provides an alternate source of packages.
|
2016-03-23 01:18:49 +00:00
|
|
|
|
|
|
|
The HTTP and wheel caches are not single flat directories: they use a
|
|
|
|
hierarchy of subdirectories, named after a hash of the URL or name of the
|
|
|
|
object being stored (this is to avoid filesystem limitations on the size of a
|
|
|
|
directory). As a result, the wheel cache is not suitable for use as a
|
2016-04-01 00:12:08 +00:00
|
|
|
``find-links`` target (but see below).
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-03-30 07:55:21 +00:00
|
|
|
There is a command named ``pip wheel`` which only creates wheels (and stores
|
|
|
|
them in ``--wheel-dir=``, which defaults to the current directory). This
|
2016-03-23 01:18:49 +00:00
|
|
|
command does not populate the wheel cache: it reads from (and writes to) the
|
|
|
|
HTTP cache, and reads from the wheel cache, but will only save the generated
|
2016-04-01 00:12:08 +00:00
|
|
|
wheels into the directory you specify with ``--wheel-dir=``.
|
2016-03-23 01:18:49 +00:00
|
|
|
|
|
|
|
Where Does The Cache Live?
|
|
|
|
--------------------------
|
|
|
|
|
|
|
|
Pip's cache location depends upon the platform. On linux, it defaults to
|
|
|
|
~/.cache/pip/ (both http/ and wheels/). On OS-X (homebrew), it uses
|
|
|
|
~/Library/Caches/pip/ . On Windows, try ~\AppData\Local\pip\cache .
|
|
|
|
|
2016-03-30 07:55:21 +00:00
|
|
|
The location can be overridden by ``pip.conf``. Look for the "wheel-dir",
|
2016-03-23 01:18:49 +00:00
|
|
|
"cache-dir", and "find-links" options.
|
|
|
|
|
|
|
|
How Can I Tell If It's Using The Cache?
|
|
|
|
---------------------------------------
|
|
|
|
|
|
|
|
When "pip install" has to download a source tarball (and build a wheel), it
|
2016-03-30 07:55:21 +00:00
|
|
|
will say things like::
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-03-30 07:55:21 +00:00
|
|
|
Collecting zfec
|
|
|
|
Downloading zfec-1.4.24.tar.gz (175kB)
|
|
|
|
Building wheels for collected packages: zfec
|
|
|
|
Running setup.py bdist_wheel for zfec ... done
|
|
|
|
Stored in directory: $CACHEDIR
|
|
|
|
Successfully built zfec
|
|
|
|
Installing collected packages: zfec
|
|
|
|
Successfully installed zfec-1.4.24
|
2016-03-23 01:18:49 +00:00
|
|
|
|
|
|
|
When "pip install" can use a cached downloaded tarball, but does not have a
|
2016-03-30 07:55:21 +00:00
|
|
|
cached wheel, it will say::
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-03-30 07:55:21 +00:00
|
|
|
Collecting zfec
|
|
|
|
Using cached zfec-1.4.24.tar.gz
|
|
|
|
Building wheels for collected packages: zfec
|
|
|
|
Running setup.py bdist_wheel for zfec ... done
|
|
|
|
Stored in directory: $CACHEDIR
|
|
|
|
Successfully built zfec
|
|
|
|
Installing collected packages: zfec
|
|
|
|
Successfully installed zfec-1.4.24
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-03-30 07:55:21 +00:00
|
|
|
When "pip install" can use a cached wheel, it will just say::
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-03-30 07:55:21 +00:00
|
|
|
Collecting zfec
|
|
|
|
Installed collected packages: zfec
|
|
|
|
Successfully installed zfec-1.4.24
|
2016-03-23 01:18:49 +00:00
|
|
|
|
|
|
|
Many packages publish pre-built wheels next to their source tarballs. This is
|
|
|
|
common for non-platform-specific (pure-python) packages. It is also common
|
|
|
|
for them to provide pre-compiled windows and OS-X wheel, so users do not have
|
|
|
|
to have a compiler installed (pre-compiled Linux wheels are not common,
|
|
|
|
because there are too many platform variations). When "pip install" can use a
|
2016-03-30 07:55:21 +00:00
|
|
|
downloaded wheel like this, it will say::
|
2016-03-23 01:18:49 +00:00
|
|
|
|
2016-03-30 07:55:21 +00:00
|
|
|
Collecting six
|
|
|
|
Downloading six-1.10.0-py2.py3-none-any.whl
|
|
|
|
Installing collected packages: six
|
|
|
|
Successfully installed six-1.10.0
|
2016-03-23 01:18:49 +00:00
|
|
|
|
|
|
|
Note that older versions of pip do not always use wheels, or the cache. Pip
|
|
|
|
8.0.0 or newer should be ok. The version of setuptools may also be
|
|
|
|
significant.
|