-
Notifications
You must be signed in to change notification settings - Fork 175
Fix: Cross-Platform Path Handling Standardization #886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix: Cross-Platform Path Handling Standardization #886
Conversation
PR #886 Review: Cross-Platform Path Handling StandardizationExecutive SummaryThis PR successfully addresses issue #882 by implementing comprehensive cross-platform path handling utilities and migrating critical modules away from platform-specific hardcoded paths. However, there are three failing tests that need to be fixed before merging. Test Failures Analysis1. Address Validation Issue:
|
…er resource cleanup on exit and during logging setup. Update tests to ensure file handlers are closed correctly across platforms.
…p and cleanup functions for improved readability. Update tests to reflect formatting changes.
What was wrong?
Issue #882 - The py-libp2p had inconsistent & platform-specific path handling that was causing failures for different operating systems. The previous work in the PR #792 was incomplete, leaving critical core modules with hardcoded paths and missing cross-platform utilities.
Specific Problems:
libp2p/utils/logging.py
using platform-specific paths (/tmp
for Unix,C:\Windows\Temp
for Windows)os.path.join()
usage in examples and documentation instead of standardized utilitiesHow was it fixed?
Comprehensive Cross-Platform Path Utilities Enhancement
Approach: Updated the existing
libp2p/utils/paths.py
module file with a new set of cross-platform utilities measures, for use by all the critical modules.1. New Core Path Utilities
Added 5 new functions to
libp2p/utils/paths.py
:get_venv_path()
- Virtual environment detectionget_python_executable()
- Python executable path resolutionfind_executable(name)
- System PATH binary searchget_script_binary_path()
- Script binary directoryget_binary_path(binary_name)
- Virtual environment-aware binary resolution2. Critical Core Module Migration
libp2p/utils/logging.py
: Replaced the hardcoded temp paths withcreate_temp_file()
utilityexamples/kademlia/kademlia.py
: Migrated fromos.path.join()
tojoin_paths()
docs/conf.py
: Updated to useget_project_root()
andjoin_paths()
3. Comprehensive Testing & Quality Assurance
4. Audit + Review
Technical Implementation Details
Before (Platform-Specific):
After (Cross-Platform):
This PR successfully resolves #882 by completing the cross-platform path handling standardization, making py-libp2p more robust and maintainable across Windows, macOS, and Linux platforms while preserving all existing functionality.
cc: @seetadev @acul71 @pacrob