2020-12-07 07:02 阅读 0

Discuss: jpm venv

largely stolen from python3 -m venv:

$ jpm venv ./my-venv
$ ./my-venv/bin/jpm install sqlite3
$ ./my-venv/bin/janet
> (import sqlite3)

However, if it becomes too complicated (I can think of a few complications, like jpm binary installs), I think we could also encourage an alternative solution outside of jpm, e.g. write a guide on how to use jpm together with tools like direnv, or env files, or even something simpler.

For example, I am not sure what the standard setup for JANET_MODPATH, JANET_PATH and JANET_BINPATH per project should look like.


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • weixin_39679664 weixin_39679664 2020-12-07 07:02

    Janet doesn't need that much setup, so this kind of functionality should not need much code. Inside a 'venv' like this, JANET_PATH should be the same as JANET_MODPATH (./my-venv/lib), JANET_BINPATH should be on PATH (./my-venv/bin), and that's really about it. A setup script could be included, like activate.py or whatever in python virtual-env. There also should be no need to physically copy janet and jpm into the virtual env other than versioning, but that itself is probably a good reason. Other files like janet.h and libjanet.so would also be copied to ./my-venv/lib.

    点赞 评论 复制链接分享
  • weixin_39950867 weixin_39950867 2020-12-07 07:02

    I think in python venvs the files that get copied into the env are fake wrapper binaries. Janet itself is small enough I suppose a full copy is not a big deal.

    点赞 评论 复制链接分享
  • weixin_39679664 weixin_39679664 2020-12-07 07:02

    Some changes to path defaults makes this kind of workflow easier now without a special tool (with the caveat binary installs will not automatically be on your PATH).


    cd ~/code/my_project
    mkdir janet_modules
    export JANET_PATH=$(pwd)/janet_modules
    jpm deps
    jpm build
    jpm install
    janet main.janet # run program
    janet_modules/bin/mdz # run a binary or script installed from a dependency

    This does not support automatically switching between multiple versions of Janet on your system.

    点赞 评论 复制链接分享
  • weixin_39950867 weixin_39950867 2020-12-07 07:02

    Im happy with this simple solution.

    点赞 评论 复制链接分享