A no-nonsense utility for importing relative to root
Project description
root_directory
Tired of the Python "Importing files from different folder" mess?
This is a no-nonsense utility for importing relative to root. So for a directory structure like that:
* your_lib
* lib.py
* your_main
* main.py
* .root_directory
You can now import lib.py
from main.py
with the following:
import root_directory # This must be before imports relative to root
from your_lib import lib
This works as long as the root directory is a git repository or contains .root_directory
in the root.
As a bonus, you can find out your root path with root_directory.get_root()
(this returns a pathlib.Path object).
Why another library?
There are several libraries that do something similar, however as far as I know, they either 1) only find the path, but don't help with importing, or 2) add many unnecessary and heavyweight dependencies.
This project has no dependencies.
Installation
Run pip install root_directory
, python 3.4+ is supported.
Project details
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
Hashes for root_directory-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecf5051a5c03680a7a6fae8a4060d11c267f6ef5798ba536bd7f74d7e225f9d0 |
|
MD5 | 02f7fe2bc6a770a28d3d9e28d56c2ad8 |
|
BLAKE2b-256 | cc855d7fc2716ad9afd705ad69dedbfd8f5262fa16a36a636a01ba870053e37c |