For this example, we'll be adding ‘scandir’ at version 1.7.
Go to pypi and find the wheel at the appropriate version in question.
Determine what type of wheel it is (in order of preference):
*-py2.py3-none-any.whl
file (may be just py2)*.tar.gz
file. You'll have to fetch this tarball and look to see if it contains any .c or .cc files. If it does, then this is either Prebuilt
or SourceOrPrebuilt
.SourceOrPrebuilt.
*.tar.gz
with the library source, but may also contain .whl
files for some platforms.Once you've identified the wheel type, open wheels.py and find the relevant section. Each section is ordered by wheel name and then by symver. If you put the wheel definition in the wrong place, dockerbuild will tell you :)
So for scandir
, we see that there are prebuilts for windows, but for everything else we have to build it ourself.
The wheels are built for linux platforms using Docker (hence “dockerbuild”). Unfortunately this tool ONLY supports building for linux this way. For building mac and windows, this can use the ambient toolchain (i.e. have XCode or MSVS installed on your system).
I actually haven't ever run this on windows. Usually python wheels with C extensions that chromium may actually need have pre-built windows wheels.
That said, this is essentially just doing setup.py bdist_wheel
to generate the wheel contents, so if that process works with MSVS, it SHOULD work.
The upshot of this is that if you need to build for e.g. mac or windows, you need to run this from one of those platforms with an appropriate SDK installed.
Back to our example, we'll be adding a new entry to the SourceOrPrebuilt section:
SourceOrPrebuilt('scandir', '1.9.0', packaged=[ 'windows-x86', 'windows-x64', ], ),
This says the wheel scandir-1.9.0
is either built from source (.tar.gz) or is prebuilt (for the following packaged
platforms).
And update the wheel.md documentation:
vpython3 -m infra.tools.dockerbuild \ wheel-dump
Now, test that your wheel builds successfully using the following:
vpython3 -m infra.tools.dockerbuild \ --logs-debug \ wheel-build \ --wheel 'scandir-1.9.0' \
Notable options (check --help
for details):
--wheel_re
- Use in place of --wheel
to run for multiple wheels or versions.--platform
- Specify a specific platform to build for.Then you upload your CL and commit as usual.
Once your CL is committed, the wheels will be automatically built and uploaded by the following builders:
While we strongly prefer to not patch anything, sometimes we need a backport or local fix for our system.
Here's the quick overview:
UniversalSource
since we need to unpack the source & patch it directly before building the wheel.patches/
.-p1
format..patch
. e.g. UniversalSource('scandir', '1.9.0')
will have a prefix of scandir-1.9.0-
and a suffix of .patch
.patches=(...)
tuple to UniversalSource
.A short example:
UniversalSource('scandir', '1.9.0', patches=( 'some-fix', 'another-change', )),
This will apply the two patches:
patches/scandir-1.9.0-some-fix.patch
patches/scandir-1.9.0-another-change.patch