OLD | NEW |
---|---|
(Empty) | |
1 Bootstrapping the Chromium Infra Repo | |
2 ===================================== | |
3 | |
4 The infra/infra repo uses python [wheel files][1], [virtualenv][2] and [pip][3] | |
5 to manage dependencies. The process for bootstrapping these is contained | |
6 entirely within the bootstrap directory. | |
7 | |
8 1: http://legacy.python.org/dev/peps/pep-0427/ | |
iannucci
2014/12/08 10:41:06
https link: https://www.python.org/dev/peps/pep-04
pgervais
2014/12/09 01:44:30
Done.
| |
9 2: https://github.com/pypa/virtualenv | |
10 3: https://github.com/pypa/pip | |
11 | |
12 | |
13 TL;DR - Workflows | |
14 ~~~~~~~~~~~~~~~~~ | |
15 | |
16 Setting up the env with already-built-deps | |
17 ++++++++++++++++++++++++++++++++++++++++++ | |
18 | |
19 gclient sync | |
20 # OR | |
21 gclient runhooks | |
22 | |
23 Adding a new dep | |
24 ++++++++++++++++ | |
25 Say we want to add a stock `my_pkg` python package at version 1.2.3: | |
26 | |
27 If it comes from a tarball:: | |
28 | |
29 $ ./bootstrap/ingest_source.py <tarball> | |
30 ... | |
31 deadbeefdeadbeefdeadbeefdeadbeef.tar.gz | |
32 | |
33 If it comes from a repo: | |
34 | |
35 File a ticket to have it mirrored (no matter what VCS!) to | |
36 ``chromium.googlesource.com/infra/third_party/my_pkg`` | |
iannucci
2014/12/08 10:41:06
File a ticket..... to ``chromium.googlesource.com/
pgervais
2014/12/09 01:44:30
Done.
| |
37 Grab the git commit hash of the commit to build: badc0ffeebadc0ffeebadc0ffeebadc 0 | |
38 | |
39 Then add the actual dep:: | |
40 | |
41 $ edit bootstrap/deps.pyl # add a new entry (see the 'deps.pyl' section) | |
42 ... | |
43 'my_pkg' : { | |
44 'version': '1.2.3', | |
45 'build': 0, # This is the first build | |
46 'gs': 'deadbeefdeadbeefdeadbeefdeadbeef.tar.gz', # if tarball | |
47 'rev': 'badc0ffeebadc0ffeebadc0ffeebadc0', # if repo | |
48 } | |
49 ... | |
50 | |
51 Then build it:: | |
52 | |
53 $ ./bootstrap/build_deps.py | |
54 # builds and uploads my_pkg-1.2.3-0_deadbeef...-....whl to google storage | |
55 | |
56 If your dep is not pure-python, you will have to run ``build_deps.py`` for each | |
57 platform. | |
iannucci
2014/12/08 10:41:06
This should probably be bold or something. This is
pgervais
2014/12/09 01:44:30
Done.
| |
58 | |
59 | |
60 If your dep needs special treatment | |
61 +++++++++++++++++++++++++++++++++++ | |
62 Do everything in the 'Adding a new dep' section, but before running | |
63 ``build_deps.py``, add a file ``bootstrap/custom_builds/{wheel package name}.py` `. | |
64 This file is expected to implement:: | |
65 | |
66 def Build(source_path, wheelhouse_path) | |
67 | |
68 See `custom builds`_ below for more detail. | |
69 | |
70 | |
71 ``bootstrap.py`` (a.k.a. "I just want a working infra repo!") | |
72 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
73 | |
74 Run ``gclient runhooks``. Under the hood, this is running:: | |
iannucci
2014/12/08 10:41:06
pedantic/nit: s/is running/runs/
pgervais
2014/12/09 01:44:30
This is not being pedantic, this is writing proper
| |
75 | |
76 ./bootstrap/bootstrap.py --deps_file bootstrap/deps.pyl | |
77 | |
78 This creates a virtualenv called ``{repo_root}/ENV`` with all the deps contained | |
79 in ``bootstrap/deps.pyl``. You must be online, or must already have the wheels f or | |
80 your system cached in ``{repo_root}/.wheelcache``. | |
iannucci
2014/12/08 10:41:06
should we be wrapping at 80 everywhere?
pgervais
2014/12/09 01:44:30
Yes, as much as possible. Sometimes hard with very
| |
81 | |
82 If you already have an ``ENV``, ``bootstrap.py`` will check the manifest in | |
83 ``ENV`` to see if it matches `deps.pyl`_ (i.e. the diff is zero). If it's not, | |
84 then ``ENV`` will be re-created *from scratch*. | |
85 | |
86 ``{repo_root}/run.py`` will automatically use the environment ``ENV``. It is an | |
87 error to use ``run.py`` without first setting up ``ENV``. | |
88 | |
89 | |
90 `deps.pyl` | |
91 ~~~~~~~~~~ | |
92 This file is a python dictionary containing the exact versions of all Python | |
93 module dependencies. These versions are the standard upstream package versions | |
94 (e.g. '0.8.0'), plus the commit hash or sha1.{ext} of an ingested source bundle | |
95 (see ``inject_source.py``). | |
96 | |
97 The format of this file is ``{'package_name': <values>}``. This file is a Python | |
98 `ast literal <https://docs.python.org/2/library/ast.html#ast.literal_eval>`_, so | |
99 comments are allowed and encouraged. | |
100 | |
101 Values are: | |
102 * version: The pip version of the module | |
103 * build: An integer representing which build of this version/hash. If you | |
104 modify the _way_ that a requirement is built, but not the source hash, you | |
105 can bump the build number to get a new pinned dependency. | |
106 | |
107 And either: | |
108 * ``rev``: The revision or sha1 of the source for this module. | |
109 The repo is | |
110 ``git+https://chromium.googlesource.com/infra/third_party/{package_name}`` | |
111 * ``gs``: ``{sha1}.{ext}`` indicates file | |
112 ``gs://chrome-infra-wheelhouse/sources/{sha1}.{ext}``. The sha1 will be | |
113 checked against the content of the file. | |
114 | |
115 And optionally: | |
116 * ``implicit``: A boolean indicating that this dep should only be installed as | |
117 a dependency of some other dep. For example, you want package A, which | |
118 depends on package Z, but you don't really care about Z. You should mark | |
119 Z as ``implicit`` to allow it to be pinned correctly, but not to | |
120 deliberately install it. | |
121 | |
122 4: | |
iannucci
2014/12/08 10:41:06
not sure what the `4:` is for?
May also want to e
pgervais
2014/12/09 01:44:30
Dropped and fixed.
| |
123 | |
124 | |
125 ``ingest_source.py`` | |
126 ~~~~~~~~~~~~~~~~~~~~ | |
127 Some python modules don't have functional python repos (i.e. ones that pip | |
128 can natively clone+build), and thus ship their source in tarballs. To ingest | |
129 such a tarball into the infra google storage bucket, use | |
130 `ingest_source.py /path/to/archive`. | |
131 This will print the value for the 'gs' key for a `deps.pyl` entry. | |
132 | |
133 | |
134 `build_deps.py` / rolling deps | |
135 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
136 Any time a new dependency/version is introduced into ``deps.pyl``, you must run | |
137 ``build_deps.py``. If the dependency is a pure-Python dependency (i.e. no compil ed | |
138 extensions), you only need to run it once on CPython 2.7. You can tell that it's | |
139 a pure python module by looking at the name of the wheel file. For example:: | |
140 | |
141 requests-2.3.0-py2.py3-none-any.whl | |
142 | |
143 Is compatible with Python 2 and Python 3 (py2.py3) any python ABI (none), and | |
144 any OS platform (any). | |
145 | |
146 If the module does contain compiled extensions, you must run ``build_deps.py`` | |
147 on the following systems (all with CPython 2.7): | |
148 * OS X 10.9 - ``x86_64`` | |
149 * Windows 7 - ``x86_64`` | |
150 * Linux - ``x86_64`` | |
151 | |
152 TODO(iannucci): Add job to build wheels on all appropriate systems. | |
153 | |
154 Once a wheel is sucessfully built, it is uploaded to | |
155 ``gs://chrome-python-wheelhouse/wheels`` if it is not there already. | |
156 | |
157 Running ``build_deps.py`` will only attempt to build dependencies which are | |
158 missing for the current platform. | |
159 | |
160 ``build_deps.py`` assumes that it can find ``gsutil`` on ``PATH``, so go ahead | |
161 and install it appropriately for whichever platform you're on. You will also | |
162 need write access to the ``chrome-python-wheelhouse`` bucket. | |
163 | |
164 | |
165 custom builds | |
166 ~~~~~~~~~~~~~ | |
167 Sometimes building a wheel is a bit trickier than ``pip wheel {repo}@{hash}``. I n | |
168 order to support this, add a script named ``custom_builds/{name}.py``. This modu le | |
169 should have a function defined like:: | |
170 | |
171 def Build(source_path, wheelhouse_path) | |
172 | |
173 Where ``source_path`` is a string path to the checked-out / unpacked source code , | |
174 and ``wheelhouse_path`` is a string path where ``build_deps.py`` expects to find | |
175 a ``.whl`` file after Build completes. | |
iannucci
2014/12/08 10:41:06
Note that your Build function will actually need t
pgervais
2014/12/09 01:44:30
Added the first paragraph, dropped the footnote.
| |
176 | |
177 | |
178 rolling the version of wheel | |
179 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
180 Since wheel is a package needed to build the wheels, it has a slightly different | |
181 treatment. To roll wheel, bump the version in deps.pyl, and then run | |
182 ``bootstrap_wheel_wheel.sh`` | |
183 to build and upload the wheel for ``wheel`` pinned at the version in ``deps.pyl` `. | |
184 | |
185 Once you do that, ``build_deps.py`` will continue working as expected. | |
186 | |
187 | |
188 Building deps on Windows | |
189 ~~~~~~~~~~~~~~~~~~~~~~~~ | |
190 TODO(iannucci): actually implement this | |
191 | |
192 Windows builds require a slightly more care when building, due to the | |
193 complexities of getting a compile environment. To this effect, ``build_deps.py`` | |
194 relies on the ``depot_tools/win_toolchain`` functionality to get a hermetic | |
195 windows compiler toolchain. This should not be an issue for chromium devs | |
196 working on windows, since they should already have this installed by compiling | |
197 chromium, but it's something to be aware of. | |
198 | |
199 | |
200 modified (non-upstream) deps | |
201 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
202 If it is necessary to roll a patched version of a library, we should branch it | |
203 in the infra googlesource mirror. This branch should be named ``{version}-cr``, | |
204 and will build packages whose version is ``{version}.{cr_version}`` (e.g. modify | |
205 ``setup.py`` on this branch to add an additional component to the version | |
206 field). | |
207 | |
208 For example, given the package ``jane`` at version ``2.1.3``, we would create | |
209 a branch ``2.1.3-cr``. On this branch we would commit any changes necessary to | |
210 ``2.1.3``, and would adjust the version number in the builds to be e.g. | |
211 ``2.1.3.0``. | |
212 | |
213 | |
OLD | NEW |