Support scheme-agnostic projects (#486)

This adds changes to support loading project dependencies in non-file based projects.

The design for this feature can be found in SPICE-0005: https://github.com/apple/pkl-evolution/pull/6

Changes:
* Consider all imports prefixed with `@` as dependency notation.
* Bugfix: fix resolution of glob expressions in a local dependency.
* Adjust pkl.Project:
  - Allow local dependencies from a scheme-local paths.
  - Disallow certain evaluator settings if not loaded as a file-based module.
* Breaking API change: `ProjectDependenciesManager` constructor now requires `ModuleResolver` and `SecurityManager`.
This commit is contained in:
Daniel Chao
2024-06-04 16:52:20 -07:00
committed by GitHub
parent c0a7080287
commit d5ba8fa736
49 changed files with 764 additions and 235 deletions

View File

@@ -0,0 +1,8 @@
amends "pkl:Project"
dependencies {
["fruit"] {
uri = "package://localhost:0/fruit@1.0.5"
}
["project4"] = import("../project4/PklProject")
}

View File

@@ -0,0 +1,17 @@
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/fruit@1": {
"type": "remote",
"uri": "projectpackage://localhost:0/fruit@1.0.5",
"checksums": {
"sha256": "$skipChecksumVerification"
}
},
"package://localhost:0/project4@1": {
"type": "local",
"uri": "projectpackage://localhost:0/project4@1.0.0",
"path": "../project4"
}
}
}

View File

@@ -0,0 +1,5 @@
import "@fruit/catalog/apple.pkl"
import "@project4/module1.pkl"
prop1 = apple
prop2 = module1

View File

@@ -0,0 +1,5 @@
amends "pkl:Project"
dependencies {
["project7"] = import("../project7/PklProject")
}

View File

@@ -0,0 +1,10 @@
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/project7@1": {
"type": "local",
"uri": "projectpackage://localhost:0/project7@1.0.0",
"path": "../project7"
}
}
}

View File

@@ -0,0 +1,3 @@
import* "@project7/*.pkl" as proj7Files
res = proj7Files

View File

@@ -0,0 +1,3 @@
import "@project7/main.pkl"
res = main.res

View File

@@ -0,0 +1,8 @@
amends "pkl:Project"
package {
name = "project7"
version = "1.0.0"
packageZipUrl = "https://bogus.value"
baseUri = "package://localhost:0/project7"
}

View File

@@ -0,0 +1 @@
res = import*("*.pkl")