dev-shell 0.7.0__tar.gz → 0.9.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.
- dev_shell-0.9.0/.editorconfig +20 -0
- dev_shell-0.9.0/.flake8 +7 -0
- dev_shell-0.9.0/.github/workflows/tests.yml +57 -0
- dev_shell-0.9.0/.gitignore +13 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/PKG-INFO +26 -25
- {dev_shell-0.7.0 → dev_shell-0.9.0}/README.md +15 -9
- dev_shell-0.9.0/dev_shell/__init__.py +8 -0
- dev_shell-0.9.0/dev_shell/__main__.py +10 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/bootstrap-source.py +39 -34
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/command_sets/dev_shell_commands.py +44 -41
- dev_shell-0.9.0/dev_shell/constants.py +21 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/dev_shell_app.py +1 -1
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/tests/fixtures.py +0 -1
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/tests/test_bootstrap.py +18 -38
- dev_shell-0.9.0/dev_shell/tests/test_dev_shell_app.py +73 -0
- dev_shell-0.9.0/dev_shell/tests/test_doctests.py +10 -0
- dev_shell-0.9.0/dev_shell/tests/test_project_setup.py +18 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/tests/test_source_file.py +5 -5
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/tests/utils.py +1 -1
- dev_shell-0.9.0/dev_shell.egg-info/PKG-INFO +175 -0
- dev_shell-0.9.0/dev_shell.egg-info/SOURCES.txt +37 -0
- dev_shell-0.9.0/dev_shell.egg-info/dependency_links.txt +1 -0
- dev_shell-0.9.0/dev_shell.egg-info/entry_points.txt +2 -0
- dev_shell-0.9.0/dev_shell.egg-info/requires.txt +2 -0
- dev_shell-0.9.0/dev_shell.egg-info/top_level.txt +1 -0
- dev_shell-0.9.0/devshell.py +154 -0
- dev_shell-0.9.0/noxfile.py +25 -0
- dev_shell-0.9.0/pyproject.toml +140 -0
- dev_shell-0.9.0/setup.cfg +4 -0
- dev_shell-0.9.0/uv.lock +1601 -0
- dev_shell-0.7.0/dev_shell/__init__.py +0 -1
- dev_shell-0.7.0/dev_shell/constants.py +0 -21
- dev_shell-0.7.0/dev_shell/tests/constants.py +0 -17
- dev_shell-0.7.0/dev_shell/tests/test_dev_shell_app.py +0 -128
- dev_shell-0.7.0/dev_shell/tests/test_subprocess_utils.py +0 -195
- dev_shell-0.7.0/pyproject.toml +0 -110
- {dev_shell-0.7.0 → dev_shell-0.9.0}/LICENSE +0 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/base_cmd2_app.py +0 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/command_sets/__init__.py +0 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/config.py +0 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/tests/__init__.py +0 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/utils/__init__.py +0 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/utils/assertion.py +0 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/utils/colorful.py +0 -0
- {dev_shell-0.7.0 → dev_shell-0.9.0}/dev_shell/utils/subprocess_utils.py +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# see https://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
indent_style = space
|
|
6
|
+
indent_size = 4
|
|
7
|
+
end_of_line = lf
|
|
8
|
+
charset = utf-8
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
insert_final_newline = true
|
|
11
|
+
|
|
12
|
+
[*.py]
|
|
13
|
+
max_line_length = 119
|
|
14
|
+
|
|
15
|
+
[{Makefile,**.mk}]
|
|
16
|
+
indent_style = tab
|
|
17
|
+
insert_final_newline = false
|
|
18
|
+
|
|
19
|
+
[{*.yaml,*.yml}]
|
|
20
|
+
indent_size = 2
|
dev_shell-0.9.0/.flake8
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
name: tests
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
pull_request:
|
|
9
|
+
schedule:
|
|
10
|
+
- cron: '0 8 * * *'
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
python-version: ["3.13", "3.12", "3.11"]
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout
|
|
21
|
+
run: |
|
|
22
|
+
echo $GITHUB_REF $GITHUB_SHA
|
|
23
|
+
git clone https://github.com/$GITHUB_REPOSITORY.git .
|
|
24
|
+
git fetch origin $GITHUB_SHA:temporary-ci-branch
|
|
25
|
+
git checkout $GITHUB_SHA || (git fetch && git checkout $GITHUB_SHA)
|
|
26
|
+
|
|
27
|
+
- name: 'Set up Python ${{ matrix.python-version }}'
|
|
28
|
+
uses: actions/setup-python@v5
|
|
29
|
+
# https://github.com/marketplace/actions/setup-python
|
|
30
|
+
with:
|
|
31
|
+
python-version: '${{ matrix.python-version }}'
|
|
32
|
+
cache: 'pip' # caching pip dependencies
|
|
33
|
+
cache-dependency-path: '**/requirements.*.txt'
|
|
34
|
+
|
|
35
|
+
- name: 'Bootstrap app venv'
|
|
36
|
+
# The first CLI call will create the .venv
|
|
37
|
+
run: |
|
|
38
|
+
./devshell.py version
|
|
39
|
+
|
|
40
|
+
- name: 'app CLI help'
|
|
41
|
+
run: |
|
|
42
|
+
./devshell.py --help
|
|
43
|
+
|
|
44
|
+
- name: 'Run tests with Python v${{ matrix.python-version }}'
|
|
45
|
+
env:
|
|
46
|
+
PYTHONUNBUFFERED: 1
|
|
47
|
+
PYTHONWARNINGS: always
|
|
48
|
+
run: |
|
|
49
|
+
./devshell.py coverage
|
|
50
|
+
|
|
51
|
+
- name: 'Upload coverage report'
|
|
52
|
+
uses: codecov/codecov-action@v4
|
|
53
|
+
# https://github.com/marketplace/actions/codecov
|
|
54
|
+
with:
|
|
55
|
+
fail_ci_if_error: false
|
|
56
|
+
verbose: true
|
|
57
|
+
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: dev-shell
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary:
|
|
5
|
-
|
|
6
|
-
License:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Requires-Python: >=3.
|
|
10
|
-
Classifier: License :: Other/Proprietary License
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
-
Requires-Dist: cmd2
|
|
16
|
-
Requires-Dist: gnureadline ; sys_platform == "darwin"
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Developer shell for easy startup...
|
|
5
|
+
Author-email: Jens Diemer <dev-shell@jensdiemer.de>
|
|
6
|
+
License: GPL-3.0-or-later
|
|
7
|
+
Project-URL: Documentation, https://github.com/jedie/dev-shell
|
|
8
|
+
Project-URL: Source, https://github.com/jedie/dev-shell
|
|
9
|
+
Requires-Python: >=3.11
|
|
17
10
|
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: cmd2
|
|
13
|
+
Requires-Dist: cli-base-utilities
|
|
18
14
|
|
|
19
15
|
# A "dev-shell" for Python projects ;)
|
|
20
16
|
|
|
21
|
-
[](https://github.com/jedie/dev-shell/actions/workflows/tests.yml)
|
|
18
|
+
[](https://app.codecov.io/github/jedie/dev_shell)
|
|
19
|
+
[](https://pypi.org/project/dev_shell/)
|
|
20
|
+
[](https://github.com/jedie/dev-shell/blob/main/pyproject.toml)
|
|
21
|
+
[](https://github.com/jedie/dev-shell/blob/main/LICENSE)
|
|
23
22
|
|
|
24
|
-
[
|
|
25
|
-

|
|
26
|
-
](https://pypi.org/project/dev-shell/)
|
|
27
23
|
|
|
28
24
|
This small project is intended to improve the start-up for collaborators.
|
|
29
25
|
|
|
@@ -38,7 +34,7 @@ The "dev-shell" is the base to create a CLI and a shell. It also shows how to ma
|
|
|
38
34
|
```bash
|
|
39
35
|
~$ git clone https://github.com/jedie/dev-shell.git
|
|
40
36
|
~$ cd dev-shell
|
|
41
|
-
~/dev-shell$ ./devshell.py
|
|
37
|
+
~/dev-shell$ ./devshell.py test
|
|
42
38
|
```
|
|
43
39
|
|
|
44
40
|
|
|
@@ -79,7 +75,7 @@ Documented commands (use 'help -v' for verbose/'help <topic>' for details):
|
|
|
79
75
|
|
|
80
76
|
dev-shell commands
|
|
81
77
|
==================
|
|
82
|
-
fix_code_style linting list_venv_packages publish
|
|
78
|
+
fix_code_style linting list_venv_packages publish test update
|
|
83
79
|
|
|
84
80
|
...
|
|
85
81
|
|
|
@@ -97,7 +93,7 @@ Developer shell - dev_shell - v0.2.0
|
|
|
97
93
|
(dev_shell) help
|
|
98
94
|
```
|
|
99
95
|
|
|
100
|
-
Info: The `.venv` will be automatically updated via `poetry install` call if the `
|
|
96
|
+
Info: The `.venv` will be automatically updated via `poetry install` call if the `uv.lock` file has been changed.
|
|
101
97
|
|
|
102
98
|
A call with `--update` will force to call some create/update steps, e.g.:
|
|
103
99
|
|
|
@@ -122,8 +118,14 @@ See also github test configuration: [.github/workflows/test.yml](https://github.
|
|
|
122
118
|
|
|
123
119
|
## History
|
|
124
120
|
|
|
125
|
-
* [*dev*](https://github.com/jedie/dev-shell/compare/v0.
|
|
121
|
+
* [*dev*](https://github.com/jedie/dev-shell/compare/v0.8.0...main)
|
|
126
122
|
* TBC
|
|
123
|
+
* [0.9.0 - 2025-03-11](https://github.com/jedie/dev-shell/compare/v0.8.0...v0.9.0)
|
|
124
|
+
* Replace `poetry` with `uv`
|
|
125
|
+
* [0.8.0 - 2024-04-09](https://github.com/jedie/dev-shell/compare/v0.7.0...v0.8.0)
|
|
126
|
+
* Remove "gnureadline" as dependency
|
|
127
|
+
* update boot script
|
|
128
|
+
* update requirements
|
|
127
129
|
* [0.7.0 - 2023-04-25](https://github.com/jedie/dev-shell/compare/v0.6.1...v0.7.0)
|
|
128
130
|
* Update test matrix
|
|
129
131
|
* update requirements
|
|
@@ -171,4 +173,3 @@ See also github test configuration: [.github/workflows/test.yml](https://github.
|
|
|
171
173
|
|
|
172
174
|
* Github: https://github.com/jedie/dev-shell/
|
|
173
175
|
* PyPi: https://pypi.org/project/dev-shell/
|
|
174
|
-
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# A "dev-shell" for Python projects ;)
|
|
2
2
|
|
|
3
|
-
[](https://github.com/jedie/dev-shell/actions/workflows/tests.yml)
|
|
4
|
+
[](https://app.codecov.io/github/jedie/dev_shell)
|
|
5
|
+
[](https://pypi.org/project/dev_shell/)
|
|
6
|
+
[](https://github.com/jedie/dev-shell/blob/main/pyproject.toml)
|
|
7
|
+
[](https://github.com/jedie/dev-shell/blob/main/LICENSE)
|
|
5
8
|
|
|
6
|
-
[
|
|
7
|
-

|
|
8
|
-
](https://pypi.org/project/dev-shell/)
|
|
9
9
|
|
|
10
10
|
This small project is intended to improve the start-up for collaborators.
|
|
11
11
|
|
|
@@ -20,7 +20,7 @@ The "dev-shell" is the base to create a CLI and a shell. It also shows how to ma
|
|
|
20
20
|
```bash
|
|
21
21
|
~$ git clone https://github.com/jedie/dev-shell.git
|
|
22
22
|
~$ cd dev-shell
|
|
23
|
-
~/dev-shell$ ./devshell.py
|
|
23
|
+
~/dev-shell$ ./devshell.py test
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
|
|
@@ -61,7 +61,7 @@ Documented commands (use 'help -v' for verbose/'help <topic>' for details):
|
|
|
61
61
|
|
|
62
62
|
dev-shell commands
|
|
63
63
|
==================
|
|
64
|
-
fix_code_style linting list_venv_packages publish
|
|
64
|
+
fix_code_style linting list_venv_packages publish test update
|
|
65
65
|
|
|
66
66
|
...
|
|
67
67
|
|
|
@@ -79,7 +79,7 @@ Developer shell - dev_shell - v0.2.0
|
|
|
79
79
|
(dev_shell) help
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
Info: The `.venv` will be automatically updated via `poetry install` call if the `
|
|
82
|
+
Info: The `.venv` will be automatically updated via `poetry install` call if the `uv.lock` file has been changed.
|
|
83
83
|
|
|
84
84
|
A call with `--update` will force to call some create/update steps, e.g.:
|
|
85
85
|
|
|
@@ -104,8 +104,14 @@ See also github test configuration: [.github/workflows/test.yml](https://github.
|
|
|
104
104
|
|
|
105
105
|
## History
|
|
106
106
|
|
|
107
|
-
* [*dev*](https://github.com/jedie/dev-shell/compare/v0.
|
|
107
|
+
* [*dev*](https://github.com/jedie/dev-shell/compare/v0.8.0...main)
|
|
108
108
|
* TBC
|
|
109
|
+
* [0.9.0 - 2025-03-11](https://github.com/jedie/dev-shell/compare/v0.8.0...v0.9.0)
|
|
110
|
+
* Replace `poetry` with `uv`
|
|
111
|
+
* [0.8.0 - 2024-04-09](https://github.com/jedie/dev-shell/compare/v0.7.0...v0.8.0)
|
|
112
|
+
* Remove "gnureadline" as dependency
|
|
113
|
+
* update boot script
|
|
114
|
+
* update requirements
|
|
109
115
|
* [0.7.0 - 2023-04-25](https://github.com/jedie/dev-shell/compare/v0.6.1...v0.7.0)
|
|
110
116
|
* Update test matrix
|
|
111
117
|
* update requirements
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
This file is from: https://pypi.org/project/dev-shell/
|
|
10
10
|
Source: https://github.com/jedie/dev-shell/blob/main/devshell.py
|
|
11
11
|
|
|
12
|
-
:copyleft: 2021-
|
|
12
|
+
:copyleft: 2021-2024 by Jens Diemer
|
|
13
13
|
:license: GNU GPL v3 or above
|
|
14
14
|
"""
|
|
15
|
-
|
|
16
15
|
import argparse
|
|
17
16
|
import hashlib
|
|
17
|
+
import shlex
|
|
18
18
|
import signal
|
|
19
19
|
import subprocess
|
|
20
20
|
import sys
|
|
@@ -22,17 +22,25 @@ import venv
|
|
|
22
22
|
from pathlib import Path
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
def print_no_pip_error():
|
|
26
|
+
print('Error: Pip not available!')
|
|
27
|
+
print('Hint: "apt-get install python3-venv"\n')
|
|
28
|
+
|
|
29
|
+
|
|
25
30
|
try:
|
|
26
|
-
|
|
31
|
+
from ensurepip import version
|
|
27
32
|
except ModuleNotFoundError as err:
|
|
28
33
|
print(err)
|
|
29
34
|
print('-' * 100)
|
|
30
|
-
|
|
31
|
-
print('Hint: "apt-get install python3-venv"\n')
|
|
35
|
+
print_no_pip_error()
|
|
32
36
|
raise
|
|
37
|
+
else:
|
|
38
|
+
if not version():
|
|
39
|
+
print_no_pip_error()
|
|
40
|
+
sys.exit(-1)
|
|
33
41
|
|
|
34
42
|
|
|
35
|
-
assert sys.version_info >= (3,
|
|
43
|
+
assert sys.version_info >= (3, 11), f'Python version {sys.version_info} is too old!'
|
|
36
44
|
|
|
37
45
|
|
|
38
46
|
if sys.platform == 'win32': # wtf
|
|
@@ -40,45 +48,44 @@ if sys.platform == 'win32': # wtf
|
|
|
40
48
|
BIN_NAME = 'Scripts'
|
|
41
49
|
FILE_EXT = '.exe'
|
|
42
50
|
else:
|
|
43
|
-
# Files under Linux/Mac and all other than Windows, e.g.: .../.venv/bin/
|
|
51
|
+
# Files under Linux/Mac and all other than Windows, e.g.: .../.venv/bin/python3
|
|
44
52
|
BIN_NAME = 'bin'
|
|
45
53
|
FILE_EXT = ''
|
|
46
54
|
|
|
47
55
|
BASE_PATH = Path(__file__).parent
|
|
48
56
|
VENV_PATH = BASE_PATH / '.venv'
|
|
49
57
|
BIN_PATH = VENV_PATH / BIN_NAME
|
|
50
|
-
PYTHON_PATH = BIN_PATH / f'
|
|
58
|
+
PYTHON_PATH = BIN_PATH / f'python3{FILE_EXT}'
|
|
51
59
|
PIP_PATH = BIN_PATH / f'pip{FILE_EXT}'
|
|
52
|
-
|
|
60
|
+
UV_PATH = BIN_PATH / f'uv{FILE_EXT}'
|
|
53
61
|
|
|
54
|
-
DEP_LOCK_PATH = BASE_PATH / '
|
|
62
|
+
DEP_LOCK_PATH = BASE_PATH / 'uv.lock'
|
|
55
63
|
DEP_HASH_PATH = VENV_PATH / '.dep_hash'
|
|
56
64
|
|
|
57
|
-
# script file defined in pyproject.toml as [
|
|
65
|
+
# script file defined in pyproject.toml as [console_scripts]
|
|
58
66
|
# (Under Windows: ".exe" not added!)
|
|
59
67
|
PROJECT_SHELL_SCRIPT = BIN_PATH / 'devshell'
|
|
60
68
|
|
|
61
69
|
|
|
62
70
|
def get_dep_hash():
|
|
63
|
-
"""
|
|
71
|
+
"""Get SHA512 hash from lock file content."""
|
|
64
72
|
return hashlib.sha512(DEP_LOCK_PATH.read_bytes()).hexdigest()
|
|
65
73
|
|
|
66
74
|
|
|
67
75
|
def store_dep_hash():
|
|
68
|
-
"""
|
|
76
|
+
"""Generate .venv/.dep_hash"""
|
|
69
77
|
DEP_HASH_PATH.write_text(get_dep_hash())
|
|
70
78
|
|
|
71
79
|
|
|
72
80
|
def venv_up2date():
|
|
73
|
-
"""
|
|
81
|
+
"""Is existing .venv is up-to-date?"""
|
|
74
82
|
if DEP_HASH_PATH.is_file():
|
|
75
83
|
return DEP_HASH_PATH.read_text() == get_dep_hash()
|
|
76
84
|
return False
|
|
77
85
|
|
|
78
86
|
|
|
79
87
|
def verbose_check_call(*popen_args):
|
|
80
|
-
|
|
81
|
-
print(f'\n+ {" ".join(popen_args)}\n')
|
|
88
|
+
print(f'\n+ {shlex.join(str(arg) for arg in popen_args)}\n')
|
|
82
89
|
return subprocess.check_call(popen_args)
|
|
83
90
|
|
|
84
91
|
|
|
@@ -86,7 +93,6 @@ def noop_signal_handler(signal_num, frame):
|
|
|
86
93
|
"""
|
|
87
94
|
Signal handler that does nothing: Used to ignore "Ctrl-C" signals
|
|
88
95
|
"""
|
|
89
|
-
pass
|
|
90
96
|
|
|
91
97
|
|
|
92
98
|
def main(argv):
|
|
@@ -114,33 +120,32 @@ def main(argv):
|
|
|
114
120
|
force_update = False
|
|
115
121
|
extra_args = argv[1:]
|
|
116
122
|
|
|
117
|
-
# Create virtual env in "
|
|
123
|
+
# Create virtual env in ".venv/":
|
|
118
124
|
if not PYTHON_PATH.is_file() or force_update:
|
|
119
|
-
print('Create virtual env here:
|
|
125
|
+
print(f'Create virtual env here: {VENV_PATH.absolute()}')
|
|
120
126
|
builder = venv.EnvBuilder(symlinks=True, upgrade=True, with_pip=True)
|
|
121
127
|
builder.create(env_dir=VENV_PATH)
|
|
122
128
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
verbose_check_call(
|
|
129
|
+
if not PROJECT_SHELL_SCRIPT.is_file() or not venv_up2date() or force_update:
|
|
130
|
+
# Update pip
|
|
131
|
+
verbose_check_call(PYTHON_PATH, '-m', 'pip', 'install', '-U', 'pip')
|
|
132
|
+
|
|
133
|
+
# Install uv
|
|
134
|
+
verbose_check_call(PYTHON_PATH, '-m', 'pip', 'install', '-U', 'uv')
|
|
135
|
+
|
|
136
|
+
# install requirements
|
|
137
|
+
verbose_check_call(UV_PATH, 'sync')
|
|
138
|
+
|
|
139
|
+
# install project
|
|
140
|
+
verbose_check_call(PIP_PATH, 'install', '--no-deps', '-e', '.')
|
|
135
141
|
store_dep_hash()
|
|
136
142
|
|
|
137
143
|
# The cmd2 shell should not abort on Ctrl-C => ignore "Interrupt from keyboard" signal:
|
|
138
144
|
signal.signal(signal.SIGINT, noop_signal_handler)
|
|
139
145
|
|
|
140
|
-
#
|
|
141
|
-
# (Call it via python, because Windows sucks calling the file direct)
|
|
146
|
+
# Call our entry point CLI:
|
|
142
147
|
try:
|
|
143
|
-
verbose_check_call(
|
|
148
|
+
verbose_check_call(PROJECT_SHELL_SCRIPT, *extra_args)
|
|
144
149
|
except subprocess.CalledProcessError as err:
|
|
145
150
|
sys.exit(err.returncode)
|
|
146
151
|
|
|
@@ -3,13 +3,26 @@ import sys
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
5
|
import cmd2
|
|
6
|
+
from cli_base.cli_tools import code_style
|
|
7
|
+
from cli_base.cli_tools.dev_tools import run_coverage, run_unittest_cli
|
|
8
|
+
from cli_base.cli_tools.subprocess_utils import ToolsExecutor
|
|
9
|
+
from cli_base.run_pip_audit import run_pip_audit
|
|
6
10
|
from cmd2 import Cmd2ArgumentParser, with_argparser
|
|
7
11
|
|
|
12
|
+
import dev_shell
|
|
13
|
+
from dev_shell import __version__
|
|
8
14
|
from dev_shell.command_sets import DevShellBaseCommandSet
|
|
15
|
+
from dev_shell.constants import PACKAGE_ROOT
|
|
9
16
|
from dev_shell.utils.colorful import bright_green
|
|
10
17
|
from dev_shell.utils.subprocess_utils import verbose_check_call
|
|
11
18
|
|
|
12
19
|
|
|
20
|
+
try:
|
|
21
|
+
from manageprojects.utilities.publish import publish_package # dev dependency
|
|
22
|
+
except ModuleNotFoundError:
|
|
23
|
+
publish_package = None
|
|
24
|
+
|
|
25
|
+
|
|
13
26
|
@cmd2.with_default_category('dev-shell commands')
|
|
14
27
|
class DevShellCommandSet(DevShellBaseCommandSet):
|
|
15
28
|
"""
|
|
@@ -17,7 +30,7 @@ class DevShellCommandSet(DevShellBaseCommandSet):
|
|
|
17
30
|
"""
|
|
18
31
|
|
|
19
32
|
MIN_PY_MAJOR_VERSION = 3
|
|
20
|
-
MIN_PY_MINOR_VERSION =
|
|
33
|
+
MIN_PY_MINOR_VERSION = 11
|
|
21
34
|
|
|
22
35
|
pyupgrade_argparser = Cmd2ArgumentParser()
|
|
23
36
|
pyupgrade_argparser.add_argument('--exit-zero-even-if-changed', action='store_true')
|
|
@@ -57,42 +70,33 @@ class DevShellCommandSet(DevShellBaseCommandSet):
|
|
|
57
70
|
change_count += 1
|
|
58
71
|
print(f'Out of {total_count} files, {change_count} have been updated.')
|
|
59
72
|
|
|
60
|
-
def
|
|
73
|
+
def do_test(self, statement: cmd2.Statement):
|
|
61
74
|
"""
|
|
62
|
-
Run
|
|
75
|
+
Run the project's test suite using the unittest runner.
|
|
63
76
|
"""
|
|
64
|
-
|
|
65
|
-
'pytest', *statement.arg_list, cwd=self.config.base_path, exit_on_error=True
|
|
66
|
-
)
|
|
77
|
+
run_unittest_cli(argv=statement.arg_list)
|
|
67
78
|
|
|
68
|
-
def
|
|
79
|
+
def do_coverage(self, statement: cmd2.Statement):
|
|
69
80
|
"""
|
|
70
|
-
|
|
81
|
+
Run the project's test suite using the unittest runner and create a coverage report.
|
|
71
82
|
"""
|
|
72
|
-
|
|
73
|
-
'tox', *statement.arg_list, cwd=self.config.base_path, exit_on_error=True
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
def do_poetry(self, statement: cmd2.Statement):
|
|
77
|
-
"""
|
|
78
|
-
Call poetry and pass all given arguments to it.
|
|
79
|
-
"""
|
|
80
|
-
verbose_check_call(
|
|
81
|
-
'poetry', *statement.arg_list, cwd=self.config.base_path, exit_on_error=True
|
|
82
|
-
)
|
|
83
|
+
run_coverage()
|
|
83
84
|
|
|
84
85
|
def do_update(self, statement: cmd2.Statement):
|
|
85
86
|
"""
|
|
86
87
|
Call "poetry update" to update all dependencies in .venv
|
|
87
88
|
"""
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
tools_executor = ToolsExecutor(cwd=PACKAGE_ROOT)
|
|
90
|
+
|
|
91
|
+
tools_executor.verbose_check_call('pip', 'install', '-U', 'pip')
|
|
92
|
+
tools_executor.verbose_check_call('pip', 'install', '-U', 'uv')
|
|
93
|
+
tools_executor.verbose_check_call('uv', 'lock', '--upgrade')
|
|
94
|
+
|
|
95
|
+
run_pip_audit(base_path=PACKAGE_ROOT)
|
|
96
|
+
|
|
97
|
+
# Install new dependencies in current .venv:
|
|
98
|
+
tools_executor.verbose_check_call('uv', 'sync')
|
|
99
|
+
|
|
96
100
|
script_name = Path(sys.argv[0]).name
|
|
97
101
|
print(bright_green(f'\n\nPlease restart "{script_name}" !\n'))
|
|
98
102
|
sys.exit(0) # Stop cmd
|
|
@@ -101,7 +105,13 @@ class DevShellCommandSet(DevShellBaseCommandSet):
|
|
|
101
105
|
"""
|
|
102
106
|
Fix code style by running darker
|
|
103
107
|
"""
|
|
104
|
-
|
|
108
|
+
code_style.fix(package_root=self.config.base_path)
|
|
109
|
+
|
|
110
|
+
def do_check_code_style(self, statement: cmd2.Statement):
|
|
111
|
+
"""
|
|
112
|
+
Check code style by running darker
|
|
113
|
+
"""
|
|
114
|
+
code_style.check(package_root=self.config.base_path)
|
|
105
115
|
|
|
106
116
|
def do_list_venv_packages(self, statement: cmd2.Statement):
|
|
107
117
|
"""
|
|
@@ -116,22 +126,15 @@ class DevShellCommandSet(DevShellBaseCommandSet):
|
|
|
116
126
|
"""
|
|
117
127
|
Publish "dev-shell" to PyPi
|
|
118
128
|
"""
|
|
119
|
-
#
|
|
120
|
-
# So import it here to make this dependency "optional"
|
|
121
|
-
from poetry_publish.publish import poetry_publish # noqa
|
|
129
|
+
run_unittest_cli(verbose=False, exit_after_run=False) # Don't publish a broken state
|
|
122
130
|
|
|
123
|
-
|
|
124
|
-
self.do_pytest(statement)
|
|
131
|
+
publish_package(module=dev_shell, package_path=PACKAGE_ROOT, distribution_name='dev-shell')
|
|
125
132
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
)
|
|
133
|
+
def do_version(self, statement: cmd2.Statement):
|
|
134
|
+
print(__version__)
|
|
135
|
+
sys.exit(0) # Stop cmd
|
|
130
136
|
|
|
131
137
|
|
|
132
|
-
|
|
133
|
-
try:
|
|
134
|
-
import poetry_publish # noqa
|
|
135
|
-
except ModuleNotFoundError:
|
|
138
|
+
if publish_package is None:
|
|
136
139
|
# Remove the "publish" command
|
|
137
140
|
del DevShellCommandSet.do_publish
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
PACKAGE_ROOT = Path(__file__).parent.parent.resolve()
|
|
6
|
+
assert Path(PACKAGE_ROOT / 'dev_shell').is_dir(), f'Path wrong: {PACKAGE_ROOT}'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
if sys.platform == 'win32': # wtf
|
|
10
|
+
BIN_NAME = 'Scripts'
|
|
11
|
+
else:
|
|
12
|
+
BIN_NAME = 'bin'
|
|
13
|
+
|
|
14
|
+
VENV_PATH = PACKAGE_ROOT / '.venv'
|
|
15
|
+
|
|
16
|
+
BIN_PATH = VENV_PATH / BIN_NAME
|
|
17
|
+
assert BIN_PATH.is_dir()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# The source file path for external projects:
|
|
21
|
+
BOOTSTRAP_SOURCE_FILE = PACKAGE_ROOT / 'dev_shell' / 'bootstrap-source.py'
|
|
@@ -35,7 +35,7 @@ def get_devshell_app_kwargs():
|
|
|
35
35
|
def devshell_cmdloop():
|
|
36
36
|
"""
|
|
37
37
|
Entry point to start the "dev-shell" cmd2 app.
|
|
38
|
-
Used in: [
|
|
38
|
+
Used in: [project.scripts]
|
|
39
39
|
"""
|
|
40
40
|
app = DevShellApp(**get_devshell_app_kwargs())
|
|
41
41
|
run_cmd2_app(app) # Run a cmd2 App as CLI or shell
|