Skip to content

Commit aeff52c

Browse files
committed
use shutil which to get cmd path
1 parent 6e807dd commit aeff52c

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

setup.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
from __future__ import print_function
22

3+
import sys
4+
import os
5+
import pipes
6+
import shutil
7+
import subprocess
8+
39
from setuptools import setup, find_packages
10+
from distutils import log
411
from distutils.command.build import build # type: ignore
512
from distutils.command.sdist import sdist # type: ignore
613
from setuptools.command.develop import develop
7-
import os
8-
import subprocess
14+
15+
if sys.platform == "win32":
16+
from subprocess import list2cmdline
17+
else:
18+
19+
def list2cmdline(cmd_list):
20+
return " ".join(map(pipes.quote, cmd_list))
21+
922

1023
# the name of the project
1124
name = "idom"
@@ -109,10 +122,10 @@
109122
def build_javascript_first(cls):
110123
class Command(cls):
111124
def run(self):
112-
for cmd_str in ["npm install", "npm run build"]:
113-
subprocess.check_call(
114-
cmd_str.split(), cwd=os.path.join(root, "client", "app")
115-
)
125+
for cmd, *args in map(str.split, ["npm install", "npm run build"]):
126+
cmd_args = [shutil.which(cmd)] + args
127+
log.info(list2cmdline(cmd_args))
128+
subprocess.check_call(cmd_args, cwd=os.path.join(root, "client", "app"))
116129
super().run()
117130

118131
return Command

0 commit comments

Comments
 (0)