feat: drop the psutil dependency and fix documentation divergences#44
Merged
Merged
Conversation
Make the core library truly dependency-free by replacing psutil with native per-platform process discovery, and correct a set of doc/docstring claims that did not match runtime behavior. Drop psutil: - Native process enumeration and pid checks: CreateToolhelp32Snapshot (Windows), /proc (Linux), libproc proc_listpids/proc_name (macOS). - process.util now dispatches to the per-OS backend instead of psutil. - psutil moves from a hard runtime dependency to the [app] extra (the GUI process picker still uses its richer username/memory info). - Add tests/test_process_enumeration.py and rewire the lookup tests off psutil. Docs/docstring fixes: - DEFAULT_MAX_REGION_CHUNK is 256 MiB (was documented as 16 MiB). - iter_region_chunks chunks are contiguous, not overlapping. - partial reads raise OSError; they are not logged as WARNING. - ThreadInfo.start_address is always None on every backend. - RemotePointer bufflength is required only to read str/bytes, not write. - Correct the compile_pattern example output. - OpenProcess signature shows the real platform-specific defaults. - macOS ModuleInfo name/path are both empty when the path is unresolvable. - read_string reads exactly byte_count bytes (raises on a short read). - ptr_size defaults to None (auto-detected) across the pointer APIs. - Migrate search_by_value/search_by_addresses examples to keyword args.
6b21cf6 to
7e5923b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the core library truly dependency-free by replacing
psutilwith native per-platform process discovery, and corrects a set of documentation/docstring claims that did not match the actual runtime behavior.Drop psutil
psutilwas the only hard runtime dependency, used solely to resolve a process name to a PID and to check whether a PID exists. Both are now done natively:CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS)+Process32First/Next; pid check viaOpenProcess(PROCESS_QUERY_LIMITED_INFORMATION)./proc/<pid>, read the name from/proc/<pid>/comm; pid check via/proc/<pid>.proc_listpids+proc_name(basename ofproc_pidpathas fallback); pid check viaos.kill(pid, 0).process.utilnow dispatches to the per-OS backend.psutilmoves from a required dependency to the[app]extra — the desktop GUI's process picker still uses its richer username/memory info, which is beyond what the core needs.Process-name matching semantics (
case_sensitive,exact_match) are preserved. On Linux the name comes fromcomm, which the kernel truncates to 15 characters — the same limitationpsutilhad here.Documentation/docstring fixes
DEFAULT_MAX_REGION_CHUNKis 256 MiB (was documented as 16 MiB).iter_region_chunkschunks are contiguous, not overlapping (pattern-boundary handling happens in the scanner).OSError— they are not logged asWARNING.ThreadInfo.start_addressis alwaysNoneon every backend (documented as reserved).RemotePointerbufflengthis required only to readstr/bytes; writing acceptsNone.compile_patternexample output.OpenProcesssignature now shows the real platform-specific defaults.ModuleInfoname/pathare both empty when the image path can't be resolved (the fallback only applies on Windows).read_stringreads exactlybyte_countbytes (raises on a short read), not "up to".ptr_sizedefaults toNone(auto-detected from target bitness) across the pointer APIs.search_by_value/search_by_addressesexamples to keyword arguments.Testing
tests/test_process_enumeration.pyexercises the native enumeration andpid_existson the host OS.psutil.