pathext
pathext is a collection of functions working with pathlib.Path. They're often wrappers for standard library functionality with some extensions.
Executable lookup
pathext.which()
Wrapper for shutil.which() which returns the result as an absolute Path (or None if it fails to find the executable). It also has a couple extra features, see below.
Arguments (all of them except name are optional):
name: str- Executable name to look up.path: None | str | Sequence[Path]- Directory list to look upnamein. If set toNone, or set to a string, then it is passed toshutil.which()as-is. If set to a list, concatenates the list items usingos.pathsep, and passes the result toshutil.which(). Defaults toNone. Seeshutil.which()'s documentation on exact behaviour of this argument.cwd: Optional[Path]- If specified, then changes the current working directory tocwdfor the duration of theshutil.which()call. Note that since it is changing global state (the current working directory), it is inherently not thread-safe.
pathext.checked_which()
Same as pathext.which(), except it raises ValueError instead of returning None if it cannot find the executable.
Manipulating PATH strings
pathext.split_path_list()
Split PATH string based on os.pathsep and convert each component to pathlib.Path.
Empty components will be removed, i.e. leading, trailing or duplicated separators will not cause issues.
In contrast to str.split(), if the string is empty, the function will return an empty list.
pathext.join_path_list()
Create PATH string (os.pathsep-separated string) from list of paths. The list is allowed to contain Path objects, strings and even None. Empty strings and Nones will be removed before joining the list.
pathext.deduplicate_path_list()
Remove duplicates from path list, keeping only the first occurence. The list is allowed to contain Path objects, strings and even None. Empty strings and Nones will be removed before deduplication, and the rest is converted to Path.
Generic utilities
pathext.to_path()
Simple function that converts a str to a Path (just like Path's constructor), but also handles None by returning None. It can be used to convert the return value of functions that return str | None to Path | None.
pathext.temporary_directory()
Context manager similar to tempfile.TemporaryDirectory except it returns the created directory's name as an absolute pathlib.Path instead of str.
Supports all arguments of tempfile.TemporaryDirectory, including delete introduced in Python 3.12. If delete is specified on Python 3.11 or older, ValueError is raised.
Note that the returned path is always absolute, even if the dir parameter is relative. This is consistent with how tempfile.TemporaryDirectory works starting with Python 3.12.
pathext.chdir_context()
Non parallel-safe context manager to change the current working directory. If path is None, it does nothing. If path is not None, it changes the current working directory upon entering and restores the old one on exit.
Unlike contextlib.chdir(), this context manager is NOT reentrant or reusable.
See contextlib.chdir()'s documentation on notes about threaded and async contexts.
Metadata
Release files for pathext 1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pathext-1.5.tar.gz | 6.4 kB | Without provenance | Details for pathext-1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pathext-1.5-py3-none-any.whl | Python 3 | none | any | Details for pathext-1.5-py3-none-any.whl |
Total release size: 13.7 kB
Release files / pathext-1.5.tar.gz
| Download URL | pathext-1.5.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cbfd6f697a4874be7ea37109dbf60f108d451b44bb3df290f1560c75fa16bb87
|
|
BLAKE2b-256 checksum How to use checksums |
09b3cd7d7282c1640300630e963b84b6e202862206f5ac24959015d83372e16c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|
Release files / pathext-1.5-py3-none-any.whl
| Download URL | pathext-1.5-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3aedc261736dc714881676847dcc20ce2246b09d331ec09276b478477a469530
|
|
BLAKE2b-256 checksum How to use checksums |
d0d0aab254e2ba1e2a390261ef746c4129ef81b2d13289850380c5273026915d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|
Security for pathext 1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.