in scripts/setup.py [0:0]
def initialize_opam_switch(self) -> Mapping[str, str]:
self.check_if_preinstalled()
self.validate_opam_version()
self.run(
[
"opam",
"init",
"--bare",
"--yes",
"--root",
self.opam_root.as_posix(),
"default",
"https://opam.ocaml.org",
]
)
self.run(
[
"opam",
"switch",
"create",
self.compiler,
"--packages=ocaml-option-flambda",
"--yes",
"--root",
self.opam_root.as_posix(),
]
)
opam_environment_variables = self.opam_environment_variables()
# This is required to work around a bug in pre-OCaml 4.12 that prevents
# `re2` from installing correctly.
# See https://github.com/janestreet/re2/issues/31
ocamlc_location = self.run(
["ocamlc", "-where"], add_environment_variables=opam_environment_variables
)
self.run(["rm", "-f", f"{ocamlc_location}/version"])
self.run(
["opam", "install", "--yes"] + DEPENDENCIES,
add_environment_variables=opam_environment_variables,
)
return opam_environment_variables