Skip to content

Instantly share code, notes, and snippets.

@lafftar
Created May 11, 2022 14:09
Show Gist options
  • Save lafftar/fba75ea40e6322588c5481af9513c40a to your computer and use it in GitHub Desktop.
Save lafftar/fba75ea40e6322588c5481af9513c40a to your computer and use it in GitHub Desktop.
import sys
from pathlib import Path
def get_project_root() -> str:
"""
This fx is super important!
Literally everything acts up if this isn't good.
"""
if getattr(sys, 'frozen', False):
compiled_path = Path(sys.executable).parent
return compiled_path
else:
path = str(Path(__file__).parent.parent)
path = path.replace("\\", '/')
return fr'{path}'
if __name__ == "__main__":
print(get_project_root())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment