Drop-in replacement for shutil with long path support for Windows
Project description
LongPathShutil
LongPathShutil is a drop-in Python wrapper for the methods of the built-in shutil
library, providing enhanced support for long file paths on Windows. It leverages the \\?\
prefix to bypass the 260-character path length limit on Windows systems, and to be able to handle deeply nested or long file names. More info on the long path limitations on windows here
Features
- Seamlessly integrates long path support on Windows.
- Fully compatible with the existing
shutil
functions. The functions only. - Automatically prefixes paths with
\\?\
when necessary. - Offers functions to enable or disable long path support via the Windows registry at least for the applications supporting it. (Needs to be executed as admin)
Installation
You can install it like so:
pip install LongPathShutil
Usage
Enabling Long Paths in the Windows Registry
You can try programmatically enabling long paths via the registry. This does however require admin access and does not always work. Otherwise you can use the module as drop-in replacement for shutil on windows.
import LongPathShutil
# Enable long paths in the Windows registry (requires administrative privileges)
LongPathShutil.enable_long_paths_on_registry()
Basic File Operations
import LongPathShutil as shutil
# Copy a file with long paths
shutil.copy(r"C:\very\long\source\path\file.txt", r"C:\another\very\long\destination\path\file.txt")
# Move a directory with long paths
shutil.move(r"C:\very\long\source\directory", r"C:\another\very\long\destination\directory")
# Remove a directory tree with long paths
shutil.rmtree(r"C:\very\long\path\to\directory")
Full API
The LongPathShutil
class provides all the functions available in shutil
with the addition of long path support:
copyfile()
,copy()
,copy2()
move()
,rmtree()
,copytree()
make_archive()
,unpack_archive()
,get_archive_formats()
, and more.
See the complete list of functions here.
Why Use LongPathShutil?
By default, Windows imposes a 260-character limit on paths, which can cause problems when dealing with deeply nested directory structures or long filenames. This module automatically adds the necessary prefix to bypass this limitation, allowing for seamless file operations across various platforms.
Contributing
If you find a bug or have a suggestion, feel free to open an issue or submit a pull request. Make sure to check the CONTRIBUTING.md
for guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file longpathshutil-0.3.tar.gz
.
File metadata
- Download URL: longpathshutil-0.3.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa38290c42c65de23e9c5befd34467a6a7313d80a2a7946d94bb8b7585530eff |
|
MD5 | 405edf94ae68fed1f380f91e5891f452 |
|
BLAKE2b-256 | bdee43ac42652aa3fa53a01ccbd073cfc83c4ebf757bcfc7a6546ce177b27701 |
Provenance
The following attestation bundles were made for longpathshutil-0.3.tar.gz
:
Publisher:
ci.yml
on simonmb/LongPathShutil
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
longpathshutil-0.3.tar.gz
- Subject digest:
fa38290c42c65de23e9c5befd34467a6a7313d80a2a7946d94bb8b7585530eff
- Sigstore transparency entry: 146170486
- Sigstore integration time:
- Predicate type:
File details
Details for the file LongPathShutil-0.3-py3-none-any.whl
.
File metadata
- Download URL: LongPathShutil-0.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19e4a20097868aa344db65b2f3112b8385626291ee52d3e29e219e877efe6c35 |
|
MD5 | de739a6ef9ab3e73f9026b44a89b50c1 |
|
BLAKE2b-256 | c9efb126cc482b9895d46b2dd36d60636a2508cc6b0eb526c2868f32eb090136 |
Provenance
The following attestation bundles were made for LongPathShutil-0.3-py3-none-any.whl
:
Publisher:
ci.yml
on simonmb/LongPathShutil
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
longpathshutil-0.3-py3-none-any.whl
- Subject digest:
19e4a20097868aa344db65b2f3112b8385626291ee52d3e29e219e877efe6c35
- Sigstore transparency entry: 146170487
- Sigstore integration time:
- Predicate type: