# [relpath](https://github.com/jifox/relpath.git) - relative path module
 [](https://github.com/Naereen/StrapDown.js/blob/master/LICENSE) [](https://snyk.io/test/github/jifox/relpath)
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
```bash
pip install rel-path
```
- [View on PyPi](https://pypi.org/project/rel-path/)
- [View on GitHub](https://github.com/jifox/relpath)
## Example for error:
```python
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:
```python
from relpath import relative_path
base="/home"
rel="/"
print(relative_path(base, rel))
../
```
## Configure PyPi API Token
[Poetry](https://python-poetry.org/) is used to manage the package.
[How to publish](https://www.digitalocean.com/community/tutorials/how-to-publish-python-packages-to-pypi-using-poetry-on-ubuntu-22-04)
To configure the PyPi API token, use the following command once:
```bash
# 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
Raw data
{
"_id": null,
"home_page": "https://github.com/jifox/relpath",
"name": "rel-path",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Josef Fuchs",
"author_email": "josef.fuchs@j-fuchs.at",
"download_url": "https://files.pythonhosted.org/packages/bd/8f/a49c757ffb33602b5ff04c91dc795736f5f07c7e1cef5fba0ef107ccc517/rel_path-1.0.3.tar.gz",
"platform": null,
"description": "# [relpath](https://github.com/jifox/relpath.git) - relative path module\n\n [](https://github.com/Naereen/StrapDown.js/blob/master/LICENSE) [](https://snyk.io/test/github/jifox/relpath)\n\nThis 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.\n\n## Installation\n\n```bash\npip install rel-path\n```\n\n- [View on PyPi](https://pypi.org/project/rel-path/)\n- [View on GitHub](https://github.com/jifox/relpath)\n\n## Example for error:\n\n```python\nfrom pathlib import Path\n\nbase=\"/home\"\nrel=\"/\"\n\n# Error when using Path\nPath(rel).relative_to(base)\n\nException has occurred: ValueError\n'/' does not start with '/home'\n```\n\n## Example using relpath module:\n\n```python\nfrom relpath import relative_path\n\nbase=\"/home\"\nrel=\"/\"\n\nprint(relative_path(base, rel))\n../\n```\n\n## Configure PyPi API Token\n\n[Poetry](https://python-poetry.org/) is used to manage the package.\n[How to publish](https://www.digitalocean.com/community/tutorials/how-to-publish-python-packages-to-pypi-using-poetry-on-ubuntu-22-04)\n\nTo configure the PyPi API token, use the following command once:\n\n```bash\n# Run once to set the PyPi API token\nset +o history\npoetry config pypi-token.pypi '<your-pypi-token>'\nset -o history\n\n# Build the package\npoetry build\n\n# Publish the package\npoetry publish\n```\n\n\n\n## Support\n\nIf 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.\n\n\n# Change Log\n\n## [1.0.3] - 2024-08-23\n\n### Fixed\n\n- Fixed the Github Actions for python tests\n\n## [1.0.2] - 2024-08-23\n\n### Added\n\n- Added support for poetry\n- Added Change Log to README.md\n\n### Removed\n\n- Support for Python 3.6, 3.7, and 3.7\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Get relative path.",
"version": "1.0.3",
"project_urls": {
"Homepage": "https://github.com/jifox/relpath",
"Repository": "https://github.com/jifox/relpath"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "812d614f762451dca0af631cc4f3e3dfde2466178c898c85b1fe095720dd801f",
"md5": "120b0cf73c74670502c76a0911440f4f",
"sha256": "1701d3ba2305ef26fd383127015cae9a67fbcd6237e30c08f0aaa6dc4c569797"
},
"downloads": -1,
"filename": "rel_path-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "120b0cf73c74670502c76a0911440f4f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 3590,
"upload_time": "2024-08-23T09:16:40",
"upload_time_iso_8601": "2024-08-23T09:16:40.484171Z",
"url": "https://files.pythonhosted.org/packages/81/2d/614f762451dca0af631cc4f3e3dfde2466178c898c85b1fe095720dd801f/rel_path-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bd8fa49c757ffb33602b5ff04c91dc795736f5f07c7e1cef5fba0ef107ccc517",
"md5": "32ccfa9824eb3ca07c5838359128228d",
"sha256": "63232fc031c4f1d8d08a2c5534a71e4eae1a14312ac57e417b8ebcfbb3c10cf4"
},
"downloads": -1,
"filename": "rel_path-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "32ccfa9824eb3ca07c5838359128228d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 3295,
"upload_time": "2024-08-23T09:16:41",
"upload_time_iso_8601": "2024-08-23T09:16:41.411883Z",
"url": "https://files.pythonhosted.org/packages/bd/8f/a49c757ffb33602b5ff04c91dc795736f5f07c7e1cef5fba0ef107ccc517/rel_path-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-23 09:16:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jifox",
"github_project": "relpath",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "rel-path"
}