I need to change opam envs within python due to my applicaiton (no way around this 100%).
Usually I do:
eval $(opam env --switch={switch} --set-switch)
but this gives an issue (see end).
Thus, going to try:
opam switch set {switch}
are these truly equivalent?
For context error:
Traceback (most recent call last):
File "/lfs/ampere4/0/brando9/iit-term-synthesis/iit-term-synthesis-src/data_pkg/data_gen.py", line 510, in <module>
main()
File "/lfs/ampere4/0/brando9/iit-term-synthesis/iit-term-synthesis-src/data_pkg/data_gen.py", line 497, in main
asyncio.run(create_dataset(path_2_save_new_dataset_all_splits=args.path_to_save_new_dataset,
File "/dfs/scratch0/brando9/anaconda/envs/iit_synthesis/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/dfs/scratch0/brando9/anaconda/envs/iit_synthesis/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/lfs/ampere4/0/brando9/iit-term-synthesis/iit-term-synthesis-src/data_pkg/data_gen.py", line 437, in create_dataset
coq_proj_data: DataCoqProj = await get_coq_proj_data(coq_proj, split)
File "/lfs/ampere4/0/brando9/iit-term-synthesis/iit-term-synthesis-src/data_pkg/data_gen.py", line 194, in get_coq_proj_data
path2filenames_raw: list[str] = strace_build_coq_project_and_get_filenames(coq_proj)
File "/afs/cs.stanford.edu/u/brando9/pycoq/pycoq/opam.py", line 706, in strace_build_coq_project_and_get_filenames
activate_opam_switch(switch)
File "/afs/cs.stanford.edu/u/brando9/pycoq/pycoq/opam.py", line 892, in activate_opam_switch
raise e
File "/afs/cs.stanford.edu/u/brando9/pycoq/pycoq/opam.py", line 886, in activate_opam_switch
res = subprocess.run(command.split(), check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/dfs/scratch0/brando9/anaconda/envs/iit_synthesis/lib/python3.9/subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "/dfs/scratch0/brando9/anaconda/envs/iit_synthesis/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/dfs/scratch0/brando9/anaconda/envs/iit_synthesis/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'eval'
I think it has something to do with calling subprocesses from within python donât fully understand, refs:
- Is there a way to run the bash eval command in python? - Stack Overflow
- linux - Running `eval($ something)` commands using Python sub-process - Stack Overflow
- subprocess - Python check_output call to eval (with arguments) fails - Stack Overflow
- eval $(opam env): ocaml - What is the use of eval `opam config env` or eval $(opam env) and their difference? - Stack Overflow
- What is the difference between eval $(opam env --switch={switch} --set-switch) and opam switch set SWITCH? - Stack Overflow
I think an alternative would be to get the output of $(âŚ) then run that with subprocess (without bashâs eval I think).