Skip to main content

relpath - relative path module

Python package GitHub license Known Vulnerabilities

This module addresses a limitation of the pathlib.Path class. When using Path, if the relative path is not a subdirectory of the base path, it raises a ValueError. However, with this module, that weakness is eliminated.

Installation

pip install rel-path

Example for error:

from pathlib import Path

base="/home"
rel="/"

# Error when using Path
Path(rel).relative_to(base)

Exception has occurred: ValueError
'/' does not start with '/home'

Example using relpath module:

from relpath import relative_path

base="/home"
rel="/"

print(relative_path(base, rel))
../

Configure PyPi API Token

Poetry is used to manage the package. How to publish

To configure the PyPi API token, use the following command once:

# Run once to set the PyPi API token
set +o history
poetry config pypi-token.pypi '<your-pypi-token>'
set -o history

# Build the package
poetry build

# Publish the package
poetry publish

Support

If you encounter any issues with the relpath module, please report them on GitHub. I will respond as soon as possible. Contributions to the code are always welcome, and I appreciate ideas for new modules or improvements to existing ones.

Change Log

[1.0.3] - 2024-08-23

Fixed

  • Fixed the Github Actions for python tests

[1.0.2] - 2024-08-23

Added

  • Added support for poetry
  • Added Change Log to README.md

Removed

  • Support for Python 3.6, 3.7, and 3.7

Metadata

Release files for rel-path 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rel-path 1.0.3
File Size Uploaded Provenance Actions
rel_path-1.0.3.tar.gz 3.3 kB Without provenance Details for rel_path-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rel-path 1.0.3
File Interpreter ABI Platform Actions
rel_path-1.0.3-py3-none-any.whl Python 3 none any Details for rel_path-1.0.3-py3-none-any.whl

Total release size: 6.9 kB

Release files / rel_path-1.0.3.tar.gz

Download URL rel_path-1.0.3.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
63232fc031c4f1d8d08a2c5534a71e4eae1a14312ac57e417b8ebcfbb3c10cf4
BLAKE2b-256 checksum
How to use checksums
bd8fa49c757ffb33602b5ff04c91dc795736f5f07c7e1cef5fba0ef107ccc517
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.14 Linux/5.15.0-118-generic

Release files / rel_path-1.0.3-py3-none-any.whl

Download URL rel_path-1.0.3-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1701d3ba2305ef26fd383127015cae9a67fbcd6237e30c08f0aaa6dc4c569797
BLAKE2b-256 checksum
How to use checksums
812d614f762451dca0af631cc4f3e3dfde2466178c898c85b1fe095720dd801f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.14 Linux/5.15.0-118-generic

Security for rel-path 1.0.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page