From 32aa663b9654519e81ff377eaf80ff93fc7bae74 Mon Sep 17 00:00:00 2001 From: Simon Olofsson Date: Sat, 23 Sep 2023 11:50:14 +0200 Subject: [PATCH] Improved create_environment script file; automatic call to 'build.py' if not already present; with instructions at the end to make getting up to speed easier. --- devtools/create_environment.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/devtools/create_environment.py b/devtools/create_environment.py index 30c500e..0c8473e 100644 --- a/devtools/create_environment.py +++ b/devtools/create_environment.py @@ -7,7 +7,11 @@ from time import sleep sys.path.append(Path.cwd().parent.as_posix()) -os.chdir("..") + +if not Path("setup.py").exists(): + print("You're not in the right directory. Run this script from the " + r"project's root directory, e.g. 'C:\users\your_user\projects\pyttman'.") + exit(-1) LAB_ENV_PATH = Path.cwd() / Path("dev_env") BUILD_OUTPUT_PATH = Path.cwd() / "dist" @@ -17,10 +21,7 @@ shutil.rmtree((LAB_ENV_PATH / "venv").as_posix()) if not Path("dist").exists(): - print("\nCannot create local testing environment as there is no " - "build generated for the current local version of Pyttman.", - "Run 'build.py' to create one.") - exit(-1) + subprocess.check_call("python devtools/build.py".split()) LAB_ENV_PATH.mkdir(exist_ok=True) os.chdir(LAB_ENV_PATH.as_posix()) @@ -39,5 +40,16 @@ subprocess.run(f"{venv_python} -m pip install multidict".split()) subprocess.run(f"{venv_python} -m pip install {package_file}".split()) - print("\nFinished! You can now create an app and start testing in " - f"{LAB_ENV_PATH.as_posix()}.") + clear_sc = "clear" if os.name == "posix" else "cls" + os.system(clear_sc) + + os.system("cls") + print("\nFinished! Here's how to get started:", + f"1. Activate the virtual environment:\n\tcd dev_env\n\tvenv/scripts/activate", + f"2. Run the command 'pyttman' to see available commands to the Pyttman CLI", + "3. If it's the first time you're running Pyttman, run 'pyttman new app {app_name}' to create a new project." + "4. Run 'pyttman dev {app_name}' to start the development server.", + "5. If you've made changes to the Pyttman framework which you want to test in your testing project, " + "run this script again. Your app will be left untouched, but the Pyttman version is upgraded to " + "your current HEAD in the Pyttman repo.", + sep="\n")