From f82e3d83587c9e5753b7f3d3ac526495a0ecd996 Mon Sep 17 00:00:00 2001 From: Petr Kouba Date: Tue, 4 Mar 2025 01:05:25 +0200 Subject: [PATCH] call python in subprocess as 'sys.executable' to make sure same python is used and to enable python3 alias being used by the user --- .../prot_domain_classifier/prot_domain_classifier.py | 4 ++-- src/protein_shapes/proteinmpnn/embed.py | 4 ++-- src/protein_shapes/proteinmpnn/proteinmpnn.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/protein_shapes/prot_domain_classifier/prot_domain_classifier.py b/src/protein_shapes/prot_domain_classifier/prot_domain_classifier.py index c3a22cd..6a6bde7 100755 --- a/src/protein_shapes/prot_domain_classifier/prot_domain_classifier.py +++ b/src/protein_shapes/prot_domain_classifier/prot_domain_classifier.py @@ -43,14 +43,14 @@ else: ref_embed_dir = output_dir / f"embeddings_{ref_suffix}" subprocess.run( - ["python", cur_dir / "embed.py", reference_structures, ref_embed_dir] + [sys.executable, cur_dir / "embed.py", reference_structures, ref_embed_dir] ) _, ref_embeds = load_embeddings(ref_embed_dir) samp_embed_dir = output_dir / f"embeddings_{samp_suffix}" if embed_samples != "precomputed": - subprocess.run(["python", cur_dir / "embed.py", sampled_structures, samp_embed_dir]) + subprocess.run([sys.executable, cur_dir / "embed.py", sampled_structures, samp_embed_dir]) else: samp_embed_dir = sampled_structures diff --git a/src/protein_shapes/proteinmpnn/embed.py b/src/protein_shapes/proteinmpnn/embed.py index e7a88e0..3b73c2f 100755 --- a/src/protein_shapes/proteinmpnn/embed.py +++ b/src/protein_shapes/proteinmpnn/embed.py @@ -2,7 +2,7 @@ from pathlib import Path import os import subprocess - +import sys def main(): parser = argparse.ArgumentParser( @@ -20,7 +20,7 @@ def main(): run_script = cur_dir / "run.py" clean_command = [str(clean_script), args.directory] - generate_json_command = ["python", str(generate_json_script), args.directory] + generate_json_command = [sys.executable, str(generate_json_script), args.directory] # print(f"gen command: {generate_json_command}") # subprocess.run(clean_command, check=True) diff --git a/src/protein_shapes/proteinmpnn/proteinmpnn.py b/src/protein_shapes/proteinmpnn/proteinmpnn.py index 715ec48..e6ad20a 100755 --- a/src/protein_shapes/proteinmpnn/proteinmpnn.py +++ b/src/protein_shapes/proteinmpnn/proteinmpnn.py @@ -49,7 +49,7 @@ else: ref_embed_dir = output_dir / f"embeddings_{ref_suffix}" subprocess.run( - ["python", cur_dir / "embed.py", reference_structures, ref_embed_dir] + [sys.executable, cur_dir / "embed.py", reference_structures, ref_embed_dir] ) _, ref_embeds = load_embeddings(ref_embed_dir) ref_embeds = np.transpose(ref_embeds, (1, 0, 2)) @@ -57,7 +57,7 @@ samp_embed_dir = output_dir / f"embeddings_{samp_suffix}" if embed_samples != "precomputed": - subprocess.run(["python", cur_dir / "embed.py", sampled_structures, samp_embed_dir]) + subprocess.run([sys.executable, cur_dir / "embed.py", sampled_structures, samp_embed_dir]) else: samp_embed_dir = sampled_structures