auto python version

This commit is contained in:
Thephaseless 2024-10-18 13:29:27 +00:00
parent 5d70a911e5
commit 652db1caba

View File

@ -5,11 +5,13 @@ from __future__ import annotations
import logging import logging
import os import os
from pathlib import Path from pathlib import Path
from platform import python_version
env_path = os.getenv("VIRTUAL_ENV") env_path = os.getenv("VIRTUAL_ENV")
if env_path is None: if env_path is None:
env_path = Path(os.__file__).parent.parent.parent.as_posix() env_path = Path(os.__file__).parent.parent.parent.as_posix()
nodriver_path = Path(env_path + "/lib/python3.12/site-packages/nodriver/cdp/network.py") python_version = python_version().split(".")[0:2]
nodriver_path = Path(env_path + f"/lib/python{'.'.join(python_version)}/site-packages/nodriver/cdp/network.py")
if not nodriver_path.exists(): if not nodriver_path.exists():
msg = f"{nodriver_path} not found" msg = f"{nodriver_path} not found"
raise FileNotFoundError(msg) raise FileNotFoundError(msg)