You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2882a6d
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+65Lines changed: 65 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,5 +18,70 @@ path = "."
18
18
module = "project"
19
19
```
20
20
21
+
## Dependency license files
22
+
23
+
License collection is opt-in. `go-licenses` must be installed and available on `PATH`;
24
+
the plugin does not install it automatically. The tested collector version is 2.0.1:
25
+
26
+
```bash
27
+
go install github.com/google/go-licenses/v2@v2.0.1
28
+
```
29
+
30
+
```toml
31
+
[tool.hatch.build.hooks.hatch-go]
32
+
path = "."
33
+
module = "project"
34
+
35
+
[tool.hatch.build.hooks.hatch-go.licenses]
36
+
destination = "project/licenses/go"
37
+
```
38
+
39
+
The plugin runs `go-licenses save .` in the configured Go project after a successful
40
+
build. Collection uses the build's `GOOS`, `GOARCH`, `CGO_ENABLED`, and Python CGO flags,
41
+
plus effective `GOFLAGS` from the environment or Go's persisted configuration.
42
+
Dependency-selection flags in `go_build_flags`, including `-tags`, `-mod`, `-modfile`,
43
+
`-overlay`, `-compiler`, and instrumentation flags, are passed through `GOFLAGS`.
44
+
Explicit build tags override inherited tags. Shell-dependent flags and values that
45
+
cannot be represented safely for collection fail rather than being ignored. The
46
+
collector uses Go's package loader without external `GOPACKAGESDRIVER` overrides;
47
+
the loader disables PGO, so this is not a reproduction of optimization settings.
48
+
49
+
`destination` is a normalized, wheel-relative **directory**, not a JSON file. Saved
50
+
files appear under Go library import paths, for example
51
+
`project/licenses/go/example.com/dependency/LICENSE`. Their bytes, filenames, and notices
52
+
remain unchanged. The directory is generated outside the project and force-included in
53
+
standard and editable wheels, then removed after packaging. Source distributions do not
54
+
run collection or contain these temporary files. Existing destinations, conflicting forced
55
+
inclusions, and paths rewritten by Hatch sources are rejected. Each saved file is included
56
+
explicitly so Hatch's directory filters do not remove collector artifacts.
57
+
58
+
For editable installations, use `importlib.metadata.distribution(...).locate_file(...)`
59
+
to locate installed license resources. Source-package resource APIs may not see
60
+
force-included files stored in the editable wheel.
61
+
62
+
Missing or unknown licenses, collector failures, empty license texts, and saved symlinks
63
+
fail the build. This applies to the root Go package as well as dependencies: the collector
64
+
needs an original license file for the project. Unknown options are rejected; there is no
65
+
blanket ignore or generic license-text substitution. `SKIP_HATCH_GO`, `skip = true`, and
66
+
source-distribution builds also skip collection. Builds without `licenses` are unchanged.
67
+
68
+
### Scope and review
69
+
70
+
The inventory covers direct and transitive Go packages selected by the build environment;
71
+
it is not a complete module graph or a trace of linked symbols. Test-only and inactive
72
+
target/tag dependencies are excluded. `go-licenses` groups packages by their selected
73
+
license file, and its directory output is not a versioned SBOM.
74
+
75
+
The collector saves licenses and adjacent `NOTICE`, `NOTICE.txt`, or `NOTICE.md` files.
76
+
For some license classifications it copies the **entire source directory containing the
77
+
license**, excluding only Git metadata. This can increase wheel size and include unrelated
78
+
local files. Review that output before shipping, especially with local replacements or
79
+
workspace dependencies; the plugin does not remove potentially required source files.
80
+
81
+
Go's standard library/runtime is excluded by the collector. It also cannot discover
82
+
dependencies hidden in C/C++, assembly, system libraries, or separately vendored assets.
83
+
Collector warnings remain visible. Review runtime licenses and native dependencies
84
+
separately; collecting files does not certify license compatibility or compliance.
85
+
21
86
> [!NOTE]
22
87
> This library was generated using [copier](https://copier.readthedocs.io/en/stable/) from the [Base Python Project Template repository](https://github.com/python-project-templates/base).
0 commit comments