Coverage for mddb_workflow / __init__.py: 58%

19 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2025-12-03 18:45 +0000

1import os 

2import subprocess 

3from rdkit import RDLogger 

4# Mute RDKit warnings 

5lg = RDLogger.logger() 

6lg.setLevel(RDLogger.ERROR) 

7 

8name = "mddb_workflow" 

9__all__ = ["resources", "tools", "utils"] 

10 

11try: 

12 from importlib.metadata import version 

13 __version__ = version("mddb_workflow") 

14except Exception: 

15 __version__ = "unknown" 

16 

17# Workaround to fix ReadTheDocs build issue with conda environments 

18# when fix_gromacs_masses and helical_parameters are called. 

19if "CONDA_PREFIX" not in os.environ: 

20 try: 

21 # Get the path of the python executable 

22 python_path = subprocess.check_output(["which", "python"], text=True).strip() 

23 # Extract the directory path (one level up from bin/python) 

24 conda_prefix = os.path.dirname(os.path.dirname(python_path)) 

25 # Set the environment variable 

26 os.environ["CONDA_PREFIX"] = conda_prefix 

27 except subprocess.SubprocessError: 

28 print("Warning: Could not determine CONDA_PREFIX from 'which python'")