Skip to content

Commit 48617dd

Browse files
Robust subprocess calls in CLI using current interpreter path
1 parent a84a4cc commit 48617dd

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

pythoncms/cli.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,30 +75,40 @@ def start(name, run):
7575
if run:
7676
os.chdir(dest)
7777
click.echo("Running initialization...")
78-
subprocess.run(["shopyo", "initialise"], check=True)
78+
bin_dir = os.path.dirname(sys.executable)
79+
shopyo_cmd = os.path.join(bin_dir, "shopyo")
80+
flask_cmd = os.path.join(bin_dir, "flask")
81+
82+
subprocess.run([shopyo_cmd, "initialise"], check=True)
7983
click.echo("Seeding database...")
80-
subprocess.run(["flask", "shopyo-seed"], check=True)
84+
subprocess.run([flask_cmd, "shopyo-seed"], check=True)
8185
click.echo("Starting server...")
82-
subprocess.run(["flask", "--debug", "run"], check=True)
86+
subprocess.run([flask_cmd, "--debug", "run"], check=True)
8387

8488

8589
@cli.command("initialise")
8690
def initialise():
8791
"""Initialise the project database and assets"""
88-
subprocess.run(["shopyo", "initialise"], check=True)
92+
bin_dir = os.path.dirname(sys.executable)
93+
shopyo_cmd = os.path.join(bin_dir, "shopyo")
94+
subprocess.run([shopyo_cmd, "initialise"], check=True)
8995

9096

9197
@cli.command("seed")
9298
def seed():
9399
"""Seed the database with default data"""
94-
subprocess.run(["flask", "shopyo-seed"], check=True)
100+
bin_dir = os.path.dirname(sys.executable)
101+
flask_cmd = os.path.join(bin_dir, "flask")
102+
subprocess.run([flask_cmd, "shopyo-seed"], check=True)
95103

96104

97105
@cli.command("run")
98106
@click.option("--debug", is_flag=True, default=True)
99107
def run(debug):
100108
"""Run the development server"""
101-
args = ["flask"]
109+
bin_dir = os.path.dirname(sys.executable)
110+
flask_cmd = os.path.join(bin_dir, "flask")
111+
args = [flask_cmd]
102112
if debug:
103113
args.append("--debug")
104114
args.append("run")

0 commit comments

Comments
 (0)