[PR #255] [CLOSED] Support Projects loaded from arbitrary URIs #483

Closed
opened 2025-12-30 01:24:53 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/apple/pkl/pull/255
Author: @HT154
Created: 2/26/2024
Status: Closed

Base: mainHead: projects-from-any-uri


📝 Commits (1)

  • 42224c0 Support Projects loaded from arbitrary URIs

📊 Changes

33 files changed (+644 additions, -120 deletions)

View changed files

📝 pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectPackager.kt (+42 -11)
📝 pkl-core/src/main/java/org/pkl/core/module/ModuleKeys.java (+20 -17)
📝 pkl-core/src/main/java/org/pkl/core/module/ProjectDependenciesManager.java (+42 -18)
📝 pkl-core/src/main/java/org/pkl/core/packages/Dependency.java (+3 -2)
📝 pkl-core/src/main/java/org/pkl/core/project/Project.java (+58 -19)
📝 pkl-core/src/main/java/org/pkl/core/resource/ResourceReaders.java (+11 -13)
📝 pkl-core/src/main/java/org/pkl/core/runtime/ResourceManager.java (+39 -7)
📝 pkl-core/src/main/resources/org/pkl/core/errorMessages.properties (+15 -0)
📝 pkl-core/src/test/files/LanguageSnippetTests/input/projects/project1/PklProject (+1 -0)
📝 pkl-core/src/test/files/LanguageSnippetTests/input/projects/project1/PklProject.deps.json (+5 -0)
📝 pkl-core/src/test/files/LanguageSnippetTests/input/projects/project1/globbing.pkl (+5 -0)
📝 pkl-core/src/test/files/LanguageSnippetTests/input/projects/project3/PklProject.deps.json (+5 -0)
pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/PklProject (+8 -0)
pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/PklProject.deps.json (+4 -0)
pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/children.pkl (+1 -0)
pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/children/a.pkl (+1 -0)
pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/children/b.pkl (+1 -0)
pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/children/c.pkl (+1 -0)
📝 pkl-core/src/test/files/LanguageSnippetTests/output/projects/badProjectDeps1/bug.err (+1 -1)
📝 pkl-core/src/test/files/LanguageSnippetTests/output/projects/badProjectDeps2/bug.err (+1 -1)

...and 13 more files

📄 Description

Currently, Pkl assumes that a PklProject file and any declared local dependencies are accessible on the filesystem (i.e. via file: URIs. For usage of the pkl CLI this is sufficient, but for usage of language bindings this presents an obstacle for evaluating Pkl code using projects from sources that are not the filesystem. One compelling use case would be consuming Pkl code using project dependencies from a git repository; using go-git and its go-billy filesystem abstraction, it should be possible to do this completely in-memory. With this change and https://github.com/apple/pkl-go/pull/21 this now works end-to-end.

Brief summary of the changes here:

  • Replace usage of Path projectDir with URI projectBaseUri throughout
  • Switch reading of PklProject.deps.json to use resource readers
  • Update pkl:Project to accept local dependencies when the scheme and authority are the same, rather than checking for file: URIs specifically
  • Add a test in pkl-core for custom-defined module and resource readers
  • Fix NPE in pkl-server's handling of empty/absent pathElements in List*Responses

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/apple/pkl/pull/255 **Author:** [@HT154](https://github.com/HT154) **Created:** 2/26/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `projects-from-any-uri` --- ### 📝 Commits (1) - [`42224c0`](https://github.com/apple/pkl/commit/42224c096bc02c73070a8975389d613f824a50e0) Support Projects loaded from arbitrary URIs ### 📊 Changes **33 files changed** (+644 additions, -120 deletions) <details> <summary>View changed files</summary> 📝 `pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectPackager.kt` (+42 -11) 📝 `pkl-core/src/main/java/org/pkl/core/module/ModuleKeys.java` (+20 -17) 📝 `pkl-core/src/main/java/org/pkl/core/module/ProjectDependenciesManager.java` (+42 -18) 📝 `pkl-core/src/main/java/org/pkl/core/packages/Dependency.java` (+3 -2) 📝 `pkl-core/src/main/java/org/pkl/core/project/Project.java` (+58 -19) 📝 `pkl-core/src/main/java/org/pkl/core/resource/ResourceReaders.java` (+11 -13) 📝 `pkl-core/src/main/java/org/pkl/core/runtime/ResourceManager.java` (+39 -7) 📝 `pkl-core/src/main/resources/org/pkl/core/errorMessages.properties` (+15 -0) 📝 `pkl-core/src/test/files/LanguageSnippetTests/input/projects/project1/PklProject` (+1 -0) 📝 `pkl-core/src/test/files/LanguageSnippetTests/input/projects/project1/PklProject.deps.json` (+5 -0) 📝 `pkl-core/src/test/files/LanguageSnippetTests/input/projects/project1/globbing.pkl` (+5 -0) 📝 `pkl-core/src/test/files/LanguageSnippetTests/input/projects/project3/PklProject.deps.json` (+5 -0) ➕ `pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/PklProject` (+8 -0) ➕ `pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/PklProject.deps.json` (+4 -0) ➕ `pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/children.pkl` (+1 -0) ➕ `pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/children/a.pkl` (+1 -0) ➕ `pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/children/b.pkl` (+1 -0) ➕ `pkl-core/src/test/files/LanguageSnippetTests/input/projects/project6/children/c.pkl` (+1 -0) 📝 `pkl-core/src/test/files/LanguageSnippetTests/output/projects/badProjectDeps1/bug.err` (+1 -1) 📝 `pkl-core/src/test/files/LanguageSnippetTests/output/projects/badProjectDeps2/bug.err` (+1 -1) _...and 13 more files_ </details> ### 📄 Description Currently, Pkl assumes that a PklProject file and any declared local dependencies are accessible on the filesystem (i.e. via `file:` URIs. For usage of the `pkl` CLI this is sufficient, but for usage of language bindings this presents an obstacle for evaluating Pkl code using projects from sources that are not the filesystem. One compelling use case would be consuming Pkl code using project dependencies from a git repository; using `go-git` and its `go-billy` filesystem abstraction, it should be possible to do this completely in-memory. With this change and https://github.com/apple/pkl-go/pull/21 this now works end-to-end. Brief summary of the changes here: * Replace usage of `Path projectDir` with `URI projectBaseUri` throughout * Switch reading of `PklProject.deps.json` to use resource readers * Update `pkl:Project` to accept local dependencies when the scheme and authority are the same, rather than checking for `file:` URIs specifically * Add a test in `pkl-core` for custom-defined module and resource readers * Fix NPE in pkl-server's handling of empty/absent `pathElements` in `List*Response`s --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 01:24:53 +01:00
adam closed this issue 2025-12-30 01:24:53 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#483