This module transfers the import path to the project root so you can easily import from neighboring folders.
Project description
🚀 supermagicmporter
This module dynamically adds your project's root directory to sys.path. It allows you to perform clean imports from neighboring folders or subdirectories without struggling with relative import errors.
🛠 Installation
pip install supermagicmporter
📖 How to Use To use this module, you need to call set_root_folder at the very beginning of your main script.
from supermagicmporter import set_root_folder
# Initialize the root path
# Pass __file__ to automatically detect the current script's location
set_root_folder(__file__, 'yourRootFolder')
# Now you can import from your project folders easily
from my_subfolder import my_module
Arguments
| Args | Description |
|---|---|
| file | Provides the current script's path. By passing the __file__ magic variable, the location is automatically resolved. |
| root_folder_name | The exact name of your project's root directory as a string. |
⚠️ Important Notes
Memory Storage: The set_root_folder function stores the absolute path of the target folder in Python's memory for the duration of the session.
Import Order: From the line set_root_folder onwards, your project structure is prioritized. If you need to import standard Python libraries or other installed packages that might have name conflicts, perform those imports before calling this function.
Path Resolution: Ensure the root_folder_name matches your directory casing exactly.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file supermagicmporter-0.0.3.tar.gz.
File metadata
- Download URL: supermagicmporter-0.0.3.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5034bebe4f0182c7a02447058bfca8f150ed622465c2a26db97d38a365ecae9a
|
|
| MD5 |
4e3fb5c41522705d558d7628221626ae
|
|
| BLAKE2b-256 |
0e012c903be3acdcf9a9c7573ff997082bf3f42457ecde187bc5d14d82f217b4
|
File details
Details for the file supermagicmporter-0.0.3-py3-none-any.whl.
File metadata
- Download URL: supermagicmporter-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78ca2a1325115b8e669cc35dc9921933175a0765f13b695b62183d9cb55f88e7
|
|
| MD5 |
e2c6f697c8da8a7b7ac9068025359614
|
|
| BLAKE2b-256 |
fecfed882b644f4a8421c5e60da28f6141181291ebb5d0d9c0a632a7c6c3fedb
|