ppqs 2.2.1__tar.gz → 2.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ppqs
3
- Version: 2.2.1
3
+ Version: 2.3.1
4
4
  Summary: Python project quick scripts
5
5
  Author-email: Karl Wette <karl.wette@anu.edu.au>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ppqs"
7
- version = "2.2.1"
7
+ version = "2.3.1"
8
8
  description = "Python project quick scripts"
9
9
  authors = [
10
10
  { name = "Karl Wette", email = "karl.wette@anu.edu.au" },
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ppqs
3
- Version: 2.2.1
3
+ Version: 2.3.1
4
4
  Summary: Python project quick scripts
5
5
  Author-email: Karl Wette <karl.wette@anu.edu.au>
6
6
  License-Expression: MIT
@@ -233,24 +233,6 @@ def run_script(scripts, script_name, argv, cwd, has_been_run):
233
233
  for command in script["commands"]:
234
234
  cmd = []
235
235
 
236
- cmd_exec = command.pop(0)
237
- if cmd_exec == "ppqs":
238
-
239
- # Recursively run script
240
- # - silently ignore scripts which have already been run
241
- script_name_r = command.pop(0)
242
- if script_name_r not in has_been_run:
243
- run_script(scripts, script_name_r, argv, cwd, has_been_run)
244
- continue
245
-
246
- elif cmd_exec == "python":
247
-
248
- # Use same Python as ppqs to run Python scripts
249
- cmd.append(sys.executable)
250
-
251
- else:
252
- cmd.append(cmd_exec)
253
-
254
236
  for arg in command:
255
237
  if isinstance(arg, Path):
256
238
  if "*" in arg.parts[-1]:
@@ -269,6 +251,20 @@ def run_script(scripts, script_name, argv, cwd, has_been_run):
269
251
  else:
270
252
  cmd.append(arg)
271
253
 
254
+ if cmd[0] == "ppqs":
255
+
256
+ # Recursively run script
257
+ # - silently ignore scripts which have already been run
258
+ script_name_r = cmd[1]
259
+ if script_name_r not in has_been_run:
260
+ run_script(scripts, script_name_r, cmd[2:], cwd, has_been_run)
261
+ continue
262
+
263
+ elif cmd[0] == "python":
264
+
265
+ # Use same Python as ppqs to run Python scripts
266
+ cmd[0] = sys.executable
267
+
272
268
  # Print header
273
269
  if script["print-header"]:
274
270
  cmd_str = " ".join(cmd)
@@ -276,7 +272,7 @@ def run_script(scripts, script_name, argv, cwd, has_been_run):
276
272
  print(header, flush=True)
277
273
 
278
274
  # Run command
279
- retn = subprocess.run(cmd, stdin=subprocess.DEVNULL, shell=False, cwd=cwd)
275
+ retn = subprocess.run(cmd, shell=False, cwd=cwd)
280
276
  if retn.returncode != 0:
281
277
  raise SystemExit(retn.returncode)
282
278
 
@@ -39,11 +39,11 @@ def pyproject_path(tmp_path):
39
39
  ["python", "-c", "import sys; print(*sys.argv[1:])", ["subdir", "*.txt"]],
40
40
  ]
41
41
  [tool.ppqs.scripts.greeting]
42
- script = "echo Hello"
42
+ script = "echo Hello ..."
43
43
  [tool.ppqs.scripts.farewell]
44
44
  script = '''
45
- ppqs greeting
46
- ppqs greeting
45
+ ppqs greeting friend!
46
+ ppqs greeting comrade!
47
47
  echo Goodbye
48
48
  '''
49
49
  """
@@ -131,7 +131,7 @@ def test_recursion(pyproject_path, capfd):
131
131
  with in_dir(pyproject_path.parent):
132
132
  cli("farewell")
133
133
  captured = capfd.readouterr()
134
- assert captured.out == "Hello\nGoodbye\n"
134
+ assert captured.out == "Hello friend!\nGoodbye\n"
135
135
  assert captured.err == ""
136
136
 
137
137
  with pytest.raises(InvalidScriptError):
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes