repository icon indicating copy to clipboard operation
repository copied to clipboard

Add package dependencies to the repo

Open ikskuh opened this issue 5 years ago • 6 comments
trafficstars

This is required for more complex packages that depend on each other. My proposal is to do the following format change:

{
  "dependencies": {
    "${import name 1}": "${package name 1}",
    "${import name 2}": "${package name 2}"
  }
}

This allows package managers to create a correct DAG out of the packages and build a correct std.build.Pkg structure. Import name is the name that needs to get passed to @import(…), package name is the file name in the repository without the file extension.

Example:

{
  "author": "truemedian",
  "description": "A WebSocket 1.3 library for Zig",
  "git": "https://github.com/truemedian/wz",
  "root_file": "/src/main.zig",
  "dependencies": {
    "hzzp": "hzzp"
  },
  "tags": [
    "networking"
  ]
}

ikskuh avatar Oct 21 '20 09:10 ikskuh

My proposal is a bit unusual but here is what i propose: in a case where a package depends on another package but not its implementation (for example it might depend on a windowing package, but it might be a glfw or an x11 package), there should be a way for the user to choose which to use. Maybe for those case the dependency package name might be null, for example:

{
  "author": "zenith391",
  "description": "OpenGL module for Didot",
  "git": "https://github.com/zenith391/didot",
  "root_file": "/didot-opengl/graphics.zig",
  "dependencies": {
    "didot-window": null
  },
  "tags": [
    "game",
    "graphics"
  ]
}

When installing that package, the package manager should so something like prompt the user to select a package to install, and the user could type didot-x11, didot-glfw or any other windowing package he wants.

zenith391 avatar Oct 21 '20 10:10 zenith391

Counter-proposal to the comment by @zenith391:

{
  "dependencies": {
    "didot-window": [ "didot-x11", "didot-glfw" ]
  }
}

Which would allow a package manager to also prompt the user which package to install, but also list available and checked options. Note that this should not be an enforcement, but a hint. You should be able to override the selection anyways

ikskuh avatar Oct 21 '20 10:10 ikskuh

As it seems people agreed on it, shouldn't this issue start getting implemented?

zenith391 avatar Jan 20 '21 16:01 zenith391

As it seems people agreed on it, shouldn't this issue start getting implemented?

True! If you have the time, go ahead, implement it and make a PR! I will happily click merge!

ikskuh avatar Jan 20 '21 16:01 ikskuh

It seems that current design doesn’t consider versions, which is important for reproducible build

jiacai2050 avatar Sep 29 '22 03:09 jiacai2050

Yes, but i refuse to do version tracking before Zig 1.0.0, as i consider that wasted energy, as your Zig code might break tomorrow anyways.

ikskuh avatar Sep 29 '22 08:09 ikskuh