|
1 | 1 | # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | | -"""Build helpers shared by the cuda-bindings and cuda-core PEP 517 backends. |
| 4 | +"""Build helpers shared by the cuda-bindings, cuda-core and cuda-pathfinder builds. |
5 | 5 |
|
6 | 6 | ``cuda_bindings_13/_build_shared.py`` is canonical. ``cuda_core/_build_shared.py`` |
7 | | -is either a symlink to it or a byte-for-byte identical copy. Both backends load |
| 7 | +and ``cuda_pathfinder/_build_shared.py`` are each either a symlink to it or a |
| 8 | +byte-for-byte identical copy. Both backends load |
8 | 9 | the helper through their package-local path, keeping ``Path(__file__)``-relative |
9 | 10 | state package-local. |
10 | 11 |
|
|
30 | 31 | import functools |
31 | 32 | import hashlib |
32 | 33 | import os |
| 34 | +import re |
33 | 35 | import shlex |
34 | 36 | import shutil |
35 | 37 | import sys |
@@ -509,3 +511,29 @@ def record_build_key(stamp, key): |
509 | 511 | """ |
510 | 512 | stamp.parent.mkdir(parents=True, exist_ok=True) |
511 | 513 | stamp.write_text(key + "\n", encoding="utf-8") |
| 514 | + |
| 515 | + |
| 516 | +_SOURCE_LINK_RE = re.compile(r"(https://github\.com/NVIDIA/cuda-python/(?:blob|tree))/main/") |
| 517 | + |
| 518 | + |
| 519 | +def make_egg_info_command(tag_prefix): |
| 520 | + """Return an ``egg_info`` command that pins README source links to the release tag. |
| 521 | +
|
| 522 | + DESCRIPTION.rst links to ``main`` so that it renders correctly in the |
| 523 | + repository. In a release build, the command pins those links to the tag |
| 524 | + that produced the wheel (``tag_prefix`` followed by the version), so that |
| 525 | + they survive later repository changes. Development builds keep ``main``. |
| 526 | + """ |
| 527 | + from packaging.version import Version |
| 528 | + from setuptools.command.egg_info import egg_info |
| 529 | + |
| 530 | + class ReleaseLinksEggInfo(egg_info): |
| 531 | + def run(self): |
| 532 | + metadata = self.distribution.metadata |
| 533 | + version = Version(self.distribution.get_version()) |
| 534 | + if not (version.is_devrelease or version.local): |
| 535 | + tag = f"{tag_prefix}{version}" |
| 536 | + metadata.long_description = _SOURCE_LINK_RE.sub(rf"\1/{tag}/", metadata.long_description) |
| 537 | + super().run() |
| 538 | + |
| 539 | + return ReleaseLinksEggInfo |
0 commit comments