a-scie / jump

A Self Contained Interpreted Executable Launcher
Apache License 2.0
48 stars 7 forks source link

Support a `${scie.boot}` placeholder for app scratch space in the `~/.nce` #7

Closed jsirois closed 1 year ago

jsirois commented 1 year ago

This would allow having additional commands that can perform post-install steps. The idea would be to use the fingerprint of the lift manifest itself as the value for the ${scie.boot} and then use an atomic directory (or maybe just an atomic marker file - we just want to ensure the side-effect is performed only once) at the top of that directory for each additional command name that requests the placeholder. The motivation is is pre-installing PEX venvs to avoid the PEX zip (or unzipped zip) re-director ~50ms overhead similar to how the Pex --sh-boot option operates.

For example:

{
  "command": {
    "exe": "${python}/bin/python"
    "args": [
      "${scie.boot.venv}/venv/pex"
    ]
  }
  "additional_commands": {
    "venv": {
      "env": {
        "PEX_TOOLS": "1"
      },
      "exe": "${python}/bin/python"
      "args": [
        "${pex}", "venv", "--bin-path", "prepend", "--compile", "--rm", "pex", "${scie.boot}/venv"
      ]
    }
  }
}
jsirois commented 1 year ago

This config is now shaped like so:

{
  "scie": {
    "jump": {
      "version": "0.1.0",
      "size": 1279424
    },
    "lift": {
      "files": [
        {
          "type": "archive",
          "name": "python",
          "size": 42111958,
          "hash": "032da47cd2d8f73fa677ac8f3b172d743a13cc044d457f1871e73b528d547ea1",
          "archive_type": "tar.zst"
        },
        {
          "type": "archive",
          "name": "cowsay",
          "size": 625335,
          "hash": "ca99fd202efe01a8bf244f4502c5ec0a84723702dfc52e60786a21ac7c6a7266",
          "archive_type": "zip"
        }
      ],
      "boot": {
        "commands": {
          "cowsay": {
            "description": "A cow says a thing.",
            "exe": "{python}/python/install/bin/python3.10",
            "args": [
              "{cowsay}"
            ]
          }
        },
        "bindings": {}
      }
    }
  }
}

All commands in the boot.bindings must use the {scie.boot} but no commands in boot.commands can. Instead they request a binding via {scie.boot.<binding name>} which ensures that binding has executed exactly once in the past (where history begins again with each new lift path or when its contents are removed).