Loading pkgs/development/python-modules/pyshark/default.nix +9 −11 Original line number Diff line number Diff line Loading @@ -7,9 +7,9 @@ fetchpatch, lxml, packaging, py, pytestCheckHook, pythonOlder, replaceVars, setuptools, termcolor, wireshark-cli, }: Loading @@ -17,9 +17,7 @@ buildPythonPackage rec { pname = "pyshark"; version = "0.6"; format = "setuptools"; disabled = pythonOlder "3.7"; pyproject = true; src = fetchFromGitHub { owner = "KimiNewt"; Loading @@ -37,24 +35,24 @@ buildPythonPackage rec { url = "https://github.com/KimiNewt/pyshark/commit/7142c5bf88abcd4c65c81052a00226d6155dda42.patch"; hash = "sha256-Ti7cwRyYSbF4a4pEEV9FntNevkV/JVXNqACQWzoma7g="; }) (replaceVars ./hardcode-tshark-path.patch { tshark = lib.getExe' wireshark-cli "tshark"; }) ]; sourceRoot = "${src.name}/src"; # propagate wireshark, so pyshark can find it when used propagatedBuildInputs = [ build-system = [ setuptools ]; dependencies = [ appdirs lxml packaging py termcolor wireshark-cli ]; nativeCheckInputs = [ py pytestCheckHook wireshark-cli ]; preCheck = '' Loading pkgs/development/python-modules/pyshark/hardcode-tshark-path.patch 0 → 100644 +30 −0 Original line number Diff line number Diff line diff --git a/src/pyshark/tshark/tshark.py b/src/pyshark/tshark/tshark.py index 73ede9d..17c0488 100644 --- a/src/pyshark/tshark/tshark.py +++ b/src/pyshark/tshark/tshark.py @@ -47,24 +47,7 @@ def get_process_path(tshark_path=None, process_name="tshark"): f"{process_name}.exe" if sys.platform.startswith("win") else process_name) possible_paths.insert(0, user_tshark_path) - # Windows search order: configuration file"s path, common paths. - if sys.platform.startswith("win"): - for env in ("ProgramFiles(x86)", "ProgramFiles"): - program_files = os.getenv(env) - if program_files is not None: - possible_paths.append( - os.path.join(program_files, "Wireshark", f"{process_name}.exe") - ) - # Linux, etc. search order: configuration file's path, the system's path - else: - os_path = os.getenv( - "PATH", - "/usr/bin:/usr/sbin:/usr/lib/tshark:/usr/local/bin" - ) - for path in os_path.split(":"): - possible_paths.append(os.path.join(path, process_name)) - if sys.platform.startswith("darwin"): - possible_paths.append(f"/Applications/Wireshark.app/Contents/MacOS/{process_name}") + possible_paths.append("@tshark@") for path in possible_paths: if os.path.exists(path): Loading
pkgs/development/python-modules/pyshark/default.nix +9 −11 Original line number Diff line number Diff line Loading @@ -7,9 +7,9 @@ fetchpatch, lxml, packaging, py, pytestCheckHook, pythonOlder, replaceVars, setuptools, termcolor, wireshark-cli, }: Loading @@ -17,9 +17,7 @@ buildPythonPackage rec { pname = "pyshark"; version = "0.6"; format = "setuptools"; disabled = pythonOlder "3.7"; pyproject = true; src = fetchFromGitHub { owner = "KimiNewt"; Loading @@ -37,24 +35,24 @@ buildPythonPackage rec { url = "https://github.com/KimiNewt/pyshark/commit/7142c5bf88abcd4c65c81052a00226d6155dda42.patch"; hash = "sha256-Ti7cwRyYSbF4a4pEEV9FntNevkV/JVXNqACQWzoma7g="; }) (replaceVars ./hardcode-tshark-path.patch { tshark = lib.getExe' wireshark-cli "tshark"; }) ]; sourceRoot = "${src.name}/src"; # propagate wireshark, so pyshark can find it when used propagatedBuildInputs = [ build-system = [ setuptools ]; dependencies = [ appdirs lxml packaging py termcolor wireshark-cli ]; nativeCheckInputs = [ py pytestCheckHook wireshark-cli ]; preCheck = '' Loading
pkgs/development/python-modules/pyshark/hardcode-tshark-path.patch 0 → 100644 +30 −0 Original line number Diff line number Diff line diff --git a/src/pyshark/tshark/tshark.py b/src/pyshark/tshark/tshark.py index 73ede9d..17c0488 100644 --- a/src/pyshark/tshark/tshark.py +++ b/src/pyshark/tshark/tshark.py @@ -47,24 +47,7 @@ def get_process_path(tshark_path=None, process_name="tshark"): f"{process_name}.exe" if sys.platform.startswith("win") else process_name) possible_paths.insert(0, user_tshark_path) - # Windows search order: configuration file"s path, common paths. - if sys.platform.startswith("win"): - for env in ("ProgramFiles(x86)", "ProgramFiles"): - program_files = os.getenv(env) - if program_files is not None: - possible_paths.append( - os.path.join(program_files, "Wireshark", f"{process_name}.exe") - ) - # Linux, etc. search order: configuration file's path, the system's path - else: - os_path = os.getenv( - "PATH", - "/usr/bin:/usr/sbin:/usr/lib/tshark:/usr/local/bin" - ) - for path in os_path.split(":"): - possible_paths.append(os.path.join(path, process_name)) - if sys.platform.startswith("darwin"): - possible_paths.append(f"/Applications/Wireshark.app/Contents/MacOS/{process_name}") + possible_paths.append("@tshark@") for path in possible_paths: if os.path.exists(path):