Skip to content

Commit 32aa663

Browse files
committed
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.
1 parent 8df9297 commit 32aa663

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

devtools/create_environment.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
from time import sleep
88

99
sys.path.append(Path.cwd().parent.as_posix())
10-
os.chdir("..")
10+
11+
if not Path("setup.py").exists():
12+
print("You're not in the right directory. Run this script from the "
13+
r"project's root directory, e.g. 'C:\users\your_user\projects\pyttman'.")
14+
exit(-1)
1115

1216
LAB_ENV_PATH = Path.cwd() / Path("dev_env")
1317
BUILD_OUTPUT_PATH = Path.cwd() / "dist"
@@ -17,10 +21,7 @@
1721
shutil.rmtree((LAB_ENV_PATH / "venv").as_posix())
1822

1923
if not Path("dist").exists():
20-
print("\nCannot create local testing environment as there is no "
21-
"build generated for the current local version of Pyttman.",
22-
"Run 'build.py' to create one.")
23-
exit(-1)
24+
subprocess.check_call("python devtools/build.py".split())
2425

2526
LAB_ENV_PATH.mkdir(exist_ok=True)
2627
os.chdir(LAB_ENV_PATH.as_posix())
@@ -39,5 +40,16 @@
3940
subprocess.run(f"{venv_python} -m pip install multidict".split())
4041
subprocess.run(f"{venv_python} -m pip install {package_file}".split())
4142

42-
print("\nFinished! You can now create an app and start testing in "
43-
f"{LAB_ENV_PATH.as_posix()}.")
43+
clear_sc = "clear" if os.name == "posix" else "cls"
44+
os.system(clear_sc)
45+
46+
os.system("cls")
47+
print("\nFinished! Here's how to get started:",
48+
f"1. Activate the virtual environment:\n\tcd dev_env\n\tvenv/scripts/activate",
49+
f"2. Run the command 'pyttman' to see available commands to the Pyttman CLI",
50+
"3. If it's the first time you're running Pyttman, run 'pyttman new app {app_name}' to create a new project."
51+
"4. Run 'pyttman dev {app_name}' to start the development server.",
52+
"5. If you've made changes to the Pyttman framework which you want to test in your testing project, "
53+
"run this script again. Your app will be left untouched, but the Pyttman version is upgraded to "
54+
"your current HEAD in the Pyttman repo.",
55+
sep="\n")

0 commit comments

Comments
 (0)