55
66import nox
77import platformdirs
8-
8+ from dotenv import load_dotenv
99from nox .command import CommandFailed
1010from nox .sessions import Session
1111
1818SCRIPTS_FOLDER : Path = REPO_ROOT / "scripts"
1919TEMPLATE_FOLDER : Path = REPO_ROOT / "{{cookiecutter.project_name}}"
2020
21+
22+ # Load environment variables from .env and .env.local (if present)
23+ _env_file : Path = REPO_ROOT / ".env"
24+ _env_local_file : Path = REPO_ROOT / ".env.local"
25+ if _env_file .exists ():
26+ load_dotenv (_env_file )
27+ if _env_local_file .exists ():
28+ load_dotenv (_env_local_file , override = True )
29+
2130APP_AUTHOR : str = os .getenv ("COOKIECUTTER_ROBUST_PYTHON_APP_AUTHOR" , "robust-python" )
2231COOKIECUTTER_ROBUST_PYTHON_CACHE_FOLDER : Path = Path (
2332 platformdirs .user_cache_path (
4958@nox .session (python = DEFAULT_TEMPLATE_PYTHON_VERSION , name = "generate-demo" )
5059def generate_demo (session : Session ) -> None :
5160 """Generates a project demo using the cookiecutter-robust-python template."""
52- session .install ("cookiecutter" , "cruft" , "platformdirs" , "loguru" , "typer" )
61+ session .install ("cookiecutter" , "cruft" , "platformdirs" , "loguru" , "python-dotenv" , " typer" )
5362 session .run ("python" , GENERATE_DEMO_SCRIPT , * GENERATE_DEMO_OPTIONS , * session .posargs )
5463
5564
@@ -127,7 +136,7 @@ def test(session: Session) -> None:
127136@nox .session (python = DEFAULT_TEMPLATE_PYTHON_VERSION , name = "update-demo" )
128137def update_demo (session : Session , add_rust_extension : bool ) -> None :
129138 session .log ("Installing script dependencies for updating generated project demos..." )
130- session .install ("cookiecutter" , "cruft" , "platformdirs" , "loguru" , "typer" )
139+ session .install ("cookiecutter" , "cruft" , "platformdirs" , "loguru" , "python-dotenv" , " typer" )
131140
132141 session .log ("Updating generated project demos..." )
133142 args : list [str ] = [* UPDATE_DEMO_OPTIONS ]
@@ -152,7 +161,7 @@ def release_template(session: Session):
152161 session .skip ("Git not available." )
153162
154163 session .log ("Checking Commitizen availability via uvx." )
155- session .run ("cz" , "--version" , success_codes = [0 ])
164+ session .run ("cz" , "--version" , successcodes = [0 ])
156165
157166 increment = session .posargs [0 ] if session .posargs else None
158167 session .log (
0 commit comments