do-relative
Open and import relatively.
Open files relative to the module you are in, instead of __main__ module.
Import modules relatively, directly using import module syntax, without using the from . syntax.
Or use from . even if you are not in a package.
Import relative to given custom paths, including root directory so you can do an absolute import.
Installation
pip install do-relative
Api Reference
class do_relative.RelativeOpener()
Constructor of this class returns an open function, instead of its instance.
The paths you give to this function will be treated as relative to the directory calling module resides in.
do_relative.relative_import(import_statement, folder = None)
Executes the import_statement in caller's scope and relative to the calling module's location. Calling this function from another function is not supported. In that case, no new names will be introduced to caller's scope. import_statement must be a string. Examples: "import module", "from module import func" or "from .. import module". As a side note, you don't have to be in a package to use the syntax shown in the last example. If supplied, folder must be a path string. If folder is provided import will be relative to that path instead of calling module's location. folder can either be relative to current working directory or absolute. You can pass "/" as the folder and make an absolute import. On windows "/" will be converted to the root directory of some drive. Drive is determined by the current working directory.
Metadata
Release files for do-relative 1.0.0
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 |
|---|---|---|---|---|
| do_relative-1.0.0.tar.gz | 2.0 kB | Without provenance | Details for do_relative-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| do_relative-1.0.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for do_relative-1.0.0-py2.py3-none-any.whl |
Total release size: 4.5 kB
Release files / do_relative-1.0.0.tar.gz
| Download URL | do_relative-1.0.0.tar.gz |
|---|---|
| Size | 2.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19b3bf35442105d89df8fd7bc73c12655a940fdcf95f5dd2da9319aa476b3832
|
|
BLAKE2b-256 checksum How to use checksums |
834ef018783c0b1ea3497677babf78f54bbaf1cb3f922404f703281648a95307
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Release files / do_relative-1.0.0-py2.py3-none-any.whl
| Download URL | do_relative-1.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 2.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
51c54d098a79edfe736719db1a86add751a15bc8ba3a491bace29e4f4fc24114
|
|
BLAKE2b-256 checksum How to use checksums |
de81579cc38d9306783407e7924cccd02895587e12171611f12485428bd56dca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Security for do-relative 1.0.0
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.