Skip to content

Commit 310cc0d

Browse files
committed
new devtool script file; allows pyttman developers to update their test environment with a new build without destroying apps and files
1 parent d8e4c12 commit 310cc0d

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

devtools/update_environment.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Set the current working dir to parent directory
2+
import os
3+
import shutil
4+
import subprocess
5+
import sys
6+
from pathlib import Path
7+
from time import sleep
8+
9+
sys.path.append(Path.cwd().parent.as_posix())
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)
15+
16+
LAB_ENV_PATH = Path.cwd() / Path("dev_env")
17+
BUILD_OUTPUT_PATH = Path.cwd() / "dist"
18+
19+
if __name__ == "__main__":
20+
if not (LAB_ENV_PATH / "venv").exists():
21+
raise FileNotFoundError("Your dev environment is not set up, or "
22+
"is missing the virtual environment. "
23+
"Run devtools/create_environment.py first.")
24+
25+
print("Building new Pyttman package...")
26+
subprocess.check_call("python devtools/build.py".split())
27+
os.chdir(LAB_ENV_PATH.as_posix())
28+
subprocess.run("python -m virtualenv venv".split())
29+
30+
while not Path("venv").exists():
31+
sleep(0.01)
32+
33+
package_file = [
34+
i for i in os.listdir(BUILD_OUTPUT_PATH.as_posix()) if i.endswith("tar.gz")
35+
].pop()
36+
37+
print(f"Installing your new version of Pyttman from local build: '{package_file}'")
38+
package_file = (BUILD_OUTPUT_PATH / package_file).as_posix()
39+
venv_python = (LAB_ENV_PATH / "venv/scripts/python.exe").as_posix()
40+
subprocess.run(f"{venv_python} -m pip install multidict".split())
41+
subprocess.run(f"{venv_python} -m pip install --upgrade {package_file}".split())
42+
43+
clear_sc = "clear" if os.name == "posix" else "cls"
44+
os.system(clear_sc)
45+
os.system("cls")
46+
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)