如何为OCaml Dune项目指定依赖项版本的要求?

huangapple go评论57阅读模式
英文:

How to specify requirements for versions of dependencies for ocaml dune projects?

问题

  1. 我如何指定 foobar 库应该有特定的确切版本?

  2. 如果我们知道 foobar 库使用语义版本控制,我如何指定需要主版本号为 3 的任何版本?

英文:

Say I run dune init proj hello_world, then modify the bin/dune and bin/main.ml files so that a new dependency foobar is in use.

The bin/dune file now:

(executable
 (public_name hello_world)
 (name main)
 (libraries hello_world foobar))

1. How can I specify that the foobar library should have a certain exact version?

2. If we know that the foobar library uses semantic versioning, how could I specify that any version with the major version as 3 is required?

ocaml version 4.14.0
dune version 3.6.1

答案1

得分: 2

项目的软件包依赖关系在 dune-project 文件中指定,详见 https://dune.readthedocs.io/en/stable/dune-files.html#package

通过 dune init proj ... 生成默认的 dune-project 文件。

要添加带有版本约束的依赖项,请在 depends 字段中添加一行,如下所示:

(depends 
  (foobar (>= 3))

请注意,这是为了补充指定可执行组件依赖的库,这是在 bin/dune 文件中完成的。

英文:

Package dependencies for a project are specified in the dune-project file, see https://dune.readthedocs.io/en/stable/dune-files.html#package

A default dune-project file is generated by dune init proj ....

To add a dependency with a version constraint, add a line in the depends field like

(depends 
  (foobar (>= 3))

Note that this is needed in addition to specifying which libraries the executable component depends on, which is what you have on the bin/dune file.

huangapple
  • 本文由 发表于 2023年2月18日 11:25:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75490992.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定