marler8997 / zigup

Download and manage zig compilers.
MIT No Attribution
784 stars 61 forks source link

Offer curl-based, pre-compiled, zig-less installation #10

Open mcandre opened 3 years ago

mcandre commented 3 years ago

Yay, a Zig version manager!

Could we get some shell install commands, to help first-time users who may not already have a Zig compiler installed? Similar to how rustup works.

Specifically, the user should not be required to have zig installed at the time zigup is installed. Rather, zigup could obtain a precompiled zig binary and put it in a zigup-friendly place on behalf of the user, so that the user only needs to know how to run a curl command, and zigup does 100% of the rest of the work of preparing zig's. Most version managers work this way.

marler8997 commented 3 years ago

Yeah I think some equivalent to rustup would be great.

I'm a bit confused by your wording here though. Zigup doesn't require Zig to be installed to work. If you have a zigup binary, you should be able to use it whether or not zig is installed. That being said, in order to compile zigup you need a Zig compiler, is that what you meant?

Nomy1 commented 3 years ago

Yes, I think he means that having a binary to download directly from here would be very helpful for new users as they wouldn't even have a zig compiler installed yet.

New users could just download a precompiled zigup binary and go

marler8997 commented 3 years ago

Ok, I think the tentative plan then is to write a script/tool to compile zigup for the same set of platforms that Zig supports, then creates a set of archives that can be uploaded into a zigup release on github. These versions of zigup should be compiled statically (like the zig executable) for portability. These archives could be downloaded manually, however, we can also host a shell script that can be piped to curl that will select and download the appropriate zigup archive and extract it for the user.

Note that to support a static version of zigup, we'll need to either compile openssl statically, or use a complete zig implementation for HTTPS. I discovered this project the other day, we may be able to use it: https://github.com/alexnask/iguanaTLS

truemedian commented 3 years ago

I have written a library that does just this. It is truemedian/zfetch.

It only requires:

So we're fairly close to this goal.

devins2518 commented 3 years ago

Ok, I think the tentative plan then is to write a script/tool to compile zigup for the same set of platforms that Zig supports, then creates a set of archives that can be uploaded into a zigup release on github.

Would setting up CI to build and upload artifacts for the short term be a possibility?

marler8997 commented 3 years ago

Would setting up CI to build and upload artifacts for the short term be a possibility?

Yes

devins2518 commented 3 years ago

Working on it rn :+1:

jiacai2050 commented 3 months ago

Note that to support a static version of zigup, we'll need to either compile openssl statically, or use a complete zig implementation for HTTPS.

@marler8997 Hi, I create a libcurl binding for Zig, it already support static build, I wonder if you are interested at adopting it?

marler8997 commented 3 months ago

Zigup is actually using the https client in std now, static builds have been solved.

jiacai2050 commented 3 months ago

Thanks for clarifying.

However the http client in std only supports 1.1, and doesn't support proxy, and in my experience it is not very stable.

So I think it's worth trying?

truemedian commented 3 months ago

HTTP 1.1 is by far the most supported version of HTTP, std.http does support HTTP and HTTPS proxies, and std.http.Client is relatively stable. So I'm not exactly sure what going back to depending on libcurl would add outside of a wider range of support for less common (likely primarily enterprise) environments

jiacai2050 commented 3 months ago

HTTP 1.1 is by far the most supported version of HTTP

Agreed, but zig tarball already support HTTP2 downloads.

curl -I https://ziglang.org/download/0.13.0/zig-0.13.0.tar.xz
HTTP/2 200 
content-type: application/x-xz
content-length: 17220728

std.http does support HTTP and HTTPS proxies,

Glad to know this, however I usually use socks proxy. https://github.com/ziglang/zig/issues/19717

and std.http.Client is relatively stable

I maybe wrong at this point, but when I try it last year, it hangs a few times, so I start to work on libcurl bindings, and a quick search show there are 15 open issues.

marler8997 commented 3 months ago

One of the goals of Zigup is to assist the Zig language and its standard library by being a real tool that people use that excercies Zig itself. A handful of issues and Pull Requests have resulted from this project and it continues to serve as a good test of Zig's HTTPS implementation. This is the main reason Zigup is written in Zig. Before Zig had an HTTPS client, Zigup did use other backends such as OpenSSL, however now that we have everything written in Zig, I'm comfortable limiting the scope of Zigup to only include Zig code moving forward. If we are missing functionality, it serves as motivation to contribute to Zig.

jiacai2050 commented 3 months ago

One of the goals of Zigup is to assist the Zig language and its standard library by being a real tool that people use that excercies Zig itself.

Totally make sense, I'm sure this project will benefit the Zig ecosystem a lot.

So we can close this issue?

marler8997 commented 3 months ago

this issue is for a curl-based pre-compiled zig-less installation, which is still ongoing

jiacai2050 commented 3 months ago

I'm a little confused, the website has already commands to download zigup binary after select OS and arch, so what is still missing?

marler8997 commented 3 months ago

Needs to be tested and probably need a few more options for windows/macos?