Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

supermagicmporter-0.0.3.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

supermagicmporter-0.0.3-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

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

Hashes for supermagicmporter-0.0.3.tar.gz
Algorithm Hash digest
SHA256 5034bebe4f0182c7a02447058bfca8f150ed622465c2a26db97d38a365ecae9a
MD5 4e3fb5c41522705d558d7628221626ae
BLAKE2b-256 0e012c903be3acdcf9a9c7573ff997082bf3f42457ecde187bc5d14d82f217b4

See more details on using hashes here.

File details

Details for the file supermagicmporter-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for supermagicmporter-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 78ca2a1325115b8e669cc35dc9921933175a0765f13b695b62183d9cb55f88e7
MD5 e2c6f697c8da8a7b7ac9068025359614
BLAKE2b-256 fecfed882b644f4a8421c5e60da28f6141181291ebb5d0d9c0a632a7c6c3fedb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page