templatepy 0.0.2__tar.gz → 0.2.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.
@@ -0,0 +1,310 @@
1
+ Metadata-Version: 2.1
2
+ Name: templatepy
3
+ Version: 0.2.0
4
+ Summary: templatepy: template for derivative python packages
5
+ Author-email: "Lars B. Rollik" <L.B.Rollik@protonmail.com>
6
+ License: BSD 3-Clause License
7
+
8
+ Copyright (c) 2021, Lars B. Rollik
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this
15
+ list of conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright notice,
18
+ this list of conditions and the following disclaimer in the documentation
19
+ and/or other materials provided with the distribution.
20
+
21
+ 3. Neither the name of the copyright holder nor the names of its
22
+ contributors may be used to endorse or promote products derived from
23
+ this software without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
+
36
+ Project-URL: Repository, https://github.com/larsrollik/templatepy
37
+ Project-URL: Issue Tracker, https://github.com/larsrollik/templatepy/issues
38
+ Classifier: Intended Audience :: Developers
39
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
40
+ Classifier: License :: OSI Approved :: BSD License
41
+ Classifier: Programming Language :: Python
42
+ Classifier: Programming Language :: Python :: 3
43
+ Classifier: Programming Language :: Python :: 3.10
44
+ Classifier: Programming Language :: Python :: 3.11
45
+ Requires-Python: >=3.10
46
+ Description-Content-Type: text/markdown
47
+ License-File: LICENSE
48
+ Requires-Dist: black
49
+ Provides-Extra: dev
50
+ Requires-Dist: black; extra == "dev"
51
+ Requires-Dist: bump2version; extra == "dev"
52
+ Requires-Dist: pytest-cov; extra == "dev"
53
+ Requires-Dist: pre-commit; extra == "dev"
54
+ Requires-Dist: flake8; extra == "dev"
55
+
56
+ [//]: # (Links)
57
+ [Github-flavored markdown]: https://github.github.com/gfm
58
+
59
+ [manifest]: https://packaging.python.org/en/latest/guides/using-manifest-in
60
+ [packaging]: https://packaging.python.org/en/latest/tutorials/packaging-projects
61
+ [setup.cfg]: https://setuptools.pypa.io/en/latest/userguide/declarative_config.html
62
+
63
+ [bump2version]: (https://github.com/c4urself/bump2version
64
+ [pre-commit]: https://pre-commit.com
65
+ [black]: https://github.com/psf/black
66
+
67
+ [pypi]: pypi.org
68
+ [test.pypi]: test.pypi.org
69
+
70
+ [Zenodo]: https://zenodo.org
71
+
72
+ [contribution guidelines]: https://github.com/larsrollik/templatepy/blob/main/CONTRIBUTING.md
73
+ [issues]: https://github.com/larsrollik/templatepy/issues
74
+ [BSD 3-Clause License]: https://github.com/larsrollik/templatepy/blob/main/LICENSE
75
+ [Github]: https://github.com/larsrollik/templatepy/settings/secrets/actions/new
76
+ [release]: https://github.com/larsrollik/templatepy/releases/new
77
+
78
+ [//]: # (Badges)
79
+
80
+ [![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/larsrollik/templatepy/blob/main/CONTRIBUTING.md)
81
+ [![DOI](https://zenodo.org/badge/370470893.svg)](https://zenodo.org/badge/latestdoi/370470893)
82
+ [![Website](https://img.shields.io/website?up_message=online&url=https%3A%2F%2Fgithub.com/larsrollik/templatepy)](https://github.com/larsrollik/templatepy)
83
+ [![PyPI](https://img.shields.io/pypi/v/templatepy.svg)](https://pypi.org/project/templatepy)
84
+ [![Wheel](https://img.shields.io/pypi/wheel/templatepy.svg)](https://pypi.org/project/templatepy)
85
+ ![CI](https://github.com/larsrollik/templatepy/workflows/tests/badge.svg)
86
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
87
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
88
+
89
+
90
+ # templatepy
91
+ Template repo for python repositories & PyPi integration
92
+ ---
93
+ **Version: "0.2.0"**
94
+
95
+
96
+ ## Usage
97
+ 1. **Change** files according to overview in `TODO` below
98
+ 2. **Develop** package...
99
+ 3. **Install** package:
100
+ - static/normal install: `pip install .`
101
+ - editable install:`pip install -e .`
102
+ - dev install: `pip install -e .[dev]` (some terminals require to escape brackets with ` \ ` as `\[`, esp. zsh)
103
+
104
+
105
+
106
+ ## File overview
107
+
108
+
109
+ ### General
110
+ - `LICENSE`: license text
111
+
112
+ - `README.md`: [Github-flavored markdown] file
113
+
114
+ - `templatepy`: placeholder folder for any python package that is configured for install via `setup.cfg` and `pyproject.toml`
115
+ - `__init__.py`: contains basic package info and example function that is called by console entrypoint (see `setup.cfg`)
116
+ - `example.data.file.config`: a file to demonstrate that data files are included based on `setup.cfg` criteria
117
+ - `example.data.file.test-extension-yu48`: a file to demonstrate data exclusion via `setup.py`
118
+
119
+
120
+ ### Testing
121
+ - `tests`: placeholder folder for unit/integration tests and associated data
122
+ - `pytest.ini`: config for testing framework with `pytest` and `coverage` plugin (`pytest-cov`)
123
+
124
+
125
+ ### Packaging System (see: [packaging] and [pyproject.toml])
126
+
127
+ - **`MANIFEST.in`**:
128
+ Defines additional files to include/exclude in the build (if not automatically detected).
129
+
130
+ - **`pyproject.toml`**:
131
+ Central configuration file that replaces the traditional `setup.cfg` and `setup.py` files:
132
+ - **Build System**: Specifies the build system requirements and configuration, as defined in [PEP 518](https://peps.python.org/pep-0518/) and [PEP 621](https://peps.python.org/pep-0621/).
133
+ - **Package Metadata**: Includes the project's metadata (name, version, dependencies, etc.).
134
+ - **Code Formatting**: Configuration for tools like [black] and [flake8] (if used).
135
+ - **Optional Dependencies**: Organizes extra dependencies for development or other environments.
136
+
137
+ - **`setup.py`**:
138
+ Legacy file retained only for backward compatibility if needed (e.g., older tooling). New projects should avoid it entirely.
139
+
140
+
141
+ ## CI Workflow Overview
142
+
143
+ The CI workflow is triggered on push to `main` or when a tag is created. It ensures code quality and automates the release process:
144
+
145
+ 1. **Linting and Testing**:
146
+ - `lint`: Checks code style with `black` and `flake8`, runs pre-commit hooks.
147
+ - `test`: Runs tests with `pytest` and generates coverage reports.
148
+
149
+ 2. **Tag Validation**:
150
+ - `check-tag`: Verifies that the tag is valid (not `dev` or `rc`) before proceeding.
151
+
152
+ 3. **Release Creation**:
153
+ - `release`: Creates a GitHub release when the tag is valid.
154
+
155
+ 4. **Deployment to PyPI**:
156
+ - `deploy`: Builds and uploads the package to PyPI using `twine`.
157
+
158
+ The pipeline ensures code quality, passing tests, and automated deployment on new releases.
159
+
160
+ ### Testing CI Locally
161
+
162
+ - Install `act`:
163
+ - **macOS/Linux**: `brew install act` / `sudo apt install act`
164
+ - **Windows**: Download from [act GitHub Releases](https://github.com/nektos/act/releases) and follow the installation instructions.
165
+ - Ensure Docker is installed and running. Download from [Docker Desktop](https://www.docker.com/products/docker).
166
+ - Run the CI workflow with `act`:
167
+ ```bash
168
+ act push
169
+ act push --verbose # very verbose output !
170
+ ```
171
+
172
+
173
+ ### Code maintenance (linting/formatting/github)
174
+ - `.pre-commit-config.yaml`: use [pre-commit] to run code formatting (e.g. with [black] and `flake8`) and PEP compliance checks
175
+ - Install pre-commit hook with `pre-commit install` (Note: only installs it in the current virtual environment)
176
+ - Run it manually with `pre-commit run --all` or leave it to run on commit (requires to re-stage changed files!)
177
+
178
+ - `.github`: folder that contains github automation workflows and issues templates
179
+
180
+ - `.gitignore`: ignored files/folders in git tools
181
+
182
+ - `.bumpversion.cfg`: config for [bump2version]
183
+
184
+ ## TODO for **adapting** template to new project
185
+
186
+ - [ ] Change package name:
187
+ - (1) Rename the `templatepy` folder.
188
+ - (2) Update all occurrences in `README.md`.
189
+ - (3) Update the `name` field in `pyproject.toml`.
190
+ - (4) Update `.github/workflows` files.
191
+ - (5) Update version references in `pyproject.toml` and `templatepy/__init__.py`.
192
+ - [ ] Update project author and metadata details in `pyproject.toml`, `README.md`, and `templatepy/__init__.py`.
193
+ - [ ] Update the license holder in the `LICENSE` file.
194
+ - [ ] Update `README.md` badge paths at the top.
195
+ - [ ] Verify inclusions/exclusions of installable files/folders in `MANIFEST.in` and `pyproject.toml` under `[tool.setuptools]`.
196
+ - [ ] Ensure `.gitignore` contains relevant entries for the new project.
197
+ - [ ] Add all version string locations to `[tool.bump2version]` in `pyproject.toml`.
198
+ - Use syntax like `[bumpversion:file:templatepy/__init__.py]` to specify locations for version updates.
199
+ - [ ] To upload to [PyPI], follow the instructions in the section below.
200
+ - [ ] To upload to [Zenodo] (if the repository is for a publication):
201
+ - (1) Connect Zenodo to your GitHub account.
202
+ - (2) Enable Zenodo integration for the repository (Zenodo requires the repository to be **public**).
203
+ - (3) Create a new GitHub release (manually or via `.github/workflows/CI.yaml`).
204
+ - (4) Wait for Zenodo to sync and assign a DOI (this usually takes about a minute).
205
+ - (5) Add the DOI badge to `README.md`.
206
+
207
+
208
+ ## Workflow for Automatically Uploading Package to [PyPI] or [Test PyPI]
209
+
210
+ 1. **Generate a PyPI API Key**:
211
+ - Go to [PyPI](https://pypi.org/) and create a new API key, either specific to the repository or a general-purpose key.
212
+
213
+ 2. **Add the API Key to GitHub**:
214
+ - In your repository's settings on [GitHub](https://github.com/):
215
+ - Navigate to **Settings > Secrets and variables > Actions**.
216
+ - Add a new **Actions secret** with the name `TWINE_API_KEY`.
217
+ - Paste the PyPI API key into the secret's value field.
218
+
219
+ 3. **Create a New Release**:
220
+ - On [GitHub](https://github.com/), create a new release manually via the **Releases** page.
221
+ - Use a version number without a release extension (e.g., `x.y.z`).
222
+ - Alternatively, trigger the GitHub workflow configured for releasing by incrementing the version with `bump2version` (see info below)
223
+ - Desperately, manually update the version strings in the relevant files and add git commit tag to trigger the release workflow on push
224
+
225
+ The package will then be automatically uploaded to [PyPI](https://pypi.org/) or [Test PyPI](https://test.pypi.org/) as configured in your CI/CD workflow.
226
+
227
+
228
+ ## Using `bump2version` for Versioning
229
+
230
+ `bump2version` is used to increment version numbers based on semantic versioning. Here’s how you can use it with the current setup to trigger a release:
231
+
232
+ 1. **Bumping the Minor Version**:
233
+ Increment the minor version (e.g., from `1.2.3` to `1.3.0`):
234
+ ```bash
235
+ # Bumping the minor Version:
236
+ bump2version minor
237
+
238
+ # Bumping the major version (e.g., from 1.2.3 to 2.0.0):
239
+ bump2version major
240
+
241
+ # Bumping for a release Version (e.g., from 1.0.0.dev to 1.0.0.rc or 1.0.0):
242
+ bump2version release
243
+ ```
244
+
245
+ ## Notes
246
+
247
+ #### New(er) Build System with `pyproject.toml` and `setup.cfg`
248
+
249
+ Historically, packaging in Python was governed by standards such as `PEP-426`, `PEP-517`, and `PEP-518`. These PEPs introduced various mechanisms for packaging and building Python projects, but with certain limitations, especially regarding flexibility and future-proofing.
250
+
251
+ - **PEP-426**: Introduced the `setup.cfg` and `setup.py` files as the standard way to define package metadata and build configuration.
252
+ - **PEP-517**: Introduced a standardized interface for building Python projects, separating the build process from the packaging process and allowing for more flexible build systems.
253
+ - **PEP-518**: Defined how `pyproject.toml` should be used to declare build dependencies and system requirements, allowing tools like `pip` to know which backend to use for the build process.
254
+
255
+ While these PEPs were important milestones, the latest changes to the packaging ecosystem make `pyproject.toml` the preferred way to configure projects going forward.
256
+
257
+ - **`pip`**:
258
+ - Tested with `pip install . --use-feature=in-tree-build` for forward compatibility with `pip 21.3` and later.
259
+ - While `setup.py` is technically optional, an empty `setup.py` is still kept for enabling editable installs (`pip install -e .`), as this requires such a file for now.
260
+ - `wheel` is added as a build-system dependency to maintain compatibility with versions of `pip` that do not yet fully implement `PEP 517`.
261
+
262
+ - **Replacing `setup.cfg` and `setup.py` with `pyproject.toml`**:
263
+ - In the modern packaging ecosystem, `pyproject.toml` is increasingly the standard for declaring build systems, dependencies, and metadata. This configuration file simplifies the process and eliminates the need for separate `setup.py` and `setup.cfg` files in many cases.
264
+
265
+ For further reading on the transition to `pyproject.toml` and the removal of `setup.py`/`setup.cfg`, see the following discussions:
266
+ - [PEP-426](https://peps.python.org/pep-0426/)
267
+ - [PEP-517](https://peps.python.org/pep-0517/)
268
+ - [PEP-518](https://peps.python.org/pep-0518/)
269
+ - [Discussion on Setup.cfg Deprecation](https://stackoverflow.com/questions/44878600/is-setup-cfg-deprecated)
270
+
271
+
272
+ ## Common issues
273
+
274
+ ### `bump2version` fails on git tag with exit status 128
275
+
276
+ - check a signing key is configured: `git config --global user.signingkey` (see below for generating a key)
277
+ - repo is a detached HEAD? check out a branch: `git checkout main`
278
+ - there are changes that need to be committed? `git commit -am "commit message"`
279
+ - tag already exists? `git tag` to list tags, `git tag -d <tag>` to delete a tag
280
+
281
+ ### no gpg key for signing commits
282
+ - generate a key with `gpg --full-generate-key`
283
+ - list keys with `gpg --list-secret-keys --keyid-format LONG`
284
+ - set the key for signing commits with `git config --global user.signingkey <key-id>`
285
+ - enable signing commits with `git config --global commit.gpgsign true`
286
+ - set the key for signing tags with `git config --global tag.gpgSign true`
287
+ - export the public key with `gpg --armor --export <key-id>`
288
+ - and add it to your GitHub account: select 'New key' -> paste output of command above
289
+
290
+ Which one is the key id you might ask?
291
+ ```
292
+ /home/user/.gnupg/secring.gpg
293
+ ------------------------------
294
+ sec 4096R/<KEY_ID> 2024-11-22 [expires: 2025-11-22]
295
+ uid Your Name <youremail@example.com>
296
+ ssb 4096R/<KEY_SUBKEY_ID> 2024-11-22
297
+
298
+ ```
299
+
300
+ ### GPG hangs/errors and never asks for passphrase of key?
301
+
302
+ - try: `export GPG_TTY=$(tty)`
303
+
304
+
305
+ ## Contributing
306
+ Contributions are very welcome!
307
+ Please see the [contribution guidelines] or check out the [issues]
308
+
309
+ ## License
310
+ This software is released under the **[BSD 3-Clause License]**
@@ -0,0 +1,255 @@
1
+ [//]: # (Links)
2
+ [Github-flavored markdown]: https://github.github.com/gfm
3
+
4
+ [manifest]: https://packaging.python.org/en/latest/guides/using-manifest-in
5
+ [packaging]: https://packaging.python.org/en/latest/tutorials/packaging-projects
6
+ [setup.cfg]: https://setuptools.pypa.io/en/latest/userguide/declarative_config.html
7
+
8
+ [bump2version]: (https://github.com/c4urself/bump2version
9
+ [pre-commit]: https://pre-commit.com
10
+ [black]: https://github.com/psf/black
11
+
12
+ [pypi]: pypi.org
13
+ [test.pypi]: test.pypi.org
14
+
15
+ [Zenodo]: https://zenodo.org
16
+
17
+ [contribution guidelines]: https://github.com/larsrollik/templatepy/blob/main/CONTRIBUTING.md
18
+ [issues]: https://github.com/larsrollik/templatepy/issues
19
+ [BSD 3-Clause License]: https://github.com/larsrollik/templatepy/blob/main/LICENSE
20
+ [Github]: https://github.com/larsrollik/templatepy/settings/secrets/actions/new
21
+ [release]: https://github.com/larsrollik/templatepy/releases/new
22
+
23
+ [//]: # (Badges)
24
+
25
+ [![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/larsrollik/templatepy/blob/main/CONTRIBUTING.md)
26
+ [![DOI](https://zenodo.org/badge/370470893.svg)](https://zenodo.org/badge/latestdoi/370470893)
27
+ [![Website](https://img.shields.io/website?up_message=online&url=https%3A%2F%2Fgithub.com/larsrollik/templatepy)](https://github.com/larsrollik/templatepy)
28
+ [![PyPI](https://img.shields.io/pypi/v/templatepy.svg)](https://pypi.org/project/templatepy)
29
+ [![Wheel](https://img.shields.io/pypi/wheel/templatepy.svg)](https://pypi.org/project/templatepy)
30
+ ![CI](https://github.com/larsrollik/templatepy/workflows/tests/badge.svg)
31
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
32
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
33
+
34
+
35
+ # templatepy
36
+ Template repo for python repositories & PyPi integration
37
+ ---
38
+ **Version: "0.2.0"**
39
+
40
+
41
+ ## Usage
42
+ 1. **Change** files according to overview in `TODO` below
43
+ 2. **Develop** package...
44
+ 3. **Install** package:
45
+ - static/normal install: `pip install .`
46
+ - editable install:`pip install -e .`
47
+ - dev install: `pip install -e .[dev]` (some terminals require to escape brackets with ` \ ` as `\[`, esp. zsh)
48
+
49
+
50
+
51
+ ## File overview
52
+
53
+
54
+ ### General
55
+ - `LICENSE`: license text
56
+
57
+ - `README.md`: [Github-flavored markdown] file
58
+
59
+ - `templatepy`: placeholder folder for any python package that is configured for install via `setup.cfg` and `pyproject.toml`
60
+ - `__init__.py`: contains basic package info and example function that is called by console entrypoint (see `setup.cfg`)
61
+ - `example.data.file.config`: a file to demonstrate that data files are included based on `setup.cfg` criteria
62
+ - `example.data.file.test-extension-yu48`: a file to demonstrate data exclusion via `setup.py`
63
+
64
+
65
+ ### Testing
66
+ - `tests`: placeholder folder for unit/integration tests and associated data
67
+ - `pytest.ini`: config for testing framework with `pytest` and `coverage` plugin (`pytest-cov`)
68
+
69
+
70
+ ### Packaging System (see: [packaging] and [pyproject.toml])
71
+
72
+ - **`MANIFEST.in`**:
73
+ Defines additional files to include/exclude in the build (if not automatically detected).
74
+
75
+ - **`pyproject.toml`**:
76
+ Central configuration file that replaces the traditional `setup.cfg` and `setup.py` files:
77
+ - **Build System**: Specifies the build system requirements and configuration, as defined in [PEP 518](https://peps.python.org/pep-0518/) and [PEP 621](https://peps.python.org/pep-0621/).
78
+ - **Package Metadata**: Includes the project's metadata (name, version, dependencies, etc.).
79
+ - **Code Formatting**: Configuration for tools like [black] and [flake8] (if used).
80
+ - **Optional Dependencies**: Organizes extra dependencies for development or other environments.
81
+
82
+ - **`setup.py`**:
83
+ Legacy file retained only for backward compatibility if needed (e.g., older tooling). New projects should avoid it entirely.
84
+
85
+
86
+ ## CI Workflow Overview
87
+
88
+ The CI workflow is triggered on push to `main` or when a tag is created. It ensures code quality and automates the release process:
89
+
90
+ 1. **Linting and Testing**:
91
+ - `lint`: Checks code style with `black` and `flake8`, runs pre-commit hooks.
92
+ - `test`: Runs tests with `pytest` and generates coverage reports.
93
+
94
+ 2. **Tag Validation**:
95
+ - `check-tag`: Verifies that the tag is valid (not `dev` or `rc`) before proceeding.
96
+
97
+ 3. **Release Creation**:
98
+ - `release`: Creates a GitHub release when the tag is valid.
99
+
100
+ 4. **Deployment to PyPI**:
101
+ - `deploy`: Builds and uploads the package to PyPI using `twine`.
102
+
103
+ The pipeline ensures code quality, passing tests, and automated deployment on new releases.
104
+
105
+ ### Testing CI Locally
106
+
107
+ - Install `act`:
108
+ - **macOS/Linux**: `brew install act` / `sudo apt install act`
109
+ - **Windows**: Download from [act GitHub Releases](https://github.com/nektos/act/releases) and follow the installation instructions.
110
+ - Ensure Docker is installed and running. Download from [Docker Desktop](https://www.docker.com/products/docker).
111
+ - Run the CI workflow with `act`:
112
+ ```bash
113
+ act push
114
+ act push --verbose # very verbose output !
115
+ ```
116
+
117
+
118
+ ### Code maintenance (linting/formatting/github)
119
+ - `.pre-commit-config.yaml`: use [pre-commit] to run code formatting (e.g. with [black] and `flake8`) and PEP compliance checks
120
+ - Install pre-commit hook with `pre-commit install` (Note: only installs it in the current virtual environment)
121
+ - Run it manually with `pre-commit run --all` or leave it to run on commit (requires to re-stage changed files!)
122
+
123
+ - `.github`: folder that contains github automation workflows and issues templates
124
+
125
+ - `.gitignore`: ignored files/folders in git tools
126
+
127
+ - `.bumpversion.cfg`: config for [bump2version]
128
+
129
+ ## TODO for **adapting** template to new project
130
+
131
+ - [ ] Change package name:
132
+ - (1) Rename the `templatepy` folder.
133
+ - (2) Update all occurrences in `README.md`.
134
+ - (3) Update the `name` field in `pyproject.toml`.
135
+ - (4) Update `.github/workflows` files.
136
+ - (5) Update version references in `pyproject.toml` and `templatepy/__init__.py`.
137
+ - [ ] Update project author and metadata details in `pyproject.toml`, `README.md`, and `templatepy/__init__.py`.
138
+ - [ ] Update the license holder in the `LICENSE` file.
139
+ - [ ] Update `README.md` badge paths at the top.
140
+ - [ ] Verify inclusions/exclusions of installable files/folders in `MANIFEST.in` and `pyproject.toml` under `[tool.setuptools]`.
141
+ - [ ] Ensure `.gitignore` contains relevant entries for the new project.
142
+ - [ ] Add all version string locations to `[tool.bump2version]` in `pyproject.toml`.
143
+ - Use syntax like `[bumpversion:file:templatepy/__init__.py]` to specify locations for version updates.
144
+ - [ ] To upload to [PyPI], follow the instructions in the section below.
145
+ - [ ] To upload to [Zenodo] (if the repository is for a publication):
146
+ - (1) Connect Zenodo to your GitHub account.
147
+ - (2) Enable Zenodo integration for the repository (Zenodo requires the repository to be **public**).
148
+ - (3) Create a new GitHub release (manually or via `.github/workflows/CI.yaml`).
149
+ - (4) Wait for Zenodo to sync and assign a DOI (this usually takes about a minute).
150
+ - (5) Add the DOI badge to `README.md`.
151
+
152
+
153
+ ## Workflow for Automatically Uploading Package to [PyPI] or [Test PyPI]
154
+
155
+ 1. **Generate a PyPI API Key**:
156
+ - Go to [PyPI](https://pypi.org/) and create a new API key, either specific to the repository or a general-purpose key.
157
+
158
+ 2. **Add the API Key to GitHub**:
159
+ - In your repository's settings on [GitHub](https://github.com/):
160
+ - Navigate to **Settings > Secrets and variables > Actions**.
161
+ - Add a new **Actions secret** with the name `TWINE_API_KEY`.
162
+ - Paste the PyPI API key into the secret's value field.
163
+
164
+ 3. **Create a New Release**:
165
+ - On [GitHub](https://github.com/), create a new release manually via the **Releases** page.
166
+ - Use a version number without a release extension (e.g., `x.y.z`).
167
+ - Alternatively, trigger the GitHub workflow configured for releasing by incrementing the version with `bump2version` (see info below)
168
+ - Desperately, manually update the version strings in the relevant files and add git commit tag to trigger the release workflow on push
169
+
170
+ The package will then be automatically uploaded to [PyPI](https://pypi.org/) or [Test PyPI](https://test.pypi.org/) as configured in your CI/CD workflow.
171
+
172
+
173
+ ## Using `bump2version` for Versioning
174
+
175
+ `bump2version` is used to increment version numbers based on semantic versioning. Here’s how you can use it with the current setup to trigger a release:
176
+
177
+ 1. **Bumping the Minor Version**:
178
+ Increment the minor version (e.g., from `1.2.3` to `1.3.0`):
179
+ ```bash
180
+ # Bumping the minor Version:
181
+ bump2version minor
182
+
183
+ # Bumping the major version (e.g., from 1.2.3 to 2.0.0):
184
+ bump2version major
185
+
186
+ # Bumping for a release Version (e.g., from 1.0.0.dev to 1.0.0.rc or 1.0.0):
187
+ bump2version release
188
+ ```
189
+
190
+ ## Notes
191
+
192
+ #### New(er) Build System with `pyproject.toml` and `setup.cfg`
193
+
194
+ Historically, packaging in Python was governed by standards such as `PEP-426`, `PEP-517`, and `PEP-518`. These PEPs introduced various mechanisms for packaging and building Python projects, but with certain limitations, especially regarding flexibility and future-proofing.
195
+
196
+ - **PEP-426**: Introduced the `setup.cfg` and `setup.py` files as the standard way to define package metadata and build configuration.
197
+ - **PEP-517**: Introduced a standardized interface for building Python projects, separating the build process from the packaging process and allowing for more flexible build systems.
198
+ - **PEP-518**: Defined how `pyproject.toml` should be used to declare build dependencies and system requirements, allowing tools like `pip` to know which backend to use for the build process.
199
+
200
+ While these PEPs were important milestones, the latest changes to the packaging ecosystem make `pyproject.toml` the preferred way to configure projects going forward.
201
+
202
+ - **`pip`**:
203
+ - Tested with `pip install . --use-feature=in-tree-build` for forward compatibility with `pip 21.3` and later.
204
+ - While `setup.py` is technically optional, an empty `setup.py` is still kept for enabling editable installs (`pip install -e .`), as this requires such a file for now.
205
+ - `wheel` is added as a build-system dependency to maintain compatibility with versions of `pip` that do not yet fully implement `PEP 517`.
206
+
207
+ - **Replacing `setup.cfg` and `setup.py` with `pyproject.toml`**:
208
+ - In the modern packaging ecosystem, `pyproject.toml` is increasingly the standard for declaring build systems, dependencies, and metadata. This configuration file simplifies the process and eliminates the need for separate `setup.py` and `setup.cfg` files in many cases.
209
+
210
+ For further reading on the transition to `pyproject.toml` and the removal of `setup.py`/`setup.cfg`, see the following discussions:
211
+ - [PEP-426](https://peps.python.org/pep-0426/)
212
+ - [PEP-517](https://peps.python.org/pep-0517/)
213
+ - [PEP-518](https://peps.python.org/pep-0518/)
214
+ - [Discussion on Setup.cfg Deprecation](https://stackoverflow.com/questions/44878600/is-setup-cfg-deprecated)
215
+
216
+
217
+ ## Common issues
218
+
219
+ ### `bump2version` fails on git tag with exit status 128
220
+
221
+ - check a signing key is configured: `git config --global user.signingkey` (see below for generating a key)
222
+ - repo is a detached HEAD? check out a branch: `git checkout main`
223
+ - there are changes that need to be committed? `git commit -am "commit message"`
224
+ - tag already exists? `git tag` to list tags, `git tag -d <tag>` to delete a tag
225
+
226
+ ### no gpg key for signing commits
227
+ - generate a key with `gpg --full-generate-key`
228
+ - list keys with `gpg --list-secret-keys --keyid-format LONG`
229
+ - set the key for signing commits with `git config --global user.signingkey <key-id>`
230
+ - enable signing commits with `git config --global commit.gpgsign true`
231
+ - set the key for signing tags with `git config --global tag.gpgSign true`
232
+ - export the public key with `gpg --armor --export <key-id>`
233
+ - and add it to your GitHub account: select 'New key' -> paste output of command above
234
+
235
+ Which one is the key id you might ask?
236
+ ```
237
+ /home/user/.gnupg/secring.gpg
238
+ ------------------------------
239
+ sec 4096R/<KEY_ID> 2024-11-22 [expires: 2025-11-22]
240
+ uid Your Name <youremail@example.com>
241
+ ssb 4096R/<KEY_SUBKEY_ID> 2024-11-22
242
+
243
+ ```
244
+
245
+ ### GPG hangs/errors and never asks for passphrase of key?
246
+
247
+ - try: `export GPG_TTY=$(tty)`
248
+
249
+
250
+ ## Contributing
251
+ Contributions are very welcome!
252
+ Please see the [contribution guidelines] or check out the [issues]
253
+
254
+ ## License
255
+ This software is released under the **[BSD 3-Clause License]**
@@ -0,0 +1,84 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "templatepy"
7
+ version = "0.2.0"
8
+ authors = [
9
+ { name = "Lars B. Rollik", email = "L.B.Rollik@protonmail.com" }
10
+ ]
11
+ license = { file = "LICENSE" }
12
+ description = "templatepy: template for derivative python packages"
13
+ readme = { file = "README.md", content-type = "text/markdown" }
14
+ classifiers = [
15
+ "Intended Audience :: Developers",
16
+ "Topic :: Software Development :: Libraries :: Python Modules",
17
+ "License :: OSI Approved :: BSD License",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ # "Programming Language :: Python :: 3.12",
23
+ ]
24
+ requires-python = ">=3.10"
25
+ dependencies = [
26
+ "black"
27
+ ]
28
+
29
+ [project.urls]
30
+ Repository = "https://github.com/larsrollik/templatepy"
31
+ "Issue Tracker" = "https://github.com/larsrollik/templatepy/issues"
32
+
33
+
34
+ [project.optional-dependencies]
35
+ dev = [
36
+ "black",
37
+ "bump2version",
38
+ "pytest-cov", # implies: pytest, coverage dependencies
39
+ "pre-commit",
40
+ "flake8"
41
+ ]
42
+
43
+ [project.entry-points.console_scripts]
44
+ templatepy-entrypoint = "templatepy.__init__:run"
45
+
46
+ [tool.setuptools]
47
+ zip-safe = false
48
+ include-package-data = true
49
+
50
+ [tool.setuptools.packages.find]
51
+ where = [""]
52
+
53
+ [tool.setuptools.package-data]
54
+ "*" = ["*.config"]
55
+
56
+ [tool.pytest.ini_options]
57
+ addopts = "--cov=templatepy --cov-report=term-missing --maxfail=5"
58
+
59
+ [tool.black]
60
+ target-version = ["py310", "py311"] #, "py312"
61
+ skip-string-normalization = false
62
+ line-length = 79
63
+ include = '\\.pyi?$'
64
+ exclude = '''
65
+ /(
66
+ \.eggs
67
+ | \.git
68
+ | \.hg
69
+ | \.mypy_cache
70
+ | \.tox
71
+ | \.venv
72
+ | _build
73
+ | buck-out
74
+ | build
75
+ | dist
76
+ )/
77
+ '''
78
+
79
+ [tool.flake8]
80
+ ignore = ["E203", "E266", "E501", "W503", "F403", "F401"]
81
+ max-line-length = 79
82
+ max-complexity = 18
83
+ select = ["B", "C", "E", "F", "W", "T4", "B9"]
84
+ exclude = ["__init__.py", "build", "__pycache__", ".git", "tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -1,5 +1,5 @@
1
1
  __author__ = "Lars B. Rollik"
2
- __version__ = "0.0.2"
2
+ __version__ = "0.2.0"
3
3
 
4
4
 
5
5
  def run():