-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
App support in Pkg #3772
base: master
Are you sure you want to change the base?
App support in Pkg #3772
Conversation
Oh this looks very cool! Thanks for all the time/effort that's gone into this 🤩 One thing I'm slightly concerned about here is the approach taken to making sure that the executables are on the users's
I see in the design document there is some mention of putting such files in a more standard location already on the path such as Other lang's package managers already install things in the XDG-appropriate locations, such as Python with I'd advocate for a (NB: when I say |
|
||
function bash_shim(pkgname, julia_executable_path::String, env) | ||
return """ | ||
#!/usr/bin/env bash |
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.
On a briefer note, shouldn't the unix shim be based on sh
not bash
, possibly even #!/bin/sh
over #!/usr/bin/env sh
(somebody else should check, but IIRC that's the POSIX form)?
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.
"Somebody else" is apparently me 😄, and my "IIRC" was wrong.
I've just had a look at https://pubs.opengroup.org/onlinepubs/009695399/utilities/sh.html and under APPLICATION USAGE there's this relevant excerpt:
Applications should note that the standard PATH to the shell cannot be assumed to be either /bin/sh or /usr/bin/sh, and should be determined by interrogation of the PATH returned by getconf PATH , ensuring that the returned pathname is an absolute pathname and not a shell built-in.
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.
From reading around a bit more, it seems like the consensus on portability goes something like this (from most portable to least):
- A binary executable that doesn't have a shebang
#!/bin/sh
#!/usr/bin/env sh
#!/usr/bin/env bash
#!/bin/bash
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.
Bump @KristofferC
nice work! I'm wondering how apps are shared across Julia versions? e.g. are they isolated by Julia versions like how the global environment are setup? |
This seems useful, maybe already despite that limitation. Could it be lifted by autoinstalling Julia (runtime, right version) for you if not available? Needs not be in first version. This is in some ways similar to Python's zipapps (which I believe is not too popular, because runtime can't be assumed, even for Linux where it's most often preinstalled), that needs separate .pyz[w] file ending, and Python installed (and are in one archive file, optionally compressed): https://docs.python.org/3/library/zipapp.html
[We already have AppBundler.jl if you want to bundle the runtime, it's best if you can have one way to make an app and it can be compiled with PackageCompiler, or use AppBundler, or a combining those..., or this system. ] |
With regards to XDG there is an argument that Pkg should follow what Julia itself does. (As you are aware) there is JuliaLang/julia#4630. A related question, according to XDG where should the For Windows the Cargo issue comment says:
How is that translated to all the files used here (shims,
I get
|
As it is right now each app entry in AppManifest.toml has an absolute path to a Julia installation. If you want to update that Julia version you would also resolve the environment. This ties into this later comment:
one plan forward is to use Juliaup to install the Julia installation that the app is currently configured for if it does not exist. That way you would not store the absolute path to the julia installation like that. |
Right. I basically see Julia as currently being in a similar situation to Cargo — in that by the end of JuliaLang/julia#4630 I think I can fairly summarise the consensus as "yes this would be nice to have, but it's going to be a hassle to start using it". Much of the value of the XDG Desktop spec comes via a network effect. Thus when the Desktop spec was new and that issue was created in 2013, the benefit was somewhat speculative. Now though, as more tools use and assume XDG compliance, it creates a growing tension between the "Julia way" and the XDG way. In this sort of light, I see decisions like this as opportunities to choose between digging down and digging out 😛 somewhat. I still have loose plans to go back to JuliaLang/julia#4630 to see if I can help move the state of affairs closer to XDG compliance (Stefan asked me if I'd be interested in putting a PR together a few months ago, and I am once I have fewer PRs currently open). Considering the current "Julia way" and the XDG spec, would it not be possible to put things in
I made a flowchart for answering this sort of question in the BaseDirs.jl docs which might be helpful (it's not 100% accurate, but I didn't want to make it more complicated, and I think it gets 98% of the way). If we classify
then Data Home would be the relevant XDG Desktop component (let me know if any of those assumptions don't hold). More generally, I find
A while ago I spent an inordinate amount of time looking at the relevant behaviour/specs/comments around directories on Windows/Mac. I think I'd probably be best off pointing you to the comparison table on https://tecosaur.github.io/BaseDirs.jl/stable/defaults/ (and if you want the reasoning/links to some of the most relevant resources: https://tecosaur.github.io/BaseDirs.jl/stable/others/). Regarding just this part of the comment:
Yea, getting the right system dirs on windows is actually a bit of a pain. See https://github.com/tecosaur/BaseDirs.jl/blob/main/src/nt.jl for a glimpse of me not having a fun time. |
My plan generally is that the Julia version in a manifest becomes the version selector for Juliaup. Presumably that would work well for apps here too? |
What is still needed before this can be merged? |
In case folks haven't seen it - @KristofferC's talk from JuliaCon has a nice summary of the current status and what the open questions still are (or what they were as of a couple of weeks ago. Start at about 6:49:00 here: https://www.youtube.com/live/OQnHyHgs0Qo?si=IVg01oXigQw1JBDH&t=24545 |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Hi Folks, I wanted to weigh in from the perspective of HPC. If I understand this PR correctly, then the strategy chosen is to control the user environment in such a way that Julia code, Pkg environment, and default entrypoints emulate a user experience similar to a compiled executable. This is like the approaches taken by Python zipfiles, anaconda, etc. Our experiences in running HPC systems (serving up to 10k users) so far has shown that this approach is:
Basically: we are developing HPC-native container runtimes precisely because the approach chosen in this PR performs poorly for Python. The irony here is that this considerable engineering effort is only necessary because Python can't generate compiled code. Therefore, I think that the motivation behind this PR -- while well intentioned -- might run a real risk at being harmful to Julia as a High-Productivity HPC language. Especially because efforts to build executable applications appears to be within reach for Julia: JuliaLang/julia#55047. Furthermore, since JIT compilation adds complexity to the container build process, this should prove to be a much more seamless and scalable solution to building Julia applications than Pkg Apps. Also, I think an approach to Julia applications that is based on compiled executables (which could be placed in any reasonable location on the filesystem) would result in a better user experience (including for non-HPC users). When developing tools to be used by others, I have opted for compiled executables as they don't rely on the user's runtime environment. This PR implicitly promises to support every edge case which a user could configure into their favorite shell, so from a mere user support perspective I think a combination of JuliaLang/julia#55047 + a distribution mechanism would be much easier to maintain. Let me know what you think. I am happy to contribute some of my time to this. Citing @Seelengrab , @giordano, and @tecosaur : we had a conversation on Slack that brought this to my attention (this does not imply that they share or endorse my opinion) |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
First, let me say that I agree with many of the limitations that you mention, and as someone that also works on HPCs (though not at the same level), I'm glad to have people thinking about this stuff. At the same time, I don't think we want to let the perfect be the enemy of the good here. Julia already has a lot of advantages over python when it comes to platform independence (eg binary builder), and this PR as it stands has functionality that will be extremely useful in many contexts, even if it's not perfect for HPCs at the moment, requires a bit of extra work for users to modify their own paths, etc. I agree that we should not rely on Julia managing path stuff, but IIUC, this PR explicitly doesn't do that - it puts stuff in a julia-managed directory and relies on users to deal with it from there. This is how I agree we want to move towards a place where Pkg can build binaries and seamlessly integrate them into the system environment, but I think that can be built on top of this, and I for one do not want to wait for that ideal state to get access to this functionality. |
Another counter-point to JuliaLang/julia#55047 as an alternative viable solution: not all Julia programs can be made free from dynamic dispatch, yet JuliaLang/julia#55047 requires that for the programs it generates. In particular, if that were our only application deployment solution, then any program which uses Dagger.jl (which contains a dynamic-dispatch based core) would not be able to be deployed as an application, and thus users would be driven away from using Dagger in their applications if it meant that they lost application support by using Dagger. That would be a pretty harmful force to have exist within our ecosystem, as dynamic dispatch serves a very useful purpose, especially when used with care to ensure it doesn't result in unnecessary slowdowns in fast-paths. To make things more concrete, could concerned HPC developers try out this PR on their system of interest and see where any issues arise? In particular, can we identify any currently-existing pain points in the current implementation that would make it hard for application/package authors to adopt this feature in their application? That would ground the discussion around things that we can clearly identify as issues to be resolved in some way, rather than trying to throw out this idea in its entirety on the basis of known unknowns. |
Apps only write a manifest so can't rely on the path being created by `write_project`. Also moves the `mkpath` call for `write_project` to the method that actually does the filesystem writing with `write`.
This has some rudimentary docs and tests now. I'd prefer merging this soonish to get into 1.12 and the test coverage can be improved based on that. |
docs/src/apps.md
Outdated
- You need to manually make `~/.julia/bin` available on the PATH environment. | ||
- The path to the julia executable used is the same as the one used to install the app. If this | ||
julia installation gets removed, you might need to reinstall the app. | ||
used by the app might not be found. |
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.
used by the app might not be found. |
docs/src/apps.md
Outdated
- The path to the julia executable used is the same as the one used to install the app. If this | ||
julia installation gets removed, you might need to reinstall the app. | ||
used by the app might not be found. | ||
- You can only have one app installed |
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.
One per package?
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 very exciting! Would be amazing to have this in 1.12, thanks for your work on it @KristofferC !
docs/src/apps.md
Outdated
|
||
A Julia app is structured similar to a standard Julia library with the following additions: | ||
|
||
- A `@main` entry point in the package module (see the Julia help on `@main` for details) |
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.
Can this be [`@main`](@ref)
, or can this just be a link to that section in the docs?
|
||
## Installing Julia apps | ||
|
||
The installation of Julia apps are similar to installing julia libraries but instead of using e.g. `Pkg.add` or `pkg> add` one uses `Pkg.Apps.add` or `pkg> app add` (`develop` is also available). |
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.
The installation of Julia apps are similar to installing julia libraries but instead of using e.g. `Pkg.add` or `pkg> add` one uses `Pkg.Apps.add` or `pkg> app add` (`develop` is also available). | |
The installation of Julia apps are similar to installing julia libraries but instead of using e.g. `Pkg.add` or `pkg> add` one uses `Pkg.Apps.add` or `pkg> app add` (`pkg> app develop` is also available). |
Or "develop
rather than add
is also..."
This is quite heavily WIP towards having "app" support in Pkg. An app is a program that you just write its name in the terminal and it starts up, without explicitly having to invoke Julia, load the package, and call a function. Every app has an isolated environment.
More details of the design can be found in this hackmd: https://hackmd.io/r0sgJar5SpGNomVB8wRP_Q
This PR requires JuliaLang/julia#52103
Here is some example usage:
cc @MasonProtter, @Roger-luo