-
Notifications
You must be signed in to change notification settings - Fork 312
[doc-only] docs: document setuptools-scm clone requirements for source builds #2424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bharatr21
wants to merge
1
commit into
NVIDIA:main
Choose a base branch
from
bharatr21:setuptools-scm-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+138
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,10 @@ Thank you for your interest in contributing to CUDA Python! Based on the type of | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - [Contributing to CUDA Python](#contributing-to-cuda-python) | ||||||||||||||||||||||||||||
| - [Table of Contents](#table-of-contents) | ||||||||||||||||||||||||||||
| - [Cloning the repository](#cloning-the-repository) | ||||||||||||||||||||||||||||
| - [Recommended clone](#recommended-clone) | ||||||||||||||||||||||||||||
| - [Fixing an existing clone](#fixing-an-existing-clone) | ||||||||||||||||||||||||||||
| - [Symptoms of a bad clone](#symptoms-of-a-bad-clone) | ||||||||||||||||||||||||||||
| - [Type stubs for cuda.core](#type-stubs-for-cudacore) | ||||||||||||||||||||||||||||
| - [Pre-commit](#pre-commit) | ||||||||||||||||||||||||||||
| - [Signing Your Work](#signing-your-work) | ||||||||||||||||||||||||||||
|
|
@@ -34,6 +38,113 @@ Thank you for your interest in contributing to CUDA Python! Based on the type of | |||||||||||||||||||||||||||
| - [Code coverage](#code-coverage) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## Cloning the repository | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Every package in this repository derives its version from git tags using | ||||||||||||||||||||||||||||
| [`setuptools-scm`](https://setuptools-scm.readthedocs.io/), so **how you clone | ||||||||||||||||||||||||||||
| determines whether you can build at all, and whether the version you build is | ||||||||||||||||||||||||||||
| correct.** Each package matches its own tag prefix: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| | Package | Tag pattern | | ||||||||||||||||||||||||||||
| | --- | --- | | ||||||||||||||||||||||||||||
| | `cuda-bindings`, `cuda-python` | `v*` (e.g. `v13.3.1`) | | ||||||||||||||||||||||||||||
| | `cuda-core` | `cuda-core-v*` (e.g. `cuda-core-v1.1.0`) | | ||||||||||||||||||||||||||||
| | `cuda-pathfinder` | `cuda-pathfinder-v*` (e.g. `cuda-pathfinder-v1.6.0`) | | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Each package sets `root = ".."` in its `[tool.setuptools_scm]` table, meaning the | ||||||||||||||||||||||||||||
| version is read from the *repository root* rather than the package directory. A | ||||||||||||||||||||||||||||
| working build therefore needs all of the following: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 1. **A real git clone.** Source zips and GitHub "Download ZIP" archives have no | ||||||||||||||||||||||||||||
| git metadata and the build fails outright. (Tarballs produced by | ||||||||||||||||||||||||||||
| `git archive` do work, thanks to the `.git_archival.txt` substitutions | ||||||||||||||||||||||||||||
| configured in `.gitattributes`.) | ||||||||||||||||||||||||||||
| 2. **The full repository**, not just the package subdirectory, because the | ||||||||||||||||||||||||||||
| version lookup walks up to the repository root. | ||||||||||||||||||||||||||||
| 3. **Tags, reaching back at least as far as the most recent tag** matching the | ||||||||||||||||||||||||||||
| package you are building. `git describe` needs to find that tag; the history | ||||||||||||||||||||||||||||
| between it and your checkout must be present too. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Each package is tagged on its own cadence, so the distance from `main` back to | ||||||||||||||||||||||||||||
| the relevant tag differs per package and grows as commits land between releases. | ||||||||||||||||||||||||||||
| There is no `--depth` value that is safe for all four packages, and any value | ||||||||||||||||||||||||||||
| that works today will silently stop working later. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| This makes a partial `--depth` actively dangerous, because it can succeed for one | ||||||||||||||||||||||||||||
| package while quietly failing for the others. A `--depth 20` clone taken while | ||||||||||||||||||||||||||||
| the nearest `cuda-pathfinder-v*` tag was 10 commits back gives: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```text | ||||||||||||||||||||||||||||
| cuda_pathfinder -> 1.6.1.dev10+g0d22cb4 # correct | ||||||||||||||||||||||||||||
| cuda_core -> 0.1.dev20+g0d22cb444 # wrong, no error | ||||||||||||||||||||||||||||
| cuda_bindings -> 0.1.dev20+g0d22cb444 # wrong, no error | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Recommended clone | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```console | ||||||||||||||||||||||||||||
| $ git clone --filter=blob:none https://github.com/NVIDIA/cuda-python.git | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| This is a *treeless* clone: it fetches the complete commit graph and all tags | ||||||||||||||||||||||||||||
| (which is what `setuptools-scm` needs) while skipping historical file contents | ||||||||||||||||||||||||||||
| (which it does not). It is substantially faster than a plain clone and is | ||||||||||||||||||||||||||||
| exactly what CI uses — see the `fetch-depth: 0` plus `filter: blob:none` | ||||||||||||||||||||||||||||
| checkout settings in `.github/workflows/build-wheel.yml`. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Do **not** use `--depth`, `--shallow-since`, or `--no-tags`. | ||||||||||||||||||||||||||||
|
Comment on lines
+83
to
+95
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we just recommend the defaults, tbh.
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Fixing an existing clone | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| If you already have a shallow clone: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```console | ||||||||||||||||||||||||||||
| $ git fetch --unshallow --tags | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| If you are working from a personal fork, your fork's tags stop tracking upstream | ||||||||||||||||||||||||||||
| the moment new releases are cut, which silently yields a stale version. Fetch | ||||||||||||||||||||||||||||
| tags from upstream directly: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```console | ||||||||||||||||||||||||||||
| $ git remote add upstream https://github.com/NVIDIA/cuda-python.git | ||||||||||||||||||||||||||||
| $ git fetch --tags upstream | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Keep doing this periodically — a fork that was correct when you created it will | ||||||||||||||||||||||||||||
| drift. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Symptoms of a bad clone | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Only case 3 below reports an error. The first two fail *silently*, producing a | ||||||||||||||||||||||||||||
| wrong version that surfaces much later as a confusing dependency-resolution or | ||||||||||||||||||||||||||||
| version-check failure: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 1. **No tags reachable.** The build succeeds and produces a version starting at | ||||||||||||||||||||||||||||
| `0.1.dev`: a `--depth 1` clone yields `0.1.dev1+g0d22cb444`, a full clone made | ||||||||||||||||||||||||||||
| with `--no-tags` yields `0.1.dev2114+g0d22cb444`. Installing `cuda-python` | ||||||||||||||||||||||||||||
| built this way then fails, because its `install_requires` pins | ||||||||||||||||||||||||||||
| `cuda-bindings` to that same bogus version. | ||||||||||||||||||||||||||||
| 2. **Stale tags** (a fork that has not fetched upstream in a while): you get a | ||||||||||||||||||||||||||||
| plausible-looking but wrong version, e.g. `13.0.4.dev650+g0d22cb44` when the | ||||||||||||||||||||||||||||
| real latest tag is `v13.3.1`. Nothing warns you. Note there is no leading | ||||||||||||||||||||||||||||
| `v` — the tag prefix is stripped by `tag_regex`. | ||||||||||||||||||||||||||||
| 3. **No git metadata** (source zip): the build fails with | ||||||||||||||||||||||||||||
| `LookupError: setuptools-scm was unable to detect version`. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| As a last resort — for example when building inside a container that has no git | ||||||||||||||||||||||||||||
| history — you can bypass the lookup entirely: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```console | ||||||||||||||||||||||||||||
| $ SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CUDA_CORE=1.1.0 pip install ./cuda_core | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| The environment variable is suffixed with the distribution name, uppercased with | ||||||||||||||||||||||||||||
| hyphens replaced by underscores: `..._FOR_CUDA_BINDINGS`, `..._FOR_CUDA_CORE`, | ||||||||||||||||||||||||||||
| `..._FOR_CUDA_PATHFINDER`, `..._FOR_CUDA_PYTHON`. Use this only when you | ||||||||||||||||||||||||||||
| genuinely cannot provide tags; it is not a substitute for a correct clone. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## Type stubs for cuda.core | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| `cuda.core` is a PEP 561-compliant package: it ships a `py.typed` marker and | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is way too much detail.