| # Copyright 2017 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import os |
| |
| from . import util |
| |
| # Default output path of generated Markdown document. |
| DEFAULT_PATH = os.path.join(util.PKG_DIR, 'wheels.md') |
| |
| |
| class Generator(object): |
| _INFRA_GITILES_PATH = 'https://chromium.googlesource.com/infra/infra' |
| _INFRA_DOCKERBUILD_PATH = 'infra/tools/dockerbuild' |
| |
| _HEADER = """\ |
| # dockerbuild-generated wheel packages |
| |
| This file is automatically generated by `dockerbuild`'s `wheel-dump` subcommand. |
| It was generated from the list [here](./wheel.py). |
| |
| Please see [VPython and You] for a brief tutorial on how to use vpython. |
| |
| If there's a wheel you need which is missing, please [file a bug][bug]. |
| |
| [bug]: https://bugs.chromium.org/p/chromium/issues/entry?summary=Need%20VPython%20Wheel&description=Link%20to%20PyPI:%20%0AWheel%20Name:%20%0AVersion:%20%0APlatform%28s%29%20Required:&components=Infra%3EPlatform%3EAdmin |
| [VPython and You]: https://chromium.googlesource.com/infra/infra/+/master/doc/users/vpython_one_page.md |
| |
| [TOC] |
| |
| # Wheel List |
| |
| This list represents the current set of configured `dockerbuild` wheels in |
| [wheel.py](./wheel.py). |
| |
| """ |
| |
| _WHEEL_NAME_TEMPLATE = """\ |
| ## **%(name)s** |
| |
| """ |
| |
| _WHEEL_TEMPLATE = """\ |
| ### %(version)s |
| |
| ```protobuf |
| wheel: < |
| name: "%(package_name)s" |
| version: "%(package_tag)s" |
| > |
| ``` |
| |
| %(supported)s |
| |
| """ |
| |
| _FOOTER = """\ |
| |
| # Contact |
| |
| If a wheel is needed, but is not in this list, please |
| contact Chrome Operations: |
| |
| * `luci-eng@google.com` |
| * [File a bug][bug] |
| """ |
| |
| def __init__(self): |
| self._packages = {} |
| |
| def add_package(self, whl, plat): |
| key = (whl.spec.name, whl.spec.version) |
| _, v = self._packages.setdefault(key, (whl, set())) |
| if plat: |
| v.add(plat) |
| |
| def write(self, fd): |
| fd.write(self._HEADER) |
| |
| categorized_packages = {} |
| for (name, version), (whl, plats) in self._packages.iteritems(): |
| categorized_packages.setdefault(name, {})[version] = (whl, plats) |
| |
| for name, versions in sorted(categorized_packages.items()): |
| fd.write(self._WHEEL_NAME_TEMPLATE % dict( |
| name=name, |
| )) |
| |
| for version, (whl, plats) in sorted(versions.items()): |
| package = whl.cipd_package(templated=True) |
| |
| # Build an italic list of supported platforms. |
| plat_names = sorted([plat.name for plat in plats] or ('universal',)) |
| supported = '\n'.join([''] + [ |
| '* *%s*' % (plat_name,) |
| for plat_name in plat_names]) |
| |
| fd.write(self._WHEEL_TEMPLATE % dict( |
| version=version, |
| supported=supported, |
| package_name=package.name, |
| package_tag=package.tags[0], |
| )) |
| |
| fd.write(self._FOOTER) |