cmdpackage 0.1.3__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.
- cmdpackage-0.1.3/LICENSE +21 -0
- cmdpackage-0.1.3/PKG-INFO +211 -0
- cmdpackage-0.1.3/README.md +196 -0
- cmdpackage-0.1.3/cmdpackage.egg-info/PKG-INFO +211 -0
- cmdpackage-0.1.3/cmdpackage.egg-info/SOURCES.txt +19 -0
- cmdpackage-0.1.3/cmdpackage.egg-info/dependency_links.txt +1 -0
- cmdpackage-0.1.3/cmdpackage.egg-info/entry_points.txt +2 -0
- cmdpackage-0.1.3/cmdpackage.egg-info/top_level.txt +2 -0
- cmdpackage-0.1.3/pyproject.toml +33 -0
- cmdpackage-0.1.3/setup.cfg +4 -0
- cmdpackage-0.1.3/src/__init__.py +73 -0
- cmdpackage-0.1.3/src/defs/__init__.py +0 -0
- cmdpackage-0.1.3/src/defs/createzVirtualEnv.py +27 -0
- cmdpackage-0.1.3/src/defs/runSubProc.py +10 -0
- cmdpackage-0.1.3/src/defs/writeCLIPackage.py +98 -0
- cmdpackage-0.1.3/src/defs/writePyProject.py +140 -0
- cmdpackage-0.1.3/src/defs/writeSetup.py +124 -0
- cmdpackage-0.1.3/src/templates/__init__.py +0 -0
- cmdpackage-0.1.3/src/templates/cmdTemplate.py +772 -0
- cmdpackage-0.1.3/src/templates/pyprojectTemplate.py +114 -0
- cmdpackage-0.1.3/src/templates/setupTemplates.py +113 -0
cmdpackage-0.1.3/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Martin Pytel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,211 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: cmdpackage
|
3
|
+
Version: 0.1.3
|
4
|
+
Summary: Automated python package generator for CLI function calls
|
5
|
+
Author-email: mpytel <mpytel@domain.com>
|
6
|
+
Maintainer-email: mpytel <mpytel@domain.com>
|
7
|
+
Project-URL: Homepage, https://github.com/mpytel/cmdpackage
|
8
|
+
Project-URL: Bug Tracker, https://github.com/mpytel/cmdpackage/issues
|
9
|
+
Classifier: Programming Language :: Python
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
11
|
+
Classifier: Operating System :: OS Independent
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
License-File: LICENSE
|
14
|
+
Dynamic: license-file
|
15
|
+
|
16
|
+
# Command Package (cmdpackage)
|
17
|
+
|
18
|
+
## Table of Contents
|
19
|
+
|
20
|
+
- [Command Package (cmdpackage)](#command-package-cmdpackage)
|
21
|
+
- [Table of Contents](#table-of-contents)
|
22
|
+
- [Introduction](#introduction)
|
23
|
+
- [Standard Installation from PyPI](#standard-installation-from-pypi)
|
24
|
+
- [Using cmdpackage to Create New Python Packages](#using-cmdpackage-to-create-new-python-packages)
|
25
|
+
- [Modifying New Python Packages](#modifying-new-python-packages)
|
26
|
+
- [Install New Editable Python Package](#install-new-editable-python-package)
|
27
|
+
- [Editable cmdpackage Installation](#editable-cmdpackage-installation)
|
28
|
+
- [Automated Default New Package Setup with `cmdpackage.sh`](#automated-default-new-package-setup-with-cmdpackagesh)
|
29
|
+
|
30
|
+
-----
|
31
|
+
|
32
|
+
## Introduction
|
33
|
+
|
34
|
+
**cmdpackage** is a pip package that generates opinionated Python command-line program packages. These derived program packages automate the creation of new CLI program commands that you can modify in a development environment. `cmdpackage` can be installed as a standard (or "production") installation or as an editable (or "development") installation directly from GitHub.
|
35
|
+
|
36
|
+
-----
|
37
|
+
|
38
|
+
## Standard Installation from PyPI
|
39
|
+
|
40
|
+
A standard installation allows a user to quickly create derived program packages.
|
41
|
+
|
42
|
+
```bash
|
43
|
+
pip install cmdpackage
|
44
|
+
```
|
45
|
+
|
46
|
+
The derived program packages will be modified in a virtual Python development environment using `virtualenv`. This virtual environment is isolated as a self-contained Python installation with its own `site-packages` directory. This isolation prevents dependency conflicts between different projects.
|
47
|
+
|
48
|
+
```bash
|
49
|
+
pip install virtualenv
|
50
|
+
```
|
51
|
+
|
52
|
+
### Using cmdpackage to Create New Python Packages
|
53
|
+
|
54
|
+
Once installed, you can create a package directory for your new Python package (e.g., `myTypes`) and run `cmdpackage` to generate the necessary files within this directory.
|
55
|
+
|
56
|
+
```
|
57
|
+
mkdir $HOME/myTypes
|
58
|
+
cd $HOME/myTypes
|
59
|
+
cmdpackage
|
60
|
+
```
|
61
|
+
|
62
|
+
You will be asked standard package generation questions:
|
63
|
+
|
64
|
+
```
|
65
|
+
name (myTypes):
|
66
|
+
version (0.1.0):
|
67
|
+
description (myTypes pip package):
|
68
|
+
readme ():
|
69
|
+
license (MIT License):
|
70
|
+
authors (username):
|
71
|
+
authorsEmail (username@domain.com):
|
72
|
+
maintainers (username):
|
73
|
+
maintainersEmail (username@domain.com):
|
74
|
+
classifiers ():
|
75
|
+
commit a git repo [Y/n]?:
|
76
|
+
```
|
77
|
+
|
78
|
+
The **default input** for each question is the bracketed value. The username will be set to your global Git config name if Git is present; otherwise, your system login username will be used.
|
79
|
+
|
80
|
+
### Modifying New Python Packages
|
81
|
+
|
82
|
+
You're now ready to work on your new Python package, `myTypes`, by first activating a Python virtual development environment.
|
83
|
+
|
84
|
+
* **Activation Process:** To use a virtual environment, you must **activate** it. This is typically done by running a script within the environment's directory:
|
85
|
+
|
86
|
+
* On Linux/macOS: `source /path/to/myTypes/env/bin/activate`
|
87
|
+
* On Windows: `/path/to/myTypes/env/Scripts/activate` **(Not tested on Windows)**
|
88
|
+
|
89
|
+
Activating the environment modifies your terminal's shell session, primarily by adjusting your `PATH` environment variable. This ensures that when you type `python` or `pip`, you are using the Python interpreter and package manager from within that specific virtual environment, rather than your system's global Python.
|
90
|
+
|
91
|
+
**Deactivation Process:** When you **deactivate** a virtual environment, you return to the System/Global Python Environment.
|
92
|
+
|
93
|
+
* Execute: `deactivate`
|
94
|
+
|
95
|
+
#### Install New Editable Python Package
|
96
|
+
|
97
|
+
```
|
98
|
+
pip install -e .
|
99
|
+
```
|
100
|
+
|
101
|
+
Executing `pip list` results in the following output, showing the localized package installation in the Python virtual environment:
|
102
|
+
|
103
|
+
```
|
104
|
+
Package Version Editable project location
|
105
|
+
---------- ------- -----------------------------------
|
106
|
+
myTypes 0.1.0 /Users/<username>/proj/python/myTypes
|
107
|
+
pip 25.1.1
|
108
|
+
setuptools 80.9.0
|
109
|
+
wheel 0.45.1
|
110
|
+
```
|
111
|
+
|
112
|
+
Your new `myTypes` program is now ready to use as a launching point for your Python CLI development. A list of installed commands can be found using:
|
113
|
+
|
114
|
+
```
|
115
|
+
myTypes -h
|
116
|
+
```
|
117
|
+
|
118
|
+
To add a new command named `type` – which will record a token, a title representing the type of information this token represents, and a short description of what it is and where it can be used – use the following command:
|
119
|
+
|
120
|
+
```
|
121
|
+
myTypes newCmd type token title sd
|
122
|
+
```
|
123
|
+
|
124
|
+
You will then be prompted to enter help text for the command and each of the arguments you defined (`type`, `title`, `sd`):
|
125
|
+
|
126
|
+
1. Enter a description of the 'type' command:
|
127
|
+
*Records a token that represents a type of data or information.*
|
128
|
+
2. Enter a description of the 'token' argument:
|
129
|
+
*The token that represents a type of data or information.*
|
130
|
+
3. Enter a description of the 'title' argument:
|
131
|
+
*The title of the token that represents a type of data or information.*
|
132
|
+
4. Enter a description of the 'sd' argument:
|
133
|
+
*A short description of the type of data or information is entered for sd.*
|
134
|
+
|
135
|
+
Run the new `myTypes type` command:
|
136
|
+
|
137
|
+
```
|
138
|
+
myTypes type int integer 'An integer is a whole number that can be positive, negative, or zero.'
|
139
|
+
```
|
140
|
+
|
141
|
+
The path to the Python file that needs your modification (`type.py`) is displayed as output, along with the values of the three arguments (type, title, sd):
|
142
|
+
|
143
|
+
```
|
144
|
+
DEBUG: Modify default behavior in myTypes/commands/type.py
|
145
|
+
INFO: token: int
|
146
|
+
INFO: title: integer
|
147
|
+
INFO: sd: An integer is a whole number that can be positive, negative, or zero.
|
148
|
+
```
|
149
|
+
|
150
|
+
The `rmCmd` is used to remove a command from your `myTypes` program.
|
151
|
+
|
152
|
+
```
|
153
|
+
myTypes rmCmd run
|
154
|
+
```
|
155
|
+
|
156
|
+
-----
|
157
|
+
|
158
|
+
## Editable cmdpackage Installation
|
159
|
+
|
160
|
+
Modifying a clone of the `cmdpackage` GitHub repository allows a developer to change the initial files of new commands added to `cmdpackage` derived Python packages. The following commands are used to clone and install `cmdpackage` in a virtual environment for this purpose:
|
161
|
+
|
162
|
+
```bash
|
163
|
+
mkdir $HOME/proj
|
164
|
+
cd $HOME/proj
|
165
|
+
git clone https://github.com/mpytel/cmdpackage.git
|
166
|
+
cd cmdpackage
|
167
|
+
pip install -e .
|
168
|
+
```
|
169
|
+
|
170
|
+
We purposely installed `cmdpackage` in the System/Global Python Environment. `cmdpackage` is then used to generate program packages that run in Virtual Python Environments set up by `cmdpackage` when run in a new Python package directory for modification in a development environment. This is performed using the commands described in the two above sections:
|
171
|
+
|
172
|
+
1. [Creating a new package](#using-cmdpackage-to-create-new-python-packages)
|
173
|
+
2. [Modifying new python packages](#modifying-new-python-packages)
|
174
|
+
|
175
|
+
### Automated Default New Package Setup with `cmdpackage.sh`
|
176
|
+
|
177
|
+
A shell script (`cmdpackage.sh`) is provided in the `cmdpackage` directory to automate the creation of a new package using default setup values. This script creates and changes the working directory to one named after your program package. It then creates and activates a virtual environment within this directory, and installs the `cmdpackage` pip package from the local repository. It then creates the new package and uninstalls `cmdpackage` from the new package's virtual environment. The new package is installed and run to create a 'helloWorld' command to test and illustrate the `newCmd` command that is provided with the new derived package.
|
178
|
+
|
179
|
+
From any directory, execute the following command to run this shell script:
|
180
|
+
|
181
|
+
```bash
|
182
|
+
source $HOME/proj/python/cmdpackage/cmdpackage.sh myPack
|
183
|
+
```
|
184
|
+
|
185
|
+
If you prefer not to use the `cmdpackage.sh` shell script, the manual command steps used to create/install/use a new package (`myPack`) with a new 'helloWorld' command are:
|
186
|
+
|
187
|
+
```bash
|
188
|
+
mkdir myPack
|
189
|
+
cd myPack
|
190
|
+
virtualenv env/myPack
|
191
|
+
source env/myPack/bin/activate
|
192
|
+
pip install $HOME/proj/python/cmdpackage
|
193
|
+
cmdpackage
|
194
|
+
# Press the return key 11 times to accept the default values.
|
195
|
+
pip uninstall cmdpackage
|
196
|
+
# Press the return key to accept the default value Y.
|
197
|
+
pip install -e .
|
198
|
+
myPack newCmd helloWorld greeting
|
199
|
+
# When prompted by 'Enter help description for helloWorld:'
|
200
|
+
# enter: 'Echo the greeting text.'
|
201
|
+
# When prompted by 'Enter help description for greeting:'
|
202
|
+
# enter: 'The text to echo.'
|
203
|
+
myPack helloWorld "You're ready to add and remove commands, and modify code in your myPack project!"
|
204
|
+
```
|
205
|
+
|
206
|
+
The following output results from executing `myPack helloWorld`:
|
207
|
+
|
208
|
+
```
|
209
|
+
DEBUG: Modify default behavior in myPack/commands/helloWorld.py
|
210
|
+
INFO: greeting: You're ready to add and remove commands, and modify code in your myPack project!
|
211
|
+
```
|
@@ -0,0 +1,196 @@
|
|
1
|
+
# Command Package (cmdpackage)
|
2
|
+
|
3
|
+
## Table of Contents
|
4
|
+
|
5
|
+
- [Command Package (cmdpackage)](#command-package-cmdpackage)
|
6
|
+
- [Table of Contents](#table-of-contents)
|
7
|
+
- [Introduction](#introduction)
|
8
|
+
- [Standard Installation from PyPI](#standard-installation-from-pypi)
|
9
|
+
- [Using cmdpackage to Create New Python Packages](#using-cmdpackage-to-create-new-python-packages)
|
10
|
+
- [Modifying New Python Packages](#modifying-new-python-packages)
|
11
|
+
- [Install New Editable Python Package](#install-new-editable-python-package)
|
12
|
+
- [Editable cmdpackage Installation](#editable-cmdpackage-installation)
|
13
|
+
- [Automated Default New Package Setup with `cmdpackage.sh`](#automated-default-new-package-setup-with-cmdpackagesh)
|
14
|
+
|
15
|
+
-----
|
16
|
+
|
17
|
+
## Introduction
|
18
|
+
|
19
|
+
**cmdpackage** is a pip package that generates opinionated Python command-line program packages. These derived program packages automate the creation of new CLI program commands that you can modify in a development environment. `cmdpackage` can be installed as a standard (or "production") installation or as an editable (or "development") installation directly from GitHub.
|
20
|
+
|
21
|
+
-----
|
22
|
+
|
23
|
+
## Standard Installation from PyPI
|
24
|
+
|
25
|
+
A standard installation allows a user to quickly create derived program packages.
|
26
|
+
|
27
|
+
```bash
|
28
|
+
pip install cmdpackage
|
29
|
+
```
|
30
|
+
|
31
|
+
The derived program packages will be modified in a virtual Python development environment using `virtualenv`. This virtual environment is isolated as a self-contained Python installation with its own `site-packages` directory. This isolation prevents dependency conflicts between different projects.
|
32
|
+
|
33
|
+
```bash
|
34
|
+
pip install virtualenv
|
35
|
+
```
|
36
|
+
|
37
|
+
### Using cmdpackage to Create New Python Packages
|
38
|
+
|
39
|
+
Once installed, you can create a package directory for your new Python package (e.g., `myTypes`) and run `cmdpackage` to generate the necessary files within this directory.
|
40
|
+
|
41
|
+
```
|
42
|
+
mkdir $HOME/myTypes
|
43
|
+
cd $HOME/myTypes
|
44
|
+
cmdpackage
|
45
|
+
```
|
46
|
+
|
47
|
+
You will be asked standard package generation questions:
|
48
|
+
|
49
|
+
```
|
50
|
+
name (myTypes):
|
51
|
+
version (0.1.0):
|
52
|
+
description (myTypes pip package):
|
53
|
+
readme ():
|
54
|
+
license (MIT License):
|
55
|
+
authors (username):
|
56
|
+
authorsEmail (username@domain.com):
|
57
|
+
maintainers (username):
|
58
|
+
maintainersEmail (username@domain.com):
|
59
|
+
classifiers ():
|
60
|
+
commit a git repo [Y/n]?:
|
61
|
+
```
|
62
|
+
|
63
|
+
The **default input** for each question is the bracketed value. The username will be set to your global Git config name if Git is present; otherwise, your system login username will be used.
|
64
|
+
|
65
|
+
### Modifying New Python Packages
|
66
|
+
|
67
|
+
You're now ready to work on your new Python package, `myTypes`, by first activating a Python virtual development environment.
|
68
|
+
|
69
|
+
* **Activation Process:** To use a virtual environment, you must **activate** it. This is typically done by running a script within the environment's directory:
|
70
|
+
|
71
|
+
* On Linux/macOS: `source /path/to/myTypes/env/bin/activate`
|
72
|
+
* On Windows: `/path/to/myTypes/env/Scripts/activate` **(Not tested on Windows)**
|
73
|
+
|
74
|
+
Activating the environment modifies your terminal's shell session, primarily by adjusting your `PATH` environment variable. This ensures that when you type `python` or `pip`, you are using the Python interpreter and package manager from within that specific virtual environment, rather than your system's global Python.
|
75
|
+
|
76
|
+
**Deactivation Process:** When you **deactivate** a virtual environment, you return to the System/Global Python Environment.
|
77
|
+
|
78
|
+
* Execute: `deactivate`
|
79
|
+
|
80
|
+
#### Install New Editable Python Package
|
81
|
+
|
82
|
+
```
|
83
|
+
pip install -e .
|
84
|
+
```
|
85
|
+
|
86
|
+
Executing `pip list` results in the following output, showing the localized package installation in the Python virtual environment:
|
87
|
+
|
88
|
+
```
|
89
|
+
Package Version Editable project location
|
90
|
+
---------- ------- -----------------------------------
|
91
|
+
myTypes 0.1.0 /Users/<username>/proj/python/myTypes
|
92
|
+
pip 25.1.1
|
93
|
+
setuptools 80.9.0
|
94
|
+
wheel 0.45.1
|
95
|
+
```
|
96
|
+
|
97
|
+
Your new `myTypes` program is now ready to use as a launching point for your Python CLI development. A list of installed commands can be found using:
|
98
|
+
|
99
|
+
```
|
100
|
+
myTypes -h
|
101
|
+
```
|
102
|
+
|
103
|
+
To add a new command named `type` – which will record a token, a title representing the type of information this token represents, and a short description of what it is and where it can be used – use the following command:
|
104
|
+
|
105
|
+
```
|
106
|
+
myTypes newCmd type token title sd
|
107
|
+
```
|
108
|
+
|
109
|
+
You will then be prompted to enter help text for the command and each of the arguments you defined (`type`, `title`, `sd`):
|
110
|
+
|
111
|
+
1. Enter a description of the 'type' command:
|
112
|
+
*Records a token that represents a type of data or information.*
|
113
|
+
2. Enter a description of the 'token' argument:
|
114
|
+
*The token that represents a type of data or information.*
|
115
|
+
3. Enter a description of the 'title' argument:
|
116
|
+
*The title of the token that represents a type of data or information.*
|
117
|
+
4. Enter a description of the 'sd' argument:
|
118
|
+
*A short description of the type of data or information is entered for sd.*
|
119
|
+
|
120
|
+
Run the new `myTypes type` command:
|
121
|
+
|
122
|
+
```
|
123
|
+
myTypes type int integer 'An integer is a whole number that can be positive, negative, or zero.'
|
124
|
+
```
|
125
|
+
|
126
|
+
The path to the Python file that needs your modification (`type.py`) is displayed as output, along with the values of the three arguments (type, title, sd):
|
127
|
+
|
128
|
+
```
|
129
|
+
DEBUG: Modify default behavior in myTypes/commands/type.py
|
130
|
+
INFO: token: int
|
131
|
+
INFO: title: integer
|
132
|
+
INFO: sd: An integer is a whole number that can be positive, negative, or zero.
|
133
|
+
```
|
134
|
+
|
135
|
+
The `rmCmd` is used to remove a command from your `myTypes` program.
|
136
|
+
|
137
|
+
```
|
138
|
+
myTypes rmCmd run
|
139
|
+
```
|
140
|
+
|
141
|
+
-----
|
142
|
+
|
143
|
+
## Editable cmdpackage Installation
|
144
|
+
|
145
|
+
Modifying a clone of the `cmdpackage` GitHub repository allows a developer to change the initial files of new commands added to `cmdpackage` derived Python packages. The following commands are used to clone and install `cmdpackage` in a virtual environment for this purpose:
|
146
|
+
|
147
|
+
```bash
|
148
|
+
mkdir $HOME/proj
|
149
|
+
cd $HOME/proj
|
150
|
+
git clone https://github.com/mpytel/cmdpackage.git
|
151
|
+
cd cmdpackage
|
152
|
+
pip install -e .
|
153
|
+
```
|
154
|
+
|
155
|
+
We purposely installed `cmdpackage` in the System/Global Python Environment. `cmdpackage` is then used to generate program packages that run in Virtual Python Environments set up by `cmdpackage` when run in a new Python package directory for modification in a development environment. This is performed using the commands described in the two above sections:
|
156
|
+
|
157
|
+
1. [Creating a new package](#using-cmdpackage-to-create-new-python-packages)
|
158
|
+
2. [Modifying new python packages](#modifying-new-python-packages)
|
159
|
+
|
160
|
+
### Automated Default New Package Setup with `cmdpackage.sh`
|
161
|
+
|
162
|
+
A shell script (`cmdpackage.sh`) is provided in the `cmdpackage` directory to automate the creation of a new package using default setup values. This script creates and changes the working directory to one named after your program package. It then creates and activates a virtual environment within this directory, and installs the `cmdpackage` pip package from the local repository. It then creates the new package and uninstalls `cmdpackage` from the new package's virtual environment. The new package is installed and run to create a 'helloWorld' command to test and illustrate the `newCmd` command that is provided with the new derived package.
|
163
|
+
|
164
|
+
From any directory, execute the following command to run this shell script:
|
165
|
+
|
166
|
+
```bash
|
167
|
+
source $HOME/proj/python/cmdpackage/cmdpackage.sh myPack
|
168
|
+
```
|
169
|
+
|
170
|
+
If you prefer not to use the `cmdpackage.sh` shell script, the manual command steps used to create/install/use a new package (`myPack`) with a new 'helloWorld' command are:
|
171
|
+
|
172
|
+
```bash
|
173
|
+
mkdir myPack
|
174
|
+
cd myPack
|
175
|
+
virtualenv env/myPack
|
176
|
+
source env/myPack/bin/activate
|
177
|
+
pip install $HOME/proj/python/cmdpackage
|
178
|
+
cmdpackage
|
179
|
+
# Press the return key 11 times to accept the default values.
|
180
|
+
pip uninstall cmdpackage
|
181
|
+
# Press the return key to accept the default value Y.
|
182
|
+
pip install -e .
|
183
|
+
myPack newCmd helloWorld greeting
|
184
|
+
# When prompted by 'Enter help description for helloWorld:'
|
185
|
+
# enter: 'Echo the greeting text.'
|
186
|
+
# When prompted by 'Enter help description for greeting:'
|
187
|
+
# enter: 'The text to echo.'
|
188
|
+
myPack helloWorld "You're ready to add and remove commands, and modify code in your myPack project!"
|
189
|
+
```
|
190
|
+
|
191
|
+
The following output results from executing `myPack helloWorld`:
|
192
|
+
|
193
|
+
```
|
194
|
+
DEBUG: Modify default behavior in myPack/commands/helloWorld.py
|
195
|
+
INFO: greeting: You're ready to add and remove commands, and modify code in your myPack project!
|
196
|
+
```
|
@@ -0,0 +1,211 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: cmdpackage
|
3
|
+
Version: 0.1.3
|
4
|
+
Summary: Automated python package generator for CLI function calls
|
5
|
+
Author-email: mpytel <mpytel@domain.com>
|
6
|
+
Maintainer-email: mpytel <mpytel@domain.com>
|
7
|
+
Project-URL: Homepage, https://github.com/mpytel/cmdpackage
|
8
|
+
Project-URL: Bug Tracker, https://github.com/mpytel/cmdpackage/issues
|
9
|
+
Classifier: Programming Language :: Python
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
11
|
+
Classifier: Operating System :: OS Independent
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
License-File: LICENSE
|
14
|
+
Dynamic: license-file
|
15
|
+
|
16
|
+
# Command Package (cmdpackage)
|
17
|
+
|
18
|
+
## Table of Contents
|
19
|
+
|
20
|
+
- [Command Package (cmdpackage)](#command-package-cmdpackage)
|
21
|
+
- [Table of Contents](#table-of-contents)
|
22
|
+
- [Introduction](#introduction)
|
23
|
+
- [Standard Installation from PyPI](#standard-installation-from-pypi)
|
24
|
+
- [Using cmdpackage to Create New Python Packages](#using-cmdpackage-to-create-new-python-packages)
|
25
|
+
- [Modifying New Python Packages](#modifying-new-python-packages)
|
26
|
+
- [Install New Editable Python Package](#install-new-editable-python-package)
|
27
|
+
- [Editable cmdpackage Installation](#editable-cmdpackage-installation)
|
28
|
+
- [Automated Default New Package Setup with `cmdpackage.sh`](#automated-default-new-package-setup-with-cmdpackagesh)
|
29
|
+
|
30
|
+
-----
|
31
|
+
|
32
|
+
## Introduction
|
33
|
+
|
34
|
+
**cmdpackage** is a pip package that generates opinionated Python command-line program packages. These derived program packages automate the creation of new CLI program commands that you can modify in a development environment. `cmdpackage` can be installed as a standard (or "production") installation or as an editable (or "development") installation directly from GitHub.
|
35
|
+
|
36
|
+
-----
|
37
|
+
|
38
|
+
## Standard Installation from PyPI
|
39
|
+
|
40
|
+
A standard installation allows a user to quickly create derived program packages.
|
41
|
+
|
42
|
+
```bash
|
43
|
+
pip install cmdpackage
|
44
|
+
```
|
45
|
+
|
46
|
+
The derived program packages will be modified in a virtual Python development environment using `virtualenv`. This virtual environment is isolated as a self-contained Python installation with its own `site-packages` directory. This isolation prevents dependency conflicts between different projects.
|
47
|
+
|
48
|
+
```bash
|
49
|
+
pip install virtualenv
|
50
|
+
```
|
51
|
+
|
52
|
+
### Using cmdpackage to Create New Python Packages
|
53
|
+
|
54
|
+
Once installed, you can create a package directory for your new Python package (e.g., `myTypes`) and run `cmdpackage` to generate the necessary files within this directory.
|
55
|
+
|
56
|
+
```
|
57
|
+
mkdir $HOME/myTypes
|
58
|
+
cd $HOME/myTypes
|
59
|
+
cmdpackage
|
60
|
+
```
|
61
|
+
|
62
|
+
You will be asked standard package generation questions:
|
63
|
+
|
64
|
+
```
|
65
|
+
name (myTypes):
|
66
|
+
version (0.1.0):
|
67
|
+
description (myTypes pip package):
|
68
|
+
readme ():
|
69
|
+
license (MIT License):
|
70
|
+
authors (username):
|
71
|
+
authorsEmail (username@domain.com):
|
72
|
+
maintainers (username):
|
73
|
+
maintainersEmail (username@domain.com):
|
74
|
+
classifiers ():
|
75
|
+
commit a git repo [Y/n]?:
|
76
|
+
```
|
77
|
+
|
78
|
+
The **default input** for each question is the bracketed value. The username will be set to your global Git config name if Git is present; otherwise, your system login username will be used.
|
79
|
+
|
80
|
+
### Modifying New Python Packages
|
81
|
+
|
82
|
+
You're now ready to work on your new Python package, `myTypes`, by first activating a Python virtual development environment.
|
83
|
+
|
84
|
+
* **Activation Process:** To use a virtual environment, you must **activate** it. This is typically done by running a script within the environment's directory:
|
85
|
+
|
86
|
+
* On Linux/macOS: `source /path/to/myTypes/env/bin/activate`
|
87
|
+
* On Windows: `/path/to/myTypes/env/Scripts/activate` **(Not tested on Windows)**
|
88
|
+
|
89
|
+
Activating the environment modifies your terminal's shell session, primarily by adjusting your `PATH` environment variable. This ensures that when you type `python` or `pip`, you are using the Python interpreter and package manager from within that specific virtual environment, rather than your system's global Python.
|
90
|
+
|
91
|
+
**Deactivation Process:** When you **deactivate** a virtual environment, you return to the System/Global Python Environment.
|
92
|
+
|
93
|
+
* Execute: `deactivate`
|
94
|
+
|
95
|
+
#### Install New Editable Python Package
|
96
|
+
|
97
|
+
```
|
98
|
+
pip install -e .
|
99
|
+
```
|
100
|
+
|
101
|
+
Executing `pip list` results in the following output, showing the localized package installation in the Python virtual environment:
|
102
|
+
|
103
|
+
```
|
104
|
+
Package Version Editable project location
|
105
|
+
---------- ------- -----------------------------------
|
106
|
+
myTypes 0.1.0 /Users/<username>/proj/python/myTypes
|
107
|
+
pip 25.1.1
|
108
|
+
setuptools 80.9.0
|
109
|
+
wheel 0.45.1
|
110
|
+
```
|
111
|
+
|
112
|
+
Your new `myTypes` program is now ready to use as a launching point for your Python CLI development. A list of installed commands can be found using:
|
113
|
+
|
114
|
+
```
|
115
|
+
myTypes -h
|
116
|
+
```
|
117
|
+
|
118
|
+
To add a new command named `type` – which will record a token, a title representing the type of information this token represents, and a short description of what it is and where it can be used – use the following command:
|
119
|
+
|
120
|
+
```
|
121
|
+
myTypes newCmd type token title sd
|
122
|
+
```
|
123
|
+
|
124
|
+
You will then be prompted to enter help text for the command and each of the arguments you defined (`type`, `title`, `sd`):
|
125
|
+
|
126
|
+
1. Enter a description of the 'type' command:
|
127
|
+
*Records a token that represents a type of data or information.*
|
128
|
+
2. Enter a description of the 'token' argument:
|
129
|
+
*The token that represents a type of data or information.*
|
130
|
+
3. Enter a description of the 'title' argument:
|
131
|
+
*The title of the token that represents a type of data or information.*
|
132
|
+
4. Enter a description of the 'sd' argument:
|
133
|
+
*A short description of the type of data or information is entered for sd.*
|
134
|
+
|
135
|
+
Run the new `myTypes type` command:
|
136
|
+
|
137
|
+
```
|
138
|
+
myTypes type int integer 'An integer is a whole number that can be positive, negative, or zero.'
|
139
|
+
```
|
140
|
+
|
141
|
+
The path to the Python file that needs your modification (`type.py`) is displayed as output, along with the values of the three arguments (type, title, sd):
|
142
|
+
|
143
|
+
```
|
144
|
+
DEBUG: Modify default behavior in myTypes/commands/type.py
|
145
|
+
INFO: token: int
|
146
|
+
INFO: title: integer
|
147
|
+
INFO: sd: An integer is a whole number that can be positive, negative, or zero.
|
148
|
+
```
|
149
|
+
|
150
|
+
The `rmCmd` is used to remove a command from your `myTypes` program.
|
151
|
+
|
152
|
+
```
|
153
|
+
myTypes rmCmd run
|
154
|
+
```
|
155
|
+
|
156
|
+
-----
|
157
|
+
|
158
|
+
## Editable cmdpackage Installation
|
159
|
+
|
160
|
+
Modifying a clone of the `cmdpackage` GitHub repository allows a developer to change the initial files of new commands added to `cmdpackage` derived Python packages. The following commands are used to clone and install `cmdpackage` in a virtual environment for this purpose:
|
161
|
+
|
162
|
+
```bash
|
163
|
+
mkdir $HOME/proj
|
164
|
+
cd $HOME/proj
|
165
|
+
git clone https://github.com/mpytel/cmdpackage.git
|
166
|
+
cd cmdpackage
|
167
|
+
pip install -e .
|
168
|
+
```
|
169
|
+
|
170
|
+
We purposely installed `cmdpackage` in the System/Global Python Environment. `cmdpackage` is then used to generate program packages that run in Virtual Python Environments set up by `cmdpackage` when run in a new Python package directory for modification in a development environment. This is performed using the commands described in the two above sections:
|
171
|
+
|
172
|
+
1. [Creating a new package](#using-cmdpackage-to-create-new-python-packages)
|
173
|
+
2. [Modifying new python packages](#modifying-new-python-packages)
|
174
|
+
|
175
|
+
### Automated Default New Package Setup with `cmdpackage.sh`
|
176
|
+
|
177
|
+
A shell script (`cmdpackage.sh`) is provided in the `cmdpackage` directory to automate the creation of a new package using default setup values. This script creates and changes the working directory to one named after your program package. It then creates and activates a virtual environment within this directory, and installs the `cmdpackage` pip package from the local repository. It then creates the new package and uninstalls `cmdpackage` from the new package's virtual environment. The new package is installed and run to create a 'helloWorld' command to test and illustrate the `newCmd` command that is provided with the new derived package.
|
178
|
+
|
179
|
+
From any directory, execute the following command to run this shell script:
|
180
|
+
|
181
|
+
```bash
|
182
|
+
source $HOME/proj/python/cmdpackage/cmdpackage.sh myPack
|
183
|
+
```
|
184
|
+
|
185
|
+
If you prefer not to use the `cmdpackage.sh` shell script, the manual command steps used to create/install/use a new package (`myPack`) with a new 'helloWorld' command are:
|
186
|
+
|
187
|
+
```bash
|
188
|
+
mkdir myPack
|
189
|
+
cd myPack
|
190
|
+
virtualenv env/myPack
|
191
|
+
source env/myPack/bin/activate
|
192
|
+
pip install $HOME/proj/python/cmdpackage
|
193
|
+
cmdpackage
|
194
|
+
# Press the return key 11 times to accept the default values.
|
195
|
+
pip uninstall cmdpackage
|
196
|
+
# Press the return key to accept the default value Y.
|
197
|
+
pip install -e .
|
198
|
+
myPack newCmd helloWorld greeting
|
199
|
+
# When prompted by 'Enter help description for helloWorld:'
|
200
|
+
# enter: 'Echo the greeting text.'
|
201
|
+
# When prompted by 'Enter help description for greeting:'
|
202
|
+
# enter: 'The text to echo.'
|
203
|
+
myPack helloWorld "You're ready to add and remove commands, and modify code in your myPack project!"
|
204
|
+
```
|
205
|
+
|
206
|
+
The following output results from executing `myPack helloWorld`:
|
207
|
+
|
208
|
+
```
|
209
|
+
DEBUG: Modify default behavior in myPack/commands/helloWorld.py
|
210
|
+
INFO: greeting: You're ready to add and remove commands, and modify code in your myPack project!
|
211
|
+
```
|
@@ -0,0 +1,19 @@
|
|
1
|
+
LICENSE
|
2
|
+
README.md
|
3
|
+
pyproject.toml
|
4
|
+
cmdpackage.egg-info/PKG-INFO
|
5
|
+
cmdpackage.egg-info/SOURCES.txt
|
6
|
+
cmdpackage.egg-info/dependency_links.txt
|
7
|
+
cmdpackage.egg-info/entry_points.txt
|
8
|
+
cmdpackage.egg-info/top_level.txt
|
9
|
+
src/__init__.py
|
10
|
+
src/defs/__init__.py
|
11
|
+
src/defs/createzVirtualEnv.py
|
12
|
+
src/defs/runSubProc.py
|
13
|
+
src/defs/writeCLIPackage.py
|
14
|
+
src/defs/writePyProject.py
|
15
|
+
src/defs/writeSetup.py
|
16
|
+
src/templates/__init__.py
|
17
|
+
src/templates/cmdTemplate.py
|
18
|
+
src/templates/pyprojectTemplate.py
|
19
|
+
src/templates/setupTemplates.py
|
@@ -0,0 +1 @@
|
|
1
|
+
|