Skip to content

[no-ci] cuda_core: fix SPDX identifiers and enforce Apache-2.0 headers#1897

Open
rwgk wants to merge 5 commits intoNVIDIA:mainfrom
rwgk:cuda_core_license_fixes
Open

[no-ci] cuda_core: fix SPDX identifiers and enforce Apache-2.0 headers#1897
rwgk wants to merge 5 commits intoNVIDIA:mainfrom
rwgk:cuda_core_license_fixes

Conversation

@rwgk
Copy link
Copy Markdown
Collaborator

@rwgk rwgk commented Apr 13, 2026

Summary

  • Correct the affected cuda_core/ SPDX-License-Identifier headers so they consistently use Apache-2.0.
  • Refactor toolshed/check_spdx.py so expected license identifiers can be enforced by path prefix, and require Apache-2.0 for files under cuda_core/.
  • Keep focused regression coverage in toolshed/test_check_spdx.py for the new cuda_core/ rule, path normalization, and the existing staged-file copyright autofix flow.

Validation

  • pre-commit run --all-files
  • pixi run --manifest-path "cuda_pathfinder" pytest toolshed/test_check_spdx.py -q
  • Output after locally and temporarily reverting commit 7738635:
$ pre-commit run --all-files
ruff check...............................................................Passed
ruff format..............................................................Passed
Check SPDX Headers.......................................................Failed
- hook id: check-spdx
- exit code: 1

INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/graph/test_graphdef.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/cuda/core/_utils/driver_cu_result_explanations.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/graph/test_graphdef_lifetime.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/cuda/core/_utils/clear_error_support.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/helpers/collection_interface_testers.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/cuda/core/_utils/enum_explanations_helpers.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/graph/test_graphdef_integration.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/graph/test_graph_memory_resource.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/cuda/core/_include/utility.hpp'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/graph/test_graph_builder_conditional.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/test_utils_enum_explanations_helpers.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/test_utils.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/test_optional_dependency_imports.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/graph/test_device_launch.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/cuda/core/_utils/runtime_cuda_error_explanations.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/graph/test_graphdef_errors.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/test_linker.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/cuda/core/_utils/driver_cu_result_explanations_frozen.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/helpers/graph_kernels.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/cuda/core/_utils/__init__.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/helpers/marks.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/graph/test_graphdef_mutation.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/graph/test_graph_builder.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/graph/test_graph_update.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/test_cuda_utils.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/pytest.ini'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/cuda/core/_utils/runtime_cuda_error_explanations_frozen.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/graph/test_options.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/cython/test_get_cuda_native_handle.pyx'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/cython/test_cython.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/test_program.py'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/cuda/core/_include/layout.hpp'
INVALID SPDX license identifier 'LicenseRef-NVIDIA-SOFTWARE-LICENSE' (expected 'Apache-2.0') in 'cuda_core/tests/test_helpers.py'

Prevent markdown files in docs/source directories....(no files to check)Skipped
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check docstring is first.................................................Passed
check for merge conflicts................................................Passed
check for broken symlinks................................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed
debug statements (python)................................................Passed
fix end of files.........................................................Passed
mixed line ending........................................................Passed
trim trailing whitespace.................................................Passed
rst ``code`` is two backticks............................................Passed
rst directives end with two colons.......................................Passed
rst ``inline code`` next to normal text..................................Passed
mypy-pathfinder..........................................................Passed
Lint GitHub Actions workflow files.......................................Passed
cython-lint..............................................................Passed

rwgk added 2 commits April 12, 2026 20:12
Refactor the SPDX checker so package-specific license rules can be enforced cleanly while preserving the existing autofix flow. Keep focused regression coverage alongside the toolshed script instead of in routine package test collection.

Made-with: Cursor
@rwgk rwgk added this to the cuda.core v1.0.0 milestone Apr 13, 2026
@rwgk rwgk self-assigned this Apr 13, 2026
@rwgk rwgk added bug Something isn't working P1 Medium priority - Should do cuda.core Everything related to the cuda.core module labels Apr 13, 2026
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot bot commented Apr 13, 2026

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@rwgk
Copy link
Copy Markdown
Collaborator Author

rwgk commented Apr 13, 2026

/ok to test

@github-actions
Copy link
Copy Markdown

@rwgk rwgk marked this pull request as ready for review April 13, 2026 16:00
@rwgk rwgk requested a review from mdboom April 13, 2026 16:58
normalized_path = filepath.replace("\\", "/")
while normalized_path.startswith("./"):
normalized_path = normalized_path[2:]
return normalized_path
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this differ from / why doesn't it use os.path.normpath?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor found a better implementation. I asked it to add a full explanation. Please take another look:

commit eef3902

assert "OUTDATED copyright '2024' (expected '2026')" in capsys.readouterr().out
assert "Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved." in path.read_text(
encoding="ascii"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add this to CI or just remove it. It's only going to bitrot if it sits here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: commit 36a4914

rwgk added 3 commits April 13, 2026 11:56
Use a standard-library path normalizer so repo-prefix checks treat Windows-style paths consistently on any host. Document why os.path.normpath is not suitable for this forward-slash prefix comparison.

Made-with: Cursor
@rwgk rwgk changed the title cuda_core: fix SPDX identifiers and enforce Apache-2.0 headers [no-ci] cuda_core: fix SPDX identifiers and enforce Apache-2.0 headers Apr 13, 2026
@rwgk
Copy link
Copy Markdown
Collaborator Author

rwgk commented Apr 13, 2026

I added [no-ci] to the PR title to not waste our CI resources: we had one successful run already:

I'll push updates to toolshed/check_spdx.py, they will still be exercised with the pre-commit.ci - pr workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.core Everything related to the cuda.core module P1 Medium priority - Should do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants