source: trunk/docs/build/build-on-desert-island.rst

Last change on this file was f67c75c, checked in by Florian Sesser <florian@…>, at 2024-08-22T17:08:51Z

Merge moving build docs to developer documentation

  • Property mode set to 100644
File size: 5.5 KB
Line 
1***************************************
2Building Tahoe-LAFS On A Desert Island
3***************************************
4
5(or an airplane, or anywhere else without internet connectivity)
6
7Here's the story: you leave for the airport in an hour, you know you want to
8do some Tahoe hacking on the flight. What can you grab right now that will
9let you install the necessary dependencies later, when you are offline?
10
11Pip can help, with a technique described in the pip documentation
12https://pip.pypa.io/en/stable/user_guide/#installing-from-local-packages .
13
14First, do two setup steps:
15
16* ``mkdir ~/.pip/wheels``
17* edit ``~/.pip/pip.conf`` to set ``[global] find-links = ~/.pip/wheels``
18
19(the filename may vary on non-unix platforms: check the pip documentation for
20details)
21
22This instructs all ``pip install`` commands to look in your local directory
23for compiled wheels, in addition to asking PyPI and the normal wheel cache.
24
25Before you get shipwrecked (or leave the internet for a while), do this from
26your tahoe source tree (or any python source tree that you want to hack on):
27
28* ``pip wheel -w ~/.pip/wheels .``
29
30That command will require network and time: it will download and compile
31whatever is necessary right away. Schedule your shipwreck for *after* it
32completes.
33
34Specifically, it will get wheels for everything that the current project
35(".", i.e. tahoe) needs, and write them to the ``~/.pip/wheels`` directory.
36It will query PyPI to learn the current version of every dependency, then
37acquire wheels from the first source that has one:
38
39* copy from our ``~/.pip/wheels`` directory
40* copy from the local wheel cache (see below for where this lives)
41* download a wheel from PyPI
42* build a wheel from a tarball (cached or downloaded)
43
44Later, on the plane, do this:
45
46* ``virtualenv --no-download ve``
47* ``. ve/bin/activate``
48* ``pip install --no-index --editable .``
49
50That tells virtualenv/pip to not try to contact PyPI, and your ``pip.conf``
51"find-links" tells them to use the wheels in ``~/.pip/wheels/`` instead.
52
53How This Works
54==============
55
56The pip wheel cache
57-------------------
58
59Modern versions of pip and setuptools will, by default, cache both their HTTP
60downloads and their generated wheels. When pip is asked to install a package,
61it will first check with PyPI. If the PyPI index says it needs to download a
62newer version, but it can find a copy of the tarball/zipball/wheel in the
63HTTP cache, it will not actually download anything. Then it tries to build a
64wheel: if it already has one in the wheel cache (downloaded or built
65earlier), it will not actually build anything.
66
67If it cannot contact PyPI, it will fail. The ``--no-index`` above is to tell
68it to skip the PyPI step, but that leaves it with no source of packages. The
69``find-links`` setting is what provides an alternate source of packages.
70
71The HTTP and wheel caches are not single flat directories: they use a
72hierarchy of subdirectories, named after a hash of the URL or name of the
73object being stored (this is to avoid filesystem limitations on the size of a
74directory). As a result, the wheel cache is not suitable for use as a
75``find-links`` target (but see below).
76
77There is a command named ``pip wheel`` which only creates wheels (and stores
78them in ``--wheel-dir=``, which defaults to the current directory). This
79command does not populate the wheel cache: it reads from (and writes to) the
80HTTP cache, and reads from the wheel cache, but will only save the generated
81wheels into the directory you specify with ``--wheel-dir=``.
82
83Where Does The Cache Live?
84--------------------------
85
86Pip's cache location depends upon the platform. On linux, it defaults to
87~/.cache/pip/ (both http/ and wheels/). On OS-X (homebrew), it uses
88~/Library/Caches/pip/ . On Windows, try ~\AppData\Local\pip\cache .
89
90The location can be overridden by ``pip.conf``. Look for the "wheel-dir",
91"cache-dir", and "find-links" options.
92
93How Can I Tell If It's Using The Cache?
94---------------------------------------
95
96When "pip install" has to download a source tarball (and build a wheel), it
97will say things like::
98
99 Collecting zfec
100  Downloading zfec-1.4.24.tar.gz (175kB)
101 Building wheels for collected packages: zfec
102  Running setup.py bdist_wheel for zfec ... done
103  Stored in directory: $CACHEDIR
104 Successfully built zfec
105 Installing collected packages: zfec
106 Successfully installed zfec-1.4.24
107
108When "pip install" can use a cached downloaded tarball, but does not have a
109cached wheel, it will say::
110
111 Collecting zfec
112  Using cached zfec-1.4.24.tar.gz
113 Building wheels for collected packages: zfec
114  Running setup.py bdist_wheel for zfec ... done
115  Stored in directory: $CACHEDIR
116 Successfully built zfec
117 Installing collected packages: zfec
118 Successfully installed zfec-1.4.24
119
120When "pip install" can use a cached wheel, it will just say::
121
122 Collecting zfec
123 Installed collected packages: zfec
124 Successfully installed zfec-1.4.24
125
126Many packages publish pre-built wheels next to their source tarballs. This is
127common for non-platform-specific (pure-python) packages. It is also common
128for them to provide pre-compiled windows and OS-X wheel, so users do not have
129to have a compiler installed (pre-compiled Linux wheels are not common,
130because there are too many platform variations). When "pip install" can use a
131downloaded wheel like this, it will say::
132
133 Collecting six
134  Downloading six-1.10.0-py2.py3-none-any.whl
135 Installing collected packages: six
136 Successfully installed six-1.10.0
137
138Note that older versions of pip do not always use wheels, or the cache. Pip
1398.0.0 or newer should be ok. The version of setuptools may also be
140significant.
Note: See TracBrowser for help on using the repository browser.