Skip to content
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

Handle local archives without requiring network tooling #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lexmag
Copy link
Contributor

@lexmag lexmag commented Dec 12, 2023

No description provided.


defp local_archive("file:" <> rest) do
case rest do
"//localhost/" <> path -> "/" <> path
Copy link
Contributor

Choose a reason for hiding this comment

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

Given we don't support reading from any other host either, I would remove this version.

case rest do
"//localhost/" <> path -> "/" <> path
"///" <> path -> "/" <> path
"/" <> path when binary_part(path, 0, 1) != "/" -> rest
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should support this version. I can't see it on the spec.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, it seems to be used by KDE. I am 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RFC 3986 mentions that:

the "file" URI scheme is defined so that no authority, an empty host, and "localhost" all mean the end-user's machine

defp local_archive("file:" <> rest) do
case rest do
"//localhost/" <> path -> "/" <> path
"///" <> path -> "/" <> path
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't support "file:///c:/foo/bar" on Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unable to test on Windows; we have to rewrite that to use backslashes, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, that's not necessary, but you don't need to add a prefixing "/". Using a separate env var will be simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't need to add a prefixing "/"

Indeed. 🙈

@josevalim
Copy link
Contributor

I am not a big fan of this approach. The current implementation is too complex by trying to support three different formats and it does not work on Windows. Perhaps it would make more sense to introduce another environment variable, instead of overloading this one?

@jonatanklosko
Copy link
Member

@josevalim I just thought the same, we can have XLA_ARCHIVE_PATH. And we don't have to copy it to the cache dir, since the file is already accessible locally!

@lexmag
Copy link
Contributor Author

lexmag commented Dec 13, 2023

I'm personally also not that positive about supporting file: all the way.
That's said, I think if we decide to go just with a single format (for example, empty host), it is justifiable and does not seem worse than adding an extra environment variable (which, in turn, brings a question of priority).

@jonatanklosko
Copy link
Member

@lexmag there's still the advantage of not creating a copy of the file at all. And having an env var for path makes it much more intuitive/discoverable. I don't think prioritisation is an issue, we can check the path before url, similarly to how we respect XLA_BUILD=true first. So the path env var check would go between these:

xla/lib/xla.ex

Lines 22 to 29 in 137ca69

build?() ->
# The archive should have already been built by this point
archive_path_for_build()
url = xla_archive_url() ->
path = archive_path_for_external_download(url)
unless File.exists?(path), do: download_external!(url, path)
path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants