dev-shell 0.8.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.
Files changed (45) hide show
  1. dev_shell-0.9.0/.editorconfig +20 -0
  2. dev_shell-0.9.0/.flake8 +7 -0
  3. dev_shell-0.9.0/.github/workflows/tests.yml +57 -0
  4. dev_shell-0.9.0/.gitignore +13 -0
  5. {dev_shell-0.8.0 → dev_shell-0.9.0}/PKG-INFO +20 -22
  6. {dev_shell-0.8.0 → dev_shell-0.9.0}/README.md +10 -8
  7. dev_shell-0.9.0/dev_shell/__init__.py +8 -0
  8. dev_shell-0.9.0/dev_shell/__main__.py +10 -0
  9. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/bootstrap-source.py +20 -23
  10. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/command_sets/dev_shell_commands.py +44 -41
  11. dev_shell-0.9.0/dev_shell/constants.py +21 -0
  12. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/dev_shell_app.py +1 -1
  13. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/tests/fixtures.py +0 -1
  14. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/tests/test_bootstrap.py +18 -42
  15. dev_shell-0.9.0/dev_shell/tests/test_dev_shell_app.py +73 -0
  16. dev_shell-0.9.0/dev_shell/tests/test_doctests.py +10 -0
  17. dev_shell-0.9.0/dev_shell/tests/test_project_setup.py +18 -0
  18. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/tests/test_source_file.py +5 -5
  19. dev_shell-0.9.0/dev_shell.egg-info/PKG-INFO +175 -0
  20. dev_shell-0.9.0/dev_shell.egg-info/SOURCES.txt +37 -0
  21. dev_shell-0.9.0/dev_shell.egg-info/dependency_links.txt +1 -0
  22. dev_shell-0.9.0/dev_shell.egg-info/entry_points.txt +2 -0
  23. dev_shell-0.9.0/dev_shell.egg-info/requires.txt +2 -0
  24. dev_shell-0.9.0/dev_shell.egg-info/top_level.txt +1 -0
  25. dev_shell-0.9.0/devshell.py +154 -0
  26. dev_shell-0.9.0/noxfile.py +25 -0
  27. dev_shell-0.9.0/pyproject.toml +140 -0
  28. dev_shell-0.9.0/setup.cfg +4 -0
  29. dev_shell-0.9.0/uv.lock +1601 -0
  30. dev_shell-0.8.0/dev_shell/__init__.py +0 -1
  31. dev_shell-0.8.0/dev_shell/constants.py +0 -21
  32. dev_shell-0.8.0/dev_shell/tests/constants.py +0 -17
  33. dev_shell-0.8.0/dev_shell/tests/test_dev_shell_app.py +0 -128
  34. dev_shell-0.8.0/dev_shell/tests/test_subprocess_utils.py +0 -195
  35. dev_shell-0.8.0/pyproject.toml +0 -105
  36. {dev_shell-0.8.0 → dev_shell-0.9.0}/LICENSE +0 -0
  37. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/base_cmd2_app.py +0 -0
  38. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/command_sets/__init__.py +0 -0
  39. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/config.py +0 -0
  40. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/tests/__init__.py +0 -0
  41. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/tests/utils.py +0 -0
  42. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/utils/__init__.py +0 -0
  43. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/utils/assertion.py +0 -0
  44. {dev_shell-0.8.0 → dev_shell-0.9.0}/dev_shell/utils/colorful.py +0 -0
  45. {dev_shell-0.8.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
@@ -0,0 +1,7 @@
1
+ #
2
+ # Move to pyproject.toml after: https://github.com/PyCQA/flake8/issues/234
3
+ #
4
+ [flake8]
5
+ exclude = .*, dist, htmlcov
6
+ #ignore = E402
7
+ max-line-length = 119
@@ -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
+
@@ -0,0 +1,13 @@
1
+ .*
2
+ *.egg-info
3
+ __pycache__
4
+ /dist/
5
+ /build/
6
+ /coverage.*
7
+ *.orig
8
+
9
+ !.github
10
+ !.editorconfig
11
+ !.flake8
12
+ !.gitignore
13
+ !.gitkeep
@@ -1,28 +1,25 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: dev-shell
3
- Version: 0.8.0
3
+ Version: 0.9.0
4
4
  Summary: Developer shell for easy startup...
5
- Home-page: https://github.com/jedie/dev-shell
6
- License: GNU General Public License v3.0
7
- Author: Jens Diemer
8
- Author-email: python@jensdiemer.de
9
- Requires-Python: >=3.9,<4.0
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
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
16
10
  Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: cmd2
13
+ Requires-Dist: cli-base-utilities
17
14
 
18
15
  # A "dev-shell" for Python projects ;)
19
16
 
20
- [![Test](https://github.com/jedie/dev-shell/actions/workflows/test.yml/badge.svg?branch=bugfix-path)](https://github.com/jedie/dev-shell/actions/workflows/test.yml)
21
- [![codecov](https://codecov.io/gh/jedie/dev-shell/branch/main/graph/badge.svg)](https://codecov.io/gh/jedie/dev-shell)
17
+ [![tests](https://github.com/jedie/dev-shell/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/jedie/dev-shell/actions/workflows/tests.yml)
18
+ [![codecov](https://codecov.io/github/jedie/dev_shell/branch/main/graph/badge.svg)](https://app.codecov.io/github/jedie/dev_shell)
19
+ [![dev_shell @ PyPi](https://img.shields.io/pypi/v/dev_shell?label=dev_shell%20%40%20PyPi)](https://pypi.org/project/dev_shell/)
20
+ [![Python Versions](https://img.shields.io/pypi/pyversions/dev_shell)](https://github.com/jedie/dev-shell/blob/main/pyproject.toml)
21
+ [![License GPL-3.0-or-later](https://img.shields.io/pypi/l/dev_shell)](https://github.com/jedie/dev-shell/blob/main/LICENSE)
22
22
 
23
- [![ddev-shell @ PyPi](https://img.shields.io/pypi/v/dev-shell?label=dev-shell%20%40%20PyPi)
24
- ![Python Versions](https://img.shields.io/pypi/pyversions/dev-shell)
25
- ![License GPL V3+](https://img.shields.io/pypi/l/dev-shell)](https://pypi.org/project/dev-shell/)
26
23
 
27
24
  This small project is intended to improve the start-up for collaborators.
28
25
 
@@ -37,7 +34,7 @@ The "dev-shell" is the base to create a CLI and a shell. It also shows how to ma
37
34
  ```bash
38
35
  ~$ git clone https://github.com/jedie/dev-shell.git
39
36
  ~$ cd dev-shell
40
- ~/dev-shell$ ./devshell.py pytest
37
+ ~/dev-shell$ ./devshell.py test
41
38
  ```
42
39
 
43
40
 
@@ -78,7 +75,7 @@ Documented commands (use 'help -v' for verbose/'help <topic>' for details):
78
75
 
79
76
  dev-shell commands
80
77
  ==================
81
- fix_code_style linting list_venv_packages publish pytest update
78
+ fix_code_style linting list_venv_packages publish test update
82
79
 
83
80
  ...
84
81
 
@@ -96,7 +93,7 @@ Developer shell - dev_shell - v0.2.0
96
93
  (dev_shell) help
97
94
  ```
98
95
 
99
- Info: The `.venv` will be automatically updated via `poetry install` call if the `poetry.lock` file has been changed.
96
+ Info: The `.venv` will be automatically updated via `poetry install` call if the `uv.lock` file has been changed.
100
97
 
101
98
  A call with `--update` will force to call some create/update steps, e.g.:
102
99
 
@@ -123,6 +120,8 @@ See also github test configuration: [.github/workflows/test.yml](https://github.
123
120
 
124
121
  * [*dev*](https://github.com/jedie/dev-shell/compare/v0.8.0...main)
125
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`
126
125
  * [0.8.0 - 2024-04-09](https://github.com/jedie/dev-shell/compare/v0.7.0...v0.8.0)
127
126
  * Remove "gnureadline" as dependency
128
127
  * update boot script
@@ -174,4 +173,3 @@ See also github test configuration: [.github/workflows/test.yml](https://github.
174
173
 
175
174
  * Github: https://github.com/jedie/dev-shell/
176
175
  * PyPi: https://pypi.org/project/dev-shell/
177
-
@@ -1,11 +1,11 @@
1
1
  # A "dev-shell" for Python projects ;)
2
2
 
3
- [![Test](https://github.com/jedie/dev-shell/actions/workflows/test.yml/badge.svg?branch=bugfix-path)](https://github.com/jedie/dev-shell/actions/workflows/test.yml)
4
- [![codecov](https://codecov.io/gh/jedie/dev-shell/branch/main/graph/badge.svg)](https://codecov.io/gh/jedie/dev-shell)
3
+ [![tests](https://github.com/jedie/dev-shell/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/jedie/dev-shell/actions/workflows/tests.yml)
4
+ [![codecov](https://codecov.io/github/jedie/dev_shell/branch/main/graph/badge.svg)](https://app.codecov.io/github/jedie/dev_shell)
5
+ [![dev_shell @ PyPi](https://img.shields.io/pypi/v/dev_shell?label=dev_shell%20%40%20PyPi)](https://pypi.org/project/dev_shell/)
6
+ [![Python Versions](https://img.shields.io/pypi/pyversions/dev_shell)](https://github.com/jedie/dev-shell/blob/main/pyproject.toml)
7
+ [![License GPL-3.0-or-later](https://img.shields.io/pypi/l/dev_shell)](https://github.com/jedie/dev-shell/blob/main/LICENSE)
5
8
 
6
- [![ddev-shell @ PyPi](https://img.shields.io/pypi/v/dev-shell?label=dev-shell%20%40%20PyPi)
7
- ![Python Versions](https://img.shields.io/pypi/pyversions/dev-shell)
8
- ![License GPL V3+](https://img.shields.io/pypi/l/dev-shell)](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 pytest
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 pytest update
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 `poetry.lock` file has been changed.
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
 
@@ -106,6 +106,8 @@ See also github test configuration: [.github/workflows/test.yml](https://github.
106
106
 
107
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`
109
111
  * [0.8.0 - 2024-04-09](https://github.com/jedie/dev-shell/compare/v0.7.0...v0.8.0)
110
112
  * Remove "gnureadline" as dependency
111
113
  * update boot script
@@ -0,0 +1,8 @@
1
+ """
2
+ dev_shell
3
+ Developer shell for easy startup...
4
+ """
5
+
6
+ # See https://packaging.python.org/en/latest/specifications/version-specifiers/
7
+ __version__ = '0.9.0'
8
+ __author__ = 'Jens Diemer <dev-shell@jensdiemer.de>'
@@ -0,0 +1,10 @@
1
+ """
2
+ Allow dev_shell to be executable
3
+ through `python -m dev_shell`.
4
+ """
5
+
6
+ from dev_shell.dev_shell_app import devshell_cmdloop
7
+
8
+
9
+ if __name__ == '__main__':
10
+ devshell_cmdloop()
@@ -40,7 +40,7 @@ else:
40
40
  sys.exit(-1)
41
41
 
42
42
 
43
- assert sys.version_info >= (3, 9), f'Python version {sys.version_info} is too old!'
43
+ assert sys.version_info >= (3, 11), f'Python version {sys.version_info} is too old!'
44
44
 
45
45
 
46
46
  if sys.platform == 'win32': # wtf
@@ -48,21 +48,21 @@ if sys.platform == 'win32': # wtf
48
48
  BIN_NAME = 'Scripts'
49
49
  FILE_EXT = '.exe'
50
50
  else:
51
- # Files under Linux/Mac and all other than Windows, e.g.: .../.venv/bin/python
51
+ # Files under Linux/Mac and all other than Windows, e.g.: .../.venv/bin/python3
52
52
  BIN_NAME = 'bin'
53
53
  FILE_EXT = ''
54
54
 
55
55
  BASE_PATH = Path(__file__).parent
56
56
  VENV_PATH = BASE_PATH / '.venv'
57
57
  BIN_PATH = VENV_PATH / BIN_NAME
58
- PYTHON_PATH = BIN_PATH / f'python{FILE_EXT}'
58
+ PYTHON_PATH = BIN_PATH / f'python3{FILE_EXT}'
59
59
  PIP_PATH = BIN_PATH / f'pip{FILE_EXT}'
60
- POETRY_PATH = BIN_PATH / f'poetry{FILE_EXT}'
60
+ UV_PATH = BIN_PATH / f'uv{FILE_EXT}'
61
61
 
62
- DEP_LOCK_PATH = BASE_PATH / 'poetry.lock'
62
+ DEP_LOCK_PATH = BASE_PATH / 'uv.lock'
63
63
  DEP_HASH_PATH = VENV_PATH / '.dep_hash'
64
64
 
65
- # script file defined in pyproject.toml as [tool.poetry.scripts]
65
+ # script file defined in pyproject.toml as [console_scripts]
66
66
  # (Under Windows: ".exe" not added!)
67
67
  PROJECT_SHELL_SCRIPT = BIN_PATH / 'devshell'
68
68
 
@@ -120,35 +120,32 @@ def main(argv):
120
120
  force_update = False
121
121
  extra_args = argv[1:]
122
122
 
123
- # Create virtual env in ".../.venv/":
123
+ # Create virtual env in ".venv/":
124
124
  if not PYTHON_PATH.is_file() or force_update:
125
- print('Create virtual env here:', VENV_PATH.absolute())
125
+ print(f'Create virtual env here: {VENV_PATH.absolute()}')
126
126
  builder = venv.EnvBuilder(symlinks=True, upgrade=True, with_pip=True)
127
127
  builder.create(env_dir=VENV_PATH)
128
+
129
+ if not PROJECT_SHELL_SCRIPT.is_file() or not venv_up2date() or force_update:
128
130
  # Update pip
129
131
  verbose_check_call(PYTHON_PATH, '-m', 'pip', 'install', '-U', 'pip')
130
132
 
131
- # install/update "pip" and "poetry":
132
- if not POETRY_PATH.is_file() or force_update:
133
- # Note: Under Windows pip.exe can't replace this own .exe file, so use the module way:
134
- verbose_check_call(PYTHON_PATH, '-m', 'pip', 'install', '-U', 'pip', 'setuptools')
135
- verbose_check_call(PIP_PATH, 'install', 'poetry')
136
-
137
- # install via poetry, if:
138
- # 1. .venv not exists
139
- # 2. "--update" used
140
- # 3. poetry.lock file was changed
141
- if not PROJECT_SHELL_SCRIPT.is_file() or force_update or not venv_up2date():
142
- verbose_check_call(POETRY_PATH, 'install')
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', '.')
143
141
  store_dep_hash()
144
142
 
145
143
  # The cmd2 shell should not abort on Ctrl-C => ignore "Interrupt from keyboard" signal:
146
144
  signal.signal(signal.SIGINT, noop_signal_handler)
147
145
 
148
- # Run project cmd shell via "setup.py" entrypoint:
149
- # (Call it via python, because Windows sucks calling the file direct)
146
+ # Call our entry point CLI:
150
147
  try:
151
- verbose_check_call(PYTHON_PATH, PROJECT_SHELL_SCRIPT, *extra_args)
148
+ verbose_check_call(PROJECT_SHELL_SCRIPT, *extra_args)
152
149
  except subprocess.CalledProcessError as err:
153
150
  sys.exit(err.returncode)
154
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 = 7
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 do_pytest(self, statement: cmd2.Statement):
73
+ def do_test(self, statement: cmd2.Statement):
61
74
  """
62
- Run dev-shell tests via pytest
75
+ Run the project's test suite using the unittest runner.
63
76
  """
64
- verbose_check_call(
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 do_tox(self, statement: cmd2.Statement):
79
+ def do_coverage(self, statement: cmd2.Statement):
69
80
  """
70
- Call tox and pass all given arguments to it.
81
+ Run the project's test suite using the unittest runner and create a coverage report.
71
82
  """
72
- verbose_check_call(
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
- verbose_check_call(
89
- 'poetry',
90
- 'update',
91
- '-v',
92
- *statement.arg_list,
93
- cwd=self.config.base_path,
94
- exit_on_error=True
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
- verbose_check_call('darker', cwd=self.config.base_path)
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
- # Maybe a project that use dev-shell doesn't use poetry-publish, too!
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
- # Don't publish if test failed or code linting wrong:
124
- self.do_pytest(statement)
131
+ publish_package(module=dev_shell, package_path=PACKAGE_ROOT, distribution_name='dev-shell')
125
132
 
126
- poetry_publish(
127
- package_root=self.config.base_path,
128
- version=self.config.version,
129
- )
133
+ def do_version(self, statement: cmd2.Statement):
134
+ print(__version__)
135
+ sys.exit(0) # Stop cmd
130
136
 
131
137
 
132
- # Maybe a project that use dev-shell doesn't use poetry-publish:
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: [tool.poetry.scripts]
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
@@ -1,5 +1,4 @@
1
1
  from unittest.case import TestCase
2
-
3
2
  from cmd2 import CommandResult
4
3
  from cmd2.ansi import strip_style
5
4
  from cmd2_ext_test import ExternalTestMixin
@@ -10,14 +10,6 @@ from pathlib import Path
10
10
  from unittest import TestCase, mock
11
11
 
12
12
  import devshell
13
- from dev_shell.constants import VENV_PATH
14
- from dev_shell.tests.constants import (
15
- DEVSHELL_CALL,
16
- VENV_DEVSHELL,
17
- VENV_PIP,
18
- VENV_POETRY,
19
- VENV_PYTHON,
20
- )
21
13
  from dev_shell.tests.utils import call_mocked_subprocess
22
14
  from dev_shell.utils.assertion import assert_is_dir, assert_is_file
23
15
 
@@ -42,39 +34,34 @@ def call_devsetup_main(*args, catch_sys_exit=False):
42
34
 
43
35
  class BootstrapTestCase(TestCase):
44
36
  def test_up2date_bootstrap(self):
45
- # .dep_hash is up-to-date -> no "poetry install" call:
37
+ # .dep_hash is up-to-date -> no "uv install" call:
46
38
  check_calls, stdout, stderr = call_devsetup_main()
47
- assert stderr == ''
48
- assert f'{DEVSHELL_CALL}\n' in stdout
49
- assert check_calls == [DEVSHELL_CALL]
50
- assert 'poetry' not in stdout
39
+ self.assertEqual(stderr, '')
40
+ self.assertIn('.venv/bin/devshell', stdout)
41
+ self.assertNotIn('uv ', stdout)
51
42
 
52
- def test_poetry_install_call(self):
43
+ def test_uv_install_call(self):
53
44
  base_path = Path(devshell.__file__).parent
54
45
  assert_is_dir(base_path / 'dev_shell')
55
46
 
56
47
  DEP_HASH_PATH = base_path / '.venv' / '.dep_hash'
57
48
  assert_is_file(DEP_HASH_PATH)
58
49
 
59
- DEP_LOCK_PATH = base_path / 'poetry.lock'
50
+ DEP_LOCK_PATH = base_path / 'uv.lock'
60
51
 
61
52
  current_hash = sha512(DEP_LOCK_PATH.read_bytes()).hexdigest()
62
53
 
63
54
  assert DEP_HASH_PATH.read_text() == current_hash
64
55
 
65
- # Change the hash -> "poetry install" should be called:
56
+ # Change the hash -> "uv install" should be called:
66
57
 
67
58
  try:
68
59
  DEP_HASH_PATH.write_text('this is not the hash')
69
60
 
70
61
  check_calls, stdout, stderr = call_devsetup_main()
71
- assert stderr == ''
72
- assert f'{VENV_POETRY} install' in stdout
73
- assert f'{VENV_PYTHON} {VENV_DEVSHELL}\n' in stdout
74
- assert check_calls == [
75
- f'{VENV_POETRY} install', # <<< install called?
76
- DEVSHELL_CALL
77
- ]
62
+ self.assertEqual(stderr, '')
63
+ self.assertIn('uv sync', stdout)
64
+ self.assertIn('.venv/bin/devshell', stdout)
78
65
  finally:
79
66
  DEP_HASH_PATH.write_text(current_hash)
80
67
 
@@ -85,27 +72,18 @@ class BootstrapTestCase(TestCase):
85
72
  with mock.patch('venv.EnvBuilder.create') as create_mock:
86
73
  check_calls, stdout, stderr = call_devsetup_main('devshell.py', '--update')
87
74
 
88
- assert stderr == ''
89
- assert f'{VENV_POETRY} install' in stdout
90
- assert f'{DEVSHELL_CALL}\n' in stdout
91
- self.assertEqual(
92
- check_calls,
93
- [
94
- f'{VENV_PYTHON} -m pip install -U pip',
95
- f'{VENV_PYTHON} -m pip install -U pip setuptools',
96
- f'{VENV_PIP} install poetry',
97
- f'{VENV_POETRY} install',
98
- DEVSHELL_CALL,
99
- ],
100
- )
101
- create_mock.assert_called_once_with(env_dir=VENV_PATH)
75
+ self.assertEqual(stderr, '')
76
+ self.assertIn('Create virtual env here:', stdout)
77
+ self.assertIn('uv sync', stdout)
78
+ self.assertIn('.venv/bin/devshell\n', stdout)
79
+ create_mock.assert_called_once()
102
80
 
103
81
  def test_help(self):
104
82
  check_calls, stdout, stderr = call_devsetup_main(
105
83
  'devshell.py', '--help',
106
84
  catch_sys_exit=True
107
85
  )
108
- assert stderr == ''
86
+ self.assertEqual(stderr, '')
109
87
  assert 'usage: devshell.py [-h] [--update] [command_args ' in stdout
110
88
  assert stdout.endswith('...live long and prosper...\n')
111
89
  assert check_calls == []
@@ -118,8 +96,6 @@ class BootstrapTestCase(TestCase):
118
96
  'devshell.py', 'not_existing_command', '--help',
119
97
  catch_sys_exit=True
120
98
  )
121
- assert stderr == ''
99
+ self.assertEqual(stderr, '')
122
100
  assert 'not_existing_command --help' in stdout
123
- assert check_calls == [
124
- f'{DEVSHELL_CALL} not_existing_command --help'
125
- ]
101
+ self.assertIn('.venv/bin/devshell not_existing_command --help', check_calls[0])