-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
new package hash format: $name-$semver-$hash
#20178
Comments
this is very common in the existing ecosystem and I'd recommend using |
re the 16-byte name limit, https://github.com/nektro/zig-iso-3166-countrys and https://github.com/nektro/zig-iso-639-languages use package names that are both 17 in length |
I edited the proposal with these changes:
|
I would suggest to separate components by:
instead, since all three components (name, SemVer if I understand spec correctly and sized-hash) already disallow them. So now
IMHO it's also easier to read by human and machine. |
|
That's what I'm reading. If |
the separator needs to be filesystem safe too because this scheme ends up as the name of a folder |
The fact that the directory name would be |
Of course! Thanks to you all! How ignorant of me 🤦, to read and immediately forgot such basics. I apologise for unsensible message. |
Note that
I'll throw |
I disagree with allowing |
Regarding the name length limit, thanks @shadeops for doing a bit of legwork:
|
I like this proposal. I have a few miscellaneous thoughts:
|
I currently use I also think that using |
The rules for legal tokens in paths on Windows are (unfortunately) more complicated than just those characters:
Paraphrasing, this means that path components starting with any of the above names immediately followed by a dot are forbidden on Windows, which means that package names like Related, I wonder if there's much of a point in allowing such a large set of characters in package names. Maybe it would be easier for both the package manager implementation and the users if the set of allowed names was restricted to just "legal unquoted identifier in Zig source code (approximately I also want to mention |
Another datapoint taken from my projects:
so i guess the bsp here is borderline, but it would still fit |
Why not just use directories? i.e. $name/$semver/$sizedhash That would avoid adding new restrictions (assuming most package names are already valid file names) and provide a much cleaner and easier to browse ~/.cache/zig/p directory. |
I edited the proposal with these changes:
|
@ifreund I think you should remove "zig-" from those package names. It's redundant information. No Zig package should have "zig" in the name. |
I do not see I also have no plans to change the name of my git repositories on online code forges to something other than My intuition tells me that it is least confusing if the package's name matches the name of the repository and the name of the project. Perhaps I am wrong about this but I don't think the decision is as obvious as "It's redundant information." I do use the plain In any case, I don't see any technical benefit to disallowing Ascetically, I personally quite like @neurocyte's proposal of using sub directories instead, i.e. That proposal does have complexity tradeoffs though. I also quite like @squeek502's proposal of |
Is there a compelling reason for this? It seems to me that |
This dosen't yet handle the presence of I do agree that requiring package names to be valid zig identifiers is a nice property despite the fact that I'm not excited about dealing with the churn of renaming The part of this proposal that feels a bit strange to me is using enum literal syntax in the build.zig.zon but disallowing identifiers created with the (valid) @alexrp I think you have confused "project name" with "package name" in my comment. |
@ifreund Just replace "project name" in my comment with "package name". To be clear, I'm suggesting that naming the repository |
TLDR: maybe we don't want to have "wlroots original project" package's and "wlroots bindings" package's names to be clashed/confusing. I think it still makes sense to name package "zig-wlroots" and not "wlroots": AFAIK unlike cargo and other language-specific package managers, using Zig's build system and package manager by projects in C with no Zig code is one of the main priorities. Another way, hypothetically projects like wlroots has much higher chance to adopt build.zig(.zon) than build.rs etc. If at some point in future SDL or wlroots (or other library) are brought to Zig package manager, IMHO it would be much less awkward to have "wlroots" package name for upstream project and "zig-wlroots" for bindings, rather than both of them having "wlroots" package. |
Using enum literals for zig package names would go along well with another proposal I recall from some time ago (but can't find a link for): // Imports of zig files use a string literal argument to `@import()`.
const foo = @import("foo.zig")
const bar = @import("foo/bar.zig");
// Imports of packages use an enum literal argument to `@import()`.
const std = @import(.std);
const wlroots = @import(.wlroots);` This would have the advantage of removing some current ambiguity. What if there is both a file called |
|
I think you are getting the project name mixed up with the Zig package name. I am not suggesting to rename your source code repository. I think zig-wlroots is the best name for the source repository. The prefix "zig-" in the Can you give a single example for when "zig-" in the zig package name would disambiguate anything? |
To be honest, I would also consider It also better handles the case of multiple sets of competing bindings existing for the same library. e.g. if I create a competing set of wlroots bindings exposing a different API, I perhaps name it something like I don't think any value comes from having the project name differ from the Zig package name; this seems to me like nothing but a potential avenue for confusion. (Indeed, our original proposed terminology surrounding the package manager called a "package" a "project"; while we changed this nomenclature for good reason, I think the idea it communicates is still valid, that the project and what we now call the package are the same thing.) |
repo name / package name / import name these three also also independent from what a consumer chooses as the dependency name the package name isnt used for much afaik (this proposal is the first explicit use im aware of) so it makes sense to me that there's some differences in what people align it with, and I can totally understand why someone might go either way |
If you're trying to indicate that the package has to do with bindings, then put the word "bindings" in the name. Or, just keep it bare, to leave room for the fact that you might choose to expose both bindings, and a method of building the library from source with a future version. In node.js land the convention is to use "node-foo" for the repo name and "foo" for the npm package name. Lots of people redundantly put "node-" also in the npm package name and it was redundant then, too, also, as well. source: https://docs.npmjs.com/cli/v10/configuring-npm/package-json
|
I would be in favour of saturating the size field for larger packages. It's conceiveable that Zig packages may need to ship large binaries to avoid compiling things that take a long time (LLVM, Dawn, etc.), or to provide access to libraries that are closed source. The Zig package manager can also be used to fetch non-code artifacts, such as texture or model data for a game for instance, which obviously can be quite large. |
But you don't put entire wlroots library into npm ecosystem, like you (potentially) do in zig's ecosystem. They can safely assume "muhaha" package contains only JS bindings for "muhaha" library, again, unlike Zig PM where both "muhaha" library package and bindings package can coexist. Most of the time node ecosystem can't have this name conflict. I agree that it's redundant to add "zig-" prefix for Zig projects (like river or libxev), since it's not ambigious on this level. Ny disagreement is only about supplementary Zig code for C projects. |
legacy format is also supported. closes #20178
legacy format is also supported. closes #20178
legacy format is also supported. closes #20178
legacy format is also supported. closes #20178
legacy format is also supported. closes #20178
Make package hashes generally more user-friendly, so that it is more practical to interact with package directories on the file system, as well as interact with stack traces, debuggers, and other tooling that uses source code paths.
The current hash format is a hex-encoded multihash SHA-256.
It looks like this:
After this proposal, it would look like this instead:
This proposal is to change the hash format to
$name-$semver-$sizedhash
where:name
field frombuild.zig.zon
, limited to 32 bytes based on new rules outlined belowversion
field frombuild.zig.zon
, limited to 32 bytes based on new rules outlined below-_
to make it filesystem safePackage names gain new rules:
/[A-Za-z_][A-Za-z0-9_]*/
)The version field gains new rules:
Packages gain new rules:
Packages which lack a
build.zig.zon
file will have a$hashiname-P-$sizedhash
scheme instead:[5..][0..24]
bytes of the SHA-256, fss-base64-encoded, for a total of 32 bytes encodedP
which stands for "Pristine Tarball" or whatever you want, really. It acts as a version number so that any future updates to the hash format can tell this hash format apart. Note that"P"
is an invalid semver.The hash is broken up this way so that "sizedhash" can be calculated exactly the same way in both cases, and so that "name" and "hashiname" can be used interchangeably in both cases.
Related Future Work
Compatibility
Let's try to keep compatibility with the old hash format for at least 1 release cycle, so that there is 1 release cycle that supports both the old and new format at the same time.
The text was updated successfully, but these errors were encountered: