feat: relative directory usage type#426
Conversation
bf8a126 to
2efe572
Compare
c4d77cd to
1b89d44
Compare
1b89d44 to
db00459
Compare
Why are |
|
Publisher and name are needed for a few reasons:
|
666c174 to
7eee974
Compare
786dbc3 to
e80189c
Compare
e80189c to
287a0fc
Compare
287a0fc to
259ac39
Compare
| } | ||
|
|
||
| /// A dependency obtained from an environment (or an index/kpar copy) may | ||
| /// declare a `Directory` usage whose relative path only exists in its |
There was a problem hiding this comment.
Seeing this and other edge cases, I am kind of starting to wonder whether we should just require that all transitive dependencies are registry only.
There was a problem hiding this comment.
Requiring transitive deps to be only from registry would be too strict in my opinion, and would be very annoying for local development of a few related projects.
Everything works fine (AFAIK) as long as the environment is not involved. Dependencies of projects in the environment would be cleanly resolvable if env.toml records the original source of the project (so that relative path usages can be resolved correctly), which it currently doesn't. Will make a PR that adds this info to env.toml. Also, env.toml does not record which versions of dependencies of the installed projects (just their identifiers, so it would break with two versions of the same PURL present), this also should be fixed eventually...
9a3fcd5 to
72a1497
Compare
72a1497 to
0ec3b97
Compare
Introduce the Directory variant on InterchangeProjectUsage for relative local path dependencies, threading it through the project layer, resolvers, pubgrub solver, CLI, and Java/Python bindings. Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com> fix: incorrect merge conflict resolution Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
0ec3b97 to
5ae1ef4
Compare
This PR adds support for referencing local directory paths as project dependencies, alongside the existing IRI/URL-based usages.
New Directory usage type
A new usage variant references a project by a directory path (relative to the declaring project's root) plus its publisher and name. It serialises as
{"dir": ..., "publisher": ..., "name": ...}. The declared publisher/name must match what's actually found at the path, and there is no version constraint since a directory contains a single version. Onlylocal_srcprojects are supported; KPARs will use another type, to keep resolution unambiguous.Unlike legacy
resourceusages, where the IRI is both the project's identity and (possibly) its location, typed usages separate the two: identity is always publisher+name, and the source is explicit. This allows avoiding resolution altogether for typed usages. Currently resolution is still done due to large changes required to avoid it; typed usages always resolve to their type.Resolution and solving
Resolvers now receive the full usage (plus an optional base path for relative filesystem paths) instead of a bare IRI. Resolution outcomes distinguish "not found" from "unresolvable", letting a file-resolver miss fall through to other resolvers.
Every usage derives an identifier (a PURL where possible, an URN fallback otherwise; legacy usages keep their IRI). The solver identifies packages by this identifier rather than by version constraint or source, so a package referenced with different constraints/paths by different dependents appears only once in the solution.
experimentalCLI subcommandAdds
sysand experimental add --dir <path>andsysand experimental remove <publisher> <name>:addcomputes a path relative to the current project, reads publisher/name from the dependency, and adds a directory usage. By default it then locks and syncs (--no-lock/--no-syncopt out), rolling back the project file if resolution fails. No source overrides — typed usages will support everything overrides do, so they can be added directly instead.removeremoves a usage by publisher and name, which will work for all typed usage types.These are separate from regular
add/removeto avoid breaking changes, and because the UX for other usage types is still unclear.experimentalcommands will likely replace regular commands on next major release, but some accommodation to minimize breaking changes will be required.Other
Breaking changes
infono longer takes arelative_file_rootargument (it had no effect previously). Java code matching on usage types must also handle the new directory usage class.