ppqs 2.6.0__tar.gz → 2.7.0__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.
- ppqs-2.7.0/.github/workflows/publish.yml +73 -0
- ppqs-2.7.0/.github/workflows/test.yml +79 -0
- ppqs-2.7.0/.gitignore +5 -0
- ppqs-2.7.0/.pre-commit-config.yaml +33 -0
- ppqs-2.7.0/LICENSES/MIT.txt +18 -0
- {ppqs-2.6.0/src/ppqs.egg-info → ppqs-2.7.0}/PKG-INFO +10 -7
- {ppqs-2.6.0 → ppqs-2.7.0}/README.md +8 -5
- ppqs-2.7.0/REUSE.toml +20 -0
- {ppqs-2.6.0 → ppqs-2.7.0}/pyproject.toml +24 -6
- ppqs-2.7.0/requirements-dev.txt +8 -0
- {ppqs-2.6.0 → ppqs-2.7.0/src/ppqs.egg-info}/PKG-INFO +10 -7
- {ppqs-2.6.0 → ppqs-2.7.0}/src/ppqs.egg-info/SOURCES.txt +10 -0
- ppqs-2.7.0/src/ppqs.egg-info/scm_file_list.json +20 -0
- ppqs-2.7.0/src/ppqs.egg-info/scm_version.json +8 -0
- {ppqs-2.6.0 → ppqs-2.7.0}/src/py_proj_quick_scripts/__init__.py +68 -24
- ppqs-2.7.0/test/__init__.py +27 -0
- {ppqs-2.6.0 → ppqs-2.7.0}/test/test_cli.py +24 -3
- /ppqs-2.6.0/LICENSES/MIT.txt → /ppqs-2.7.0/LICENSE +0 -0
- {ppqs-2.6.0 → ppqs-2.7.0}/LICENSES/CC0-1.0.txt +0 -0
- {ppqs-2.6.0 → ppqs-2.7.0}/setup.cfg +0 -0
- {ppqs-2.6.0 → ppqs-2.7.0}/src/ppqs.egg-info/dependency_links.txt +0 -0
- {ppqs-2.6.0 → ppqs-2.7.0}/src/ppqs.egg-info/entry_points.txt +0 -0
- {ppqs-2.6.0 → ppqs-2.7.0}/src/ppqs.egg-info/requires.txt +0 -0
- {ppqs-2.6.0 → ppqs-2.7.0}/src/ppqs.egg-info/top_level.txt +0 -0
- {ppqs-2.6.0 → ppqs-2.7.0}/test/test_find_pyproject.py +0 -0
- {ppqs-2.6.0 → ppqs-2.7.0}/test/test_parse_scripts.py +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
name: Publish package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
workflow_dispatch: null
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
publish:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
environment: ${{ github.event_name == 'workflow_dispatch' && 'testpypi' || 'pypi' }}
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write
|
|
17
|
+
attestations: write
|
|
18
|
+
contents: read
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout source code
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
with:
|
|
24
|
+
fetch-depth: 0
|
|
25
|
+
|
|
26
|
+
- name: Set up Python
|
|
27
|
+
uses: actions/setup-python@v5
|
|
28
|
+
with:
|
|
29
|
+
python-version: '3.11'
|
|
30
|
+
|
|
31
|
+
- name: Initialise project
|
|
32
|
+
uses: nick-fields/retry@v2
|
|
33
|
+
with:
|
|
34
|
+
timeout_minutes: 5
|
|
35
|
+
max_attempts: 3
|
|
36
|
+
retry_wait_seconds: 30
|
|
37
|
+
command: |
|
|
38
|
+
python -m pip install --upgrade pip
|
|
39
|
+
python -m pip install .
|
|
40
|
+
ppqs init
|
|
41
|
+
ppqs version
|
|
42
|
+
|
|
43
|
+
- name: Perform linting checks
|
|
44
|
+
run: |
|
|
45
|
+
ppqs lint
|
|
46
|
+
|
|
47
|
+
- name: Build project
|
|
48
|
+
run: |
|
|
49
|
+
ppqs build
|
|
50
|
+
|
|
51
|
+
- name: Run tests
|
|
52
|
+
run: |
|
|
53
|
+
ppqs test --no-cov
|
|
54
|
+
|
|
55
|
+
- name: Validate metadata
|
|
56
|
+
run: |
|
|
57
|
+
twine check dist/*
|
|
58
|
+
|
|
59
|
+
- name: Attest build
|
|
60
|
+
uses: actions/attest-build-provenance@v2
|
|
61
|
+
with:
|
|
62
|
+
subject-path: "dist/*"
|
|
63
|
+
|
|
64
|
+
- name: Publish to PyPI
|
|
65
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
66
|
+
if: ${{ github.event_name == 'push' }}
|
|
67
|
+
|
|
68
|
+
- name: Publish to TestPyPI
|
|
69
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
70
|
+
if: ${{ github.event_name == 'workflow_dispatch' }}
|
|
71
|
+
with:
|
|
72
|
+
repository-url: https://test.pypi.org/legacy/
|
|
73
|
+
skip-existing: true
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
name: Test package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- "*"
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- "*"
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
python-version:
|
|
19
|
+
- "3.11"
|
|
20
|
+
- "3.12"
|
|
21
|
+
- "3.13"
|
|
22
|
+
- "3.14"
|
|
23
|
+
- "3.15"
|
|
24
|
+
|
|
25
|
+
steps:
|
|
26
|
+
- name: Checkout
|
|
27
|
+
uses: actions/checkout@v4
|
|
28
|
+
with:
|
|
29
|
+
fetch-depth: 0
|
|
30
|
+
|
|
31
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
32
|
+
uses: actions/setup-python@v5
|
|
33
|
+
with:
|
|
34
|
+
python-version: ${{ matrix.python-version }}
|
|
35
|
+
|
|
36
|
+
- name: Initialise project
|
|
37
|
+
uses: nick-fields/retry@v2
|
|
38
|
+
with:
|
|
39
|
+
timeout_minutes: 5
|
|
40
|
+
max_attempts: 3
|
|
41
|
+
retry_wait_seconds: 30
|
|
42
|
+
command: |
|
|
43
|
+
python -m pip install --upgrade pip
|
|
44
|
+
python -m pip install .
|
|
45
|
+
ppqs init
|
|
46
|
+
python -m venv $RUNNER_TEMP/venv
|
|
47
|
+
source $RUNNER_TEMP/venv/bin/activate
|
|
48
|
+
python -m pip install --upgrade pip
|
|
49
|
+
python -m pip install .
|
|
50
|
+
ppqs init
|
|
51
|
+
ppqs version
|
|
52
|
+
|
|
53
|
+
- name: Perform linting checks
|
|
54
|
+
run: |
|
|
55
|
+
ppqs lint
|
|
56
|
+
|
|
57
|
+
- name: Build project
|
|
58
|
+
run: |
|
|
59
|
+
ppqs build
|
|
60
|
+
|
|
61
|
+
- name: Run tests
|
|
62
|
+
run: |
|
|
63
|
+
ppqs test --no-cov
|
|
64
|
+
source $RUNNER_TEMP/venv/bin/activate
|
|
65
|
+
ppqs test
|
|
66
|
+
|
|
67
|
+
- name: Clean up build files
|
|
68
|
+
run: |
|
|
69
|
+
ppqs clean
|
|
70
|
+
|
|
71
|
+
all-done:
|
|
72
|
+
runs-on: ubuntu-latest
|
|
73
|
+
|
|
74
|
+
needs: test
|
|
75
|
+
|
|
76
|
+
steps:
|
|
77
|
+
- name: All done
|
|
78
|
+
run: |
|
|
79
|
+
echo All done
|
ppqs-2.7.0/.gitignore
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
default_install_hook_types: [pre-commit, post-commit]
|
|
2
|
+
|
|
3
|
+
repos:
|
|
4
|
+
|
|
5
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
6
|
+
rev: v6.0.0
|
|
7
|
+
hooks:
|
|
8
|
+
- id: mixed-line-ending
|
|
9
|
+
args: [--fix=lf]
|
|
10
|
+
- id: trailing-whitespace
|
|
11
|
+
- id: end-of-file-fixer
|
|
12
|
+
- id: check-added-large-files
|
|
13
|
+
- id: check-toml
|
|
14
|
+
- id: check-yaml
|
|
15
|
+
- id: file-contents-sorter
|
|
16
|
+
args: [--unique]
|
|
17
|
+
files: ^\.gitattributes$|^\.gitignore$|^requirements-dev\.txt$
|
|
18
|
+
|
|
19
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
20
|
+
rev: v0.15.8
|
|
21
|
+
hooks:
|
|
22
|
+
- id: ruff-check
|
|
23
|
+
|
|
24
|
+
- repo: https://github.com/assorted-pre-commit-hooks/copyright
|
|
25
|
+
rev: v0.11
|
|
26
|
+
hooks:
|
|
27
|
+
- id: copyright
|
|
28
|
+
|
|
29
|
+
- repo: https://github.com/psf/black
|
|
30
|
+
rev: 26.3.1
|
|
31
|
+
hooks:
|
|
32
|
+
- id: black
|
|
33
|
+
args: [--target-version=py311]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Karl Wette
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
9
|
+
following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
+
portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
15
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
16
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
18
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ppqs
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.7.0
|
|
4
4
|
Summary: Python project quick scripts
|
|
5
5
|
Author-email: Karl Wette <karl.wette@anu.edu.au>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -8,7 +8,7 @@ Project-URL: Homepage, https://github.com/kwwette/ppqs
|
|
|
8
8
|
Project-URL: Issues, https://github.com/kwwette/ppqs/issues
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSES/MIT.txt
|
|
14
14
|
License-File: LICENSES/CC0-1.0.txt
|
|
@@ -86,19 +86,22 @@ clean = [
|
|
|
86
86
|
]
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
If a script contains
|
|
90
|
-
|
|
89
|
+
If a script argument contains a number inside curly brackets (`{1}`, `{2}`,
|
|
90
|
+
etc.) it is replaced with the corresponding argument passed to `ppqs`. If a
|
|
91
|
+
script contains an ellipsis (`...`) it is replaced with any remaining arguments
|
|
92
|
+
(i.e. not used by a curly-bracket replacement). For example, the following
|
|
93
|
+
script:
|
|
91
94
|
|
|
92
95
|
```toml
|
|
93
96
|
[tool.ppqs.scripts]
|
|
94
|
-
print-something = "echo ..."
|
|
97
|
+
print-something = "echo {1}, and ..."
|
|
95
98
|
```
|
|
96
99
|
|
|
97
100
|
may be run as
|
|
98
101
|
|
|
99
102
|
```
|
|
100
|
-
$ ppqs print-something
|
|
101
|
-
|
|
103
|
+
$ ppqs print-something Hello goodbye again
|
|
104
|
+
Hello, and goodbye again
|
|
102
105
|
```
|
|
103
106
|
|
|
104
107
|
`ppqs` can recursively run its own scripts, however it will only run any script
|
|
@@ -69,19 +69,22 @@ clean = [
|
|
|
69
69
|
]
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
If a script contains
|
|
73
|
-
|
|
72
|
+
If a script argument contains a number inside curly brackets (`{1}`, `{2}`,
|
|
73
|
+
etc.) it is replaced with the corresponding argument passed to `ppqs`. If a
|
|
74
|
+
script contains an ellipsis (`...`) it is replaced with any remaining arguments
|
|
75
|
+
(i.e. not used by a curly-bracket replacement). For example, the following
|
|
76
|
+
script:
|
|
74
77
|
|
|
75
78
|
```toml
|
|
76
79
|
[tool.ppqs.scripts]
|
|
77
|
-
print-something = "echo ..."
|
|
80
|
+
print-something = "echo {1}, and ..."
|
|
78
81
|
```
|
|
79
82
|
|
|
80
83
|
may be run as
|
|
81
84
|
|
|
82
85
|
```
|
|
83
|
-
$ ppqs print-something
|
|
84
|
-
|
|
86
|
+
$ ppqs print-something Hello goodbye again
|
|
87
|
+
Hello, and goodbye again
|
|
85
88
|
```
|
|
86
89
|
|
|
87
90
|
`ppqs` can recursively run its own scripts, however it will only run any script
|
ppqs-2.7.0/REUSE.toml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
version = 1
|
|
2
|
+
|
|
3
|
+
[[annotations]]
|
|
4
|
+
path = [
|
|
5
|
+
".github/**",
|
|
6
|
+
".gitignore",
|
|
7
|
+
".pre-commit-config.yaml",
|
|
8
|
+
"README.md",
|
|
9
|
+
"pyproject.toml",
|
|
10
|
+
"requirements-dev.txt",
|
|
11
|
+
]
|
|
12
|
+
SPDX-FileCopyrightText = "NONE"
|
|
13
|
+
SPDX-License-Identifier = "CC0-1.0"
|
|
14
|
+
|
|
15
|
+
[[annotations]]
|
|
16
|
+
path = [
|
|
17
|
+
"src/**/*.py",
|
|
18
|
+
"test/**/*.py",
|
|
19
|
+
]
|
|
20
|
+
SPDX-License-Identifier = "MIT"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["setuptools>=
|
|
2
|
+
requires = ["setuptools>=80", "setuptools-scm>=8"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
@@ -8,7 +8,7 @@ description = "Python project quick scripts"
|
|
|
8
8
|
authors = [
|
|
9
9
|
{ name = "Karl Wette", email = "karl.wette@anu.edu.au" },
|
|
10
10
|
]
|
|
11
|
-
requires-python = ">=3.
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
12
|
dependencies = [
|
|
13
13
|
"tomli>=1.1.0; python_version<'3.11'"
|
|
14
14
|
]
|
|
@@ -28,8 +28,9 @@ Issues = "https://github.com/kwwette/ppqs/issues"
|
|
|
28
28
|
[project.scripts]
|
|
29
29
|
ppqs = "py_proj_quick_scripts:cli"
|
|
30
30
|
|
|
31
|
-
[tool.
|
|
32
|
-
|
|
31
|
+
[tool.setuptools_scm]
|
|
32
|
+
scm.git.pre_parse = "fail_on_shallow"
|
|
33
|
+
local_scheme = "node-and-timestamp"
|
|
33
34
|
|
|
34
35
|
[tool.ruff]
|
|
35
36
|
fix = true
|
|
@@ -52,6 +53,7 @@ convention = "google"
|
|
|
52
53
|
|
|
53
54
|
[tool.pytest.ini_options]
|
|
54
55
|
minversion = "6.0"
|
|
56
|
+
pythonpath = ["src"]
|
|
55
57
|
addopts = "--cov=py_proj_quick_scripts --cov-report=term-missing --cov-fail-under=100"
|
|
56
58
|
testpaths = ["test"]
|
|
57
59
|
|
|
@@ -85,12 +87,28 @@ script = """
|
|
|
85
87
|
python -m pytest ...
|
|
86
88
|
"""
|
|
87
89
|
|
|
90
|
+
[tool.ppqs.scripts.version]
|
|
91
|
+
description = "Print the current package version"
|
|
92
|
+
script = "python -m setuptools_scm"
|
|
93
|
+
|
|
94
|
+
[tool.ppqs.scripts.tag]
|
|
95
|
+
description = "Tag a release"
|
|
96
|
+
script = [
|
|
97
|
+
["git", "status"],
|
|
98
|
+
["git", "diff", "--quiet", "--exit-code"],
|
|
99
|
+
["ppqs", "lint"],
|
|
100
|
+
["ppqs", "build"],
|
|
101
|
+
["ppqs", "test"],
|
|
102
|
+
["git", "commit", "--allow-empty", "-m", "Version {1}"],
|
|
103
|
+
["git", "tag", "-a", "-m", "Version {1}", "v{1}"],
|
|
104
|
+
]
|
|
105
|
+
|
|
88
106
|
[tool.ppqs.scripts.upload]
|
|
89
107
|
description = "Upload package"
|
|
90
108
|
script = [
|
|
91
|
-
["ppqs", "
|
|
109
|
+
["ppqs", "lint"],
|
|
92
110
|
["ppqs", "build"],
|
|
93
|
-
["
|
|
111
|
+
["ppqs", "test"],
|
|
94
112
|
["git", "push", "origin"],
|
|
95
113
|
["git", "push", "origin", "--tags"],
|
|
96
114
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ppqs
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.7.0
|
|
4
4
|
Summary: Python project quick scripts
|
|
5
5
|
Author-email: Karl Wette <karl.wette@anu.edu.au>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -8,7 +8,7 @@ Project-URL: Homepage, https://github.com/kwwette/ppqs
|
|
|
8
8
|
Project-URL: Issues, https://github.com/kwwette/ppqs/issues
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSES/MIT.txt
|
|
14
14
|
License-File: LICENSES/CC0-1.0.txt
|
|
@@ -86,19 +86,22 @@ clean = [
|
|
|
86
86
|
]
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
If a script contains
|
|
90
|
-
|
|
89
|
+
If a script argument contains a number inside curly brackets (`{1}`, `{2}`,
|
|
90
|
+
etc.) it is replaced with the corresponding argument passed to `ppqs`. If a
|
|
91
|
+
script contains an ellipsis (`...`) it is replaced with any remaining arguments
|
|
92
|
+
(i.e. not used by a curly-bracket replacement). For example, the following
|
|
93
|
+
script:
|
|
91
94
|
|
|
92
95
|
```toml
|
|
93
96
|
[tool.ppqs.scripts]
|
|
94
|
-
print-something = "echo ..."
|
|
97
|
+
print-something = "echo {1}, and ..."
|
|
95
98
|
```
|
|
96
99
|
|
|
97
100
|
may be run as
|
|
98
101
|
|
|
99
102
|
```
|
|
100
|
-
$ ppqs print-something
|
|
101
|
-
|
|
103
|
+
$ ppqs print-something Hello goodbye again
|
|
104
|
+
Hello, and goodbye again
|
|
102
105
|
```
|
|
103
106
|
|
|
104
107
|
`ppqs` can recursively run its own scripts, however it will only run any script
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
.gitignore
|
|
2
|
+
.pre-commit-config.yaml
|
|
3
|
+
LICENSE
|
|
1
4
|
README.md
|
|
5
|
+
REUSE.toml
|
|
2
6
|
pyproject.toml
|
|
7
|
+
requirements-dev.txt
|
|
8
|
+
.github/workflows/publish.yml
|
|
9
|
+
.github/workflows/test.yml
|
|
3
10
|
LICENSES/CC0-1.0.txt
|
|
4
11
|
LICENSES/MIT.txt
|
|
5
12
|
src/ppqs.egg-info/PKG-INFO
|
|
@@ -7,8 +14,11 @@ src/ppqs.egg-info/SOURCES.txt
|
|
|
7
14
|
src/ppqs.egg-info/dependency_links.txt
|
|
8
15
|
src/ppqs.egg-info/entry_points.txt
|
|
9
16
|
src/ppqs.egg-info/requires.txt
|
|
17
|
+
src/ppqs.egg-info/scm_file_list.json
|
|
18
|
+
src/ppqs.egg-info/scm_version.json
|
|
10
19
|
src/ppqs.egg-info/top_level.txt
|
|
11
20
|
src/py_proj_quick_scripts/__init__.py
|
|
21
|
+
test/__init__.py
|
|
12
22
|
test/test_cli.py
|
|
13
23
|
test/test_find_pyproject.py
|
|
14
24
|
test/test_parse_scripts.py
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
".github/workflows/publish.yml",
|
|
4
|
+
".github/workflows/test.yml",
|
|
5
|
+
".gitignore",
|
|
6
|
+
".pre-commit-config.yaml",
|
|
7
|
+
"LICENSE",
|
|
8
|
+
"LICENSES/CC0-1.0.txt",
|
|
9
|
+
"LICENSES/MIT.txt",
|
|
10
|
+
"README.md",
|
|
11
|
+
"REUSE.toml",
|
|
12
|
+
"pyproject.toml",
|
|
13
|
+
"requirements-dev.txt",
|
|
14
|
+
"src/py_proj_quick_scripts/__init__.py",
|
|
15
|
+
"test/__init__.py",
|
|
16
|
+
"test/test_cli.py",
|
|
17
|
+
"test/test_find_pyproject.py",
|
|
18
|
+
"test/test_parse_scripts.py"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -11,15 +11,16 @@ import shutil
|
|
|
11
11
|
import subprocess
|
|
12
12
|
import sys
|
|
13
13
|
import textwrap
|
|
14
|
+
import tomllib
|
|
15
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
14
16
|
from pathlib import Path
|
|
15
17
|
|
|
16
|
-
if sys.version_info >= (3, 11): # pragma: no cover
|
|
17
|
-
import tomllib
|
|
18
|
-
else: # pragma: no cover
|
|
19
|
-
import tomli as tomllib
|
|
20
|
-
|
|
21
18
|
__author__ = "Karl Wette"
|
|
22
|
-
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
__version__ = version("ppqs")
|
|
22
|
+
except PackageNotFoundError: # pragma: no cover
|
|
23
|
+
__version__ = "0.0.0.dev0"
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
class MissingPyProjectError(Exception):
|
|
@@ -241,35 +242,78 @@ def run_script(pyproject_path, scripts, script_name, argv, cwd, has_been_run):
|
|
|
241
242
|
# Get script
|
|
242
243
|
script = scripts[script_name]
|
|
243
244
|
|
|
244
|
-
#
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
)
|
|
250
|
-
raise InvalidScriptCallError(pyproject_path, msg)
|
|
251
|
-
|
|
252
|
-
for command in script["commands"]:
|
|
245
|
+
# First pass of commands
|
|
246
|
+
argv_remaining = argv.copy()
|
|
247
|
+
commands = script["commands"]
|
|
248
|
+
cmds = []
|
|
249
|
+
for command in commands:
|
|
253
250
|
cmd = []
|
|
254
|
-
|
|
255
251
|
for arg in command:
|
|
252
|
+
|
|
253
|
+
# Handle path arguments
|
|
256
254
|
if isinstance(arg, Path):
|
|
257
|
-
if "*" in arg.parts[-1]:
|
|
258
255
|
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
# Expand wildcards in last path element
|
|
257
|
+
if "*" in arg.parts[-1]:
|
|
258
|
+
cmd.extend(
|
|
259
|
+
sorted(glob.glob(str(arg), root_dir=cwd, recursive=False))
|
|
260
|
+
)
|
|
261
261
|
|
|
262
262
|
else:
|
|
263
263
|
cmd.append(str(arg))
|
|
264
264
|
|
|
265
|
-
|
|
265
|
+
continue
|
|
266
|
+
|
|
267
|
+
# Replace positional arguments from command
|
|
268
|
+
for arg_match in re.finditer(r"{(\d+)}", arg):
|
|
269
|
+
arg_i = int(arg_match.group(1))
|
|
270
|
+
if arg_i < 1:
|
|
271
|
+
msg = (
|
|
272
|
+
"script '{}' arguments must be {{1}}, {{2}}, etc.,"
|
|
273
|
+
+ " instead found {{{}}}"
|
|
274
|
+
).format(script_name, arg_i)
|
|
275
|
+
raise InvalidScriptCallError(pyproject_path, msg)
|
|
276
|
+
if arg_i > len(argv):
|
|
277
|
+
msg = (
|
|
278
|
+
"script '{}' takes at least {} argument(s), "
|
|
279
|
+
+ "but only {} argument(s) were given"
|
|
280
|
+
).format(script_name, arg_i, len(argv))
|
|
281
|
+
raise InvalidScriptCallError(pyproject_path, msg)
|
|
282
|
+
arg = arg.replace(arg_match.group(0), argv[arg_i - 1])
|
|
283
|
+
argv_remaining[arg_i - 1] = None
|
|
284
|
+
|
|
285
|
+
cmd.append(arg)
|
|
286
|
+
|
|
287
|
+
cmds.append(cmd)
|
|
288
|
+
|
|
289
|
+
# Second pass of command
|
|
290
|
+
commands = cmds
|
|
291
|
+
cmds = []
|
|
292
|
+
for command in commands:
|
|
293
|
+
cmd = []
|
|
294
|
+
for arg in command:
|
|
295
|
+
|
|
296
|
+
# Replace "..." with remaining command-line arguments
|
|
297
|
+
if arg == "...":
|
|
298
|
+
cmd.extend([argr for argr in argv_remaining if argr is not None])
|
|
299
|
+
argv_remaining = [None] * len(argv_remaining)
|
|
266
300
|
|
|
267
|
-
|
|
268
|
-
cmd.extend(argv)
|
|
301
|
+
continue
|
|
269
302
|
|
|
270
|
-
|
|
271
|
-
|
|
303
|
+
cmd.append(arg)
|
|
304
|
+
|
|
305
|
+
cmds.append(cmd)
|
|
306
|
+
|
|
307
|
+
# Check for any remaining arguments
|
|
308
|
+
argv_used = sum(argr is None for argr in argv_remaining)
|
|
309
|
+
if argv_used != len(argv):
|
|
310
|
+
msg = "script '{}' takes {} argument(s), but {} argument(s) were given".format(
|
|
311
|
+
script_name, argv_used, len(argv)
|
|
312
|
+
)
|
|
313
|
+
raise InvalidScriptCallError(pyproject_path, msg)
|
|
272
314
|
|
|
315
|
+
# Execute commands
|
|
316
|
+
for cmd in cmds:
|
|
273
317
|
if cmd[0] == "ppqs":
|
|
274
318
|
|
|
275
319
|
# Recursively run script
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2025 Karl Wette
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
"""Utility functions for tests."""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import textwrap
|
|
9
|
+
from contextlib import contextmanager
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def write_file(path, contents):
|
|
14
|
+
"""Write `contents` to a text file `path`."""
|
|
15
|
+
path.write_text(textwrap.dedent(contents).strip())
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@contextmanager
|
|
19
|
+
def in_dir(path):
|
|
20
|
+
"""Temporarily change working directory to `path`, creating as needed."""
|
|
21
|
+
path.mkdir(parents=True, exist_ok=True)
|
|
22
|
+
cwd = Path.cwd()
|
|
23
|
+
os.chdir(path)
|
|
24
|
+
try:
|
|
25
|
+
yield path
|
|
26
|
+
finally:
|
|
27
|
+
os.chdir(cwd)
|
|
@@ -39,11 +39,13 @@ 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 {1}!"
|
|
43
|
+
[tool.ppqs.scripts.zero-greeting]
|
|
44
|
+
script = "echo Hello {0}!"
|
|
43
45
|
[tool.ppqs.scripts.farewell]
|
|
44
46
|
script = '''
|
|
45
|
-
ppqs greeting friend
|
|
46
|
-
ppqs greeting comrade
|
|
47
|
+
ppqs greeting friend
|
|
48
|
+
ppqs greeting comrade
|
|
47
49
|
echo Goodbye
|
|
48
50
|
'''
|
|
49
51
|
"""
|
|
@@ -111,6 +113,25 @@ def test_echo_wildcard(pyproject_path, capfd):
|
|
|
111
113
|
assert captured.err == ""
|
|
112
114
|
|
|
113
115
|
|
|
116
|
+
def test_args(pyproject_path, capfd):
|
|
117
|
+
"""Test argument parsing."""
|
|
118
|
+
|
|
119
|
+
with in_dir(pyproject_path.parent):
|
|
120
|
+
cli("greeting", "friend")
|
|
121
|
+
captured = capfd.readouterr()
|
|
122
|
+
assert captured.out == "Hello friend!\n"
|
|
123
|
+
assert captured.err == ""
|
|
124
|
+
|
|
125
|
+
with pytest.raises(InvalidScriptError):
|
|
126
|
+
cli("greeting")
|
|
127
|
+
|
|
128
|
+
with pytest.raises(InvalidScriptError):
|
|
129
|
+
cli("greeting", "magnificent", "friend")
|
|
130
|
+
|
|
131
|
+
with pytest.raises(InvalidScriptError):
|
|
132
|
+
cli("zero-greeting", "nothing")
|
|
133
|
+
|
|
134
|
+
|
|
114
135
|
def test_recursion(pyproject_path, capfd):
|
|
115
136
|
"""Test recursive script running."""
|
|
116
137
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|