pyprefab 0.3.2__tar.gz → 0.4.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.
- pyprefab-0.4.0/.github/workflows/ci.yaml +110 -0
- pyprefab-0.3.2/.github/workflows/publish-pypi.yml → pyprefab-0.4.0/.github/workflows/publish-pypi.yaml +1 -1
- pyprefab-0.4.0/CHANGELOG.md +55 -0
- pyprefab-0.4.0/CONTRIBUTING.md +151 -0
- pyprefab-0.4.0/PKG-INFO +156 -0
- pyprefab-0.4.0/README.md +139 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/pyproject.toml +4 -1
- pyprefab-0.4.0/src/pyprefab/cli.py +138 -0
- pyprefab-0.4.0/src/pyprefab/templates/.github/workflows/ci.yaml.j2 +115 -0
- pyprefab-0.4.0/src/pyprefab/templates/.github/workflows/publish-pypi-test.yaml.j2 +76 -0
- pyprefab-0.4.0/src/pyprefab/templates/.github/workflows/publish-pypi.yaml.j2 +119 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab/templates/.gitignore.j2 +0 -1
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab/templates/.pre-commit-config.yaml.j2 +0 -2
- pyprefab-0.4.0/src/pyprefab/templates/CHANGELOG.md.j2 +6 -0
- pyprefab-0.4.0/src/pyprefab/templates/CONTRIBUTING.md.j2 +147 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab/templates/README.md.j2 +0 -1
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab/templates/pyproject.toml.j2 +4 -5
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab/templates/src/{{ project_name }}/__init__.py.j2 +0 -1
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab/templates/src/{{ project_name }}/app.py.j2 +0 -1
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab/templates/test/test_app.py +0 -1
- pyprefab-0.4.0/src/pyprefab.egg-info/PKG-INFO +156 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab.egg-info/SOURCES.txt +12 -4
- pyprefab-0.4.0/test/test_cli.py +80 -0
- pyprefab-0.4.0/test/test_templates.py +102 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/uv.lock +87 -7
- pyprefab-0.3.2/.github/workflows/pythonapp-workflow.yml +0 -32
- pyprefab-0.3.2/PKG-INFO +0 -123
- pyprefab-0.3.2/README.md +0 -107
- pyprefab-0.3.2/src/pyprefab/cli.py +0 -90
- pyprefab-0.3.2/src/pyprefab.egg-info/PKG-INFO +0 -123
- pyprefab-0.3.2/test/test_pyprefab.py +0 -2
- /pyprefab-0.3.2/.github/workflows/publish-pypi-test.yml → /pyprefab-0.4.0/.github/workflows/publish-pypi-test.yaml +0 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/.gitignore +0 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/.pre-commit-config.yaml +0 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/.python-version +0 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/LICENSE +0 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/setup.cfg +0 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab/__init__.py +0 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab.egg-info/dependency_links.txt +0 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab.egg-info/entry_points.txt +0 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab.egg-info/requires.txt +0 -0
- {pyprefab-0.3.2 → pyprefab-0.4.0}/src/pyprefab.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
env:
|
|
11
|
+
FORCE_COLOR: "1"
|
|
12
|
+
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
|
13
|
+
PIP_NO_PYTHON_VERSION_WARNING: "1"
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
|
|
17
|
+
lint:
|
|
18
|
+
name: Run linter
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout 🛎️
|
|
23
|
+
uses: actions/checkout@v4
|
|
24
|
+
with:
|
|
25
|
+
persist-credentials: false
|
|
26
|
+
|
|
27
|
+
- name: Install uv 🌟
|
|
28
|
+
uses: astral-sh/setup-uv@v5
|
|
29
|
+
with:
|
|
30
|
+
version: ">=0.0.1"
|
|
31
|
+
|
|
32
|
+
- name: Lint 🧹
|
|
33
|
+
run: |
|
|
34
|
+
uv tool install ruff
|
|
35
|
+
ruff check
|
|
36
|
+
|
|
37
|
+
tests:
|
|
38
|
+
name: Run tests
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
strategy:
|
|
41
|
+
matrix:
|
|
42
|
+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
43
|
+
|
|
44
|
+
steps:
|
|
45
|
+
- name: Checkout 🛎️
|
|
46
|
+
uses: actions/checkout@v4
|
|
47
|
+
with:
|
|
48
|
+
persist-credentials: false
|
|
49
|
+
|
|
50
|
+
- name: Install uv 🌟
|
|
51
|
+
uses: astral-sh/setup-uv@v5
|
|
52
|
+
with:
|
|
53
|
+
python-version: ${{ matrix.python-version }}
|
|
54
|
+
version: ">=0.0.1"
|
|
55
|
+
|
|
56
|
+
- name: Test with python ${{ matrix.python-version }} 🧪
|
|
57
|
+
run: |
|
|
58
|
+
uv run --frozen coverage run \
|
|
59
|
+
--data-file .coverage.${{ matrix.python-version }} \
|
|
60
|
+
-m pytest
|
|
61
|
+
|
|
62
|
+
- name: Upload coverage data 📤
|
|
63
|
+
uses: actions/upload-artifact@v4
|
|
64
|
+
with:
|
|
65
|
+
name: coverage-data-${{ matrix.python-version }}
|
|
66
|
+
path: .coverage.*
|
|
67
|
+
include-hidden-files: true
|
|
68
|
+
if-no-files-found: ignore
|
|
69
|
+
|
|
70
|
+
coverage:
|
|
71
|
+
# https://hynek.me/articles/ditch-codecov-python/
|
|
72
|
+
name: Combine coverage reports & fail if below threshold
|
|
73
|
+
runs-on: ubuntu-latest
|
|
74
|
+
needs: tests
|
|
75
|
+
if: always()
|
|
76
|
+
|
|
77
|
+
steps:
|
|
78
|
+
- name: Checkout 🛎️
|
|
79
|
+
uses: actions/checkout@v4
|
|
80
|
+
with:
|
|
81
|
+
persist-credentials: false
|
|
82
|
+
|
|
83
|
+
- name: Install uv 🌟
|
|
84
|
+
uses: astral-sh/setup-uv@v5
|
|
85
|
+
with:
|
|
86
|
+
version: '>=0.0.1'
|
|
87
|
+
|
|
88
|
+
- name: Download coverage data 📥
|
|
89
|
+
uses: actions/download-artifact@v4
|
|
90
|
+
with:
|
|
91
|
+
pattern: coverage-data-*
|
|
92
|
+
merge-multiple: true
|
|
93
|
+
|
|
94
|
+
- name: Generate coverage report 📊
|
|
95
|
+
run: |
|
|
96
|
+
uv tool install 'coverage[toml]'
|
|
97
|
+
|
|
98
|
+
coverage combine
|
|
99
|
+
coverage html --skip-covered --skip-empty
|
|
100
|
+
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
|
|
101
|
+
|
|
102
|
+
# Generate report again, this time with a fail-under threshold
|
|
103
|
+
coverage report --fail-under=80
|
|
104
|
+
|
|
105
|
+
- name: Upload HTML report if coverage check fails
|
|
106
|
+
uses: actions/upload-artifact@v4
|
|
107
|
+
with:
|
|
108
|
+
name: html-cov-report
|
|
109
|
+
path: htmlcov
|
|
110
|
+
if: ${{ failure() }}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `pyprefab` are documented here.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com), and the project uses [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.4.0] - [2025-01-26]
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- New templates for GitHub workflows: ci (linting, tests, and coverage), publishing to TestPyPI, and publishing to PyPI
|
|
12
|
+
- Project changelog
|
|
13
|
+
- New CHANGELOG.md template
|
|
14
|
+
- New CONTRIBUTING.md template
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Add CLI prompts as an alternate to passing command options
|
|
19
|
+
- `--directory` option renamed to `--dir`
|
|
20
|
+
- Prompt user when specified project directory is not empty
|
|
21
|
+
- List created package components on README.md
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Correct CLI example on README.md
|
|
26
|
+
|
|
27
|
+
## [0.3.2] - [2025-01-13](https://github.com/bsweger/pyprefab/compare/v0.3.1...v0.3.2)
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Rename CLI command to `pyprefab`
|
|
32
|
+
|
|
33
|
+
## [0.3.1] - [2025-01-13](https://github.com/bsweger/pyprefab/compare/v0.3.0...v0.3.1)
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- New templates for generating Python package boilerplate: .gitignore, README.md, app.py
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- Rename project to `pyprefab`
|
|
42
|
+
|
|
43
|
+
### Removed
|
|
44
|
+
|
|
45
|
+
- Removed sample `hello_world` module in favor of template-driven boilerplate
|
|
46
|
+
|
|
47
|
+
## [0.3.0] - [2025-01-12](https://github.com/bsweger/pyprefab/compare/v0.2.1...v0.3.0)
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
|
|
51
|
+
- Added `pyproject.toml` template as the first piece of template-driven Python boilerplate
|
|
52
|
+
|
|
53
|
+
### Removed
|
|
54
|
+
|
|
55
|
+
- Removed artifacts from prior iteration of `pyprefab` that pre-dates the template-drive approach
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Contributing to pyprefab
|
|
2
|
+
|
|
3
|
+
This is a personal, very-part-time project, largely driven by my own opinions
|
|
4
|
+
about how best to configure a Python code base.
|
|
5
|
+
|
|
6
|
+
Contributions as described below are welcome.
|
|
7
|
+
|
|
8
|
+
## Reporting bugs
|
|
9
|
+
|
|
10
|
+
If something isn't working as described, or if you find a mistake in the
|
|
11
|
+
documentation, please feel free to report a bug by
|
|
12
|
+
[opening an issue](https://github.com/bsweger/pyprefab/issues).
|
|
13
|
+
|
|
14
|
+
## Contributing to the code base
|
|
15
|
+
|
|
16
|
+
Contributions to the code base are welcome. If you want to add a new feature,
|
|
17
|
+
please open an issue first. Because `pyprefab` is an opinion-drive personal
|
|
18
|
+
project, it's best to make sure our opinions are aligned before doing any work!
|
|
19
|
+
|
|
20
|
+
If you'd like to tackle an existing issue, please leave a comment on it.
|
|
21
|
+
|
|
22
|
+
### Creating your local development environment
|
|
23
|
+
|
|
24
|
+
For contributing to this code base, you'll need:
|
|
25
|
+
|
|
26
|
+
- A [GitHub account](https://github.com/)
|
|
27
|
+
- [Git](https://git-scm.com/) installed on your machine
|
|
28
|
+
- **optional**: [uv](https://docs.astral.sh/uv/getting-started/installation/)
|
|
29
|
+
(the Python-based directions below use `uv`, but if you
|
|
30
|
+
already have a preferred Python toolset, that should work too)
|
|
31
|
+
|
|
32
|
+
> [!IMPORTANT]
|
|
33
|
+
> If you have an active Python virtual environment (for example, conda's
|
|
34
|
+
> base environment), you'll need to deactivate it before following the
|
|
35
|
+
> instructions below.
|
|
36
|
+
|
|
37
|
+
#### Configure git
|
|
38
|
+
|
|
39
|
+
1. On GitHub, [fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) this repository.
|
|
40
|
+
|
|
41
|
+
2. Clone the forked repository to your machine:
|
|
42
|
+
|
|
43
|
+
```script
|
|
44
|
+
git clone https://github.com/<username>/pyprefab.git
|
|
45
|
+
cd pyprefab
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
3. **optional:** Set the `upstream` remote to sync your fork with the `pyprefab`
|
|
49
|
+
repository:
|
|
50
|
+
|
|
51
|
+
```script
|
|
52
|
+
git remote add upstream https://github.com/bsweger/pyprefab.git
|
|
53
|
+
git fetch upstream
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### Install project and dependencies
|
|
57
|
+
|
|
58
|
+
1. From the root of the repo, create a virtual environment and install the
|
|
59
|
+
project dependencies. The
|
|
60
|
+
[`uv sync` command](https://docs.astral.sh/uv/reference/cli/#uv-sync) handles
|
|
61
|
+
installing Python, creating a virtual environment, and installing project
|
|
62
|
+
dependencies.
|
|
63
|
+
|
|
64
|
+
```script
|
|
65
|
+
uv sync
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
(More information about how uv
|
|
69
|
+
[finds or downloads a Python interpreter](https://docs.astral.sh/uv/reference/cli/#uv-python))
|
|
70
|
+
|
|
71
|
+
2. Run the test suite to check that everything works correctly:
|
|
72
|
+
|
|
73
|
+
> [!TIP]
|
|
74
|
+
> Prefixing python commands with `uv run` instructs uv to run the command
|
|
75
|
+
> in the project's virtual environment, even if you haven't explicitly
|
|
76
|
+
> activated it.
|
|
77
|
+
|
|
78
|
+
```script
|
|
79
|
+
uv run pytest
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
3. Install the `pre-commit` hooks used for linting and other checks (this may
|
|
83
|
+
take a few minutes but only needs to be done once).
|
|
84
|
+
|
|
85
|
+
```script
|
|
86
|
+
uv run pre-commit install
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
4. Make sure the `pre-commit` checks are working correctly:
|
|
90
|
+
|
|
91
|
+
```script
|
|
92
|
+
uv run pre-commit install
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Updating your development environment
|
|
96
|
+
|
|
97
|
+
If time has passed between your initial project setup and when you make changes
|
|
98
|
+
to the code, make sure your fork and development environment are up-to-date.
|
|
99
|
+
|
|
100
|
+
1. Sync your fork to the upstream repository:
|
|
101
|
+
|
|
102
|
+
```script
|
|
103
|
+
git checkout main
|
|
104
|
+
git fetch upstream
|
|
105
|
+
git rebase upstream/main
|
|
106
|
+
git push origin main
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
2. Update your project dependencies:
|
|
110
|
+
|
|
111
|
+
```script
|
|
112
|
+
uv sync
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Adding project dependencies
|
|
116
|
+
|
|
117
|
+
If your change requires a new dependency, add it as follows:
|
|
118
|
+
|
|
119
|
+
```script
|
|
120
|
+
uv add <dependency>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The [`uv add`](https://docs.astral.sh/uv/reference/cli/#uv-add) command will:
|
|
124
|
+
|
|
125
|
+
- Add the dependency to `pyproject.toml`
|
|
126
|
+
- Install the dependency into the project's virtual environment
|
|
127
|
+
- Update the project's lockfile (`uv.lock`)
|
|
128
|
+
|
|
129
|
+
Make sure to commit the updated versions of `pyproject.toml` and `uv.lock`.
|
|
130
|
+
|
|
131
|
+
### Submitting code changes
|
|
132
|
+
|
|
133
|
+
After you've completed the changes described in the issue you're working on,
|
|
134
|
+
you can submit them by [creating a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) (PR) in the `pyprefab` repository.
|
|
135
|
+
|
|
136
|
+
Please ensure the following are true before creating the PR:
|
|
137
|
+
|
|
138
|
+
- Your change is covered by tests, if applicable
|
|
139
|
+
- All tests pass (`uv run pytest`)
|
|
140
|
+
- All pre-commit checks are successful
|
|
141
|
+
(these checks will run automatically as you make commits)
|
|
142
|
+
- The `[Unreleased]` section of [CHANGELOG.md](CHANGELOG.md) contains a
|
|
143
|
+
description of your change.
|
|
144
|
+
|
|
145
|
+
The PR itself should:
|
|
146
|
+
|
|
147
|
+
- Have a descriptive title
|
|
148
|
+
- Be [linked to its corresponding issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue)
|
|
149
|
+
in the description.
|
|
150
|
+
- Have a description that includes any other information or context that will
|
|
151
|
+
help a code reviewer understand your changes.
|
pyprefab-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: pyprefab
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Python application template for personal use
|
|
5
|
+
License: MIT License
|
|
6
|
+
Project-URL: Repository, https://github.com/bsweger/pyprefab.git
|
|
7
|
+
Project-URL: Changelog, https://github.com/bsweger/pyprefab/blob/main/CHANGELOG.md
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Requires-Python: <3.14,>=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: structlog
|
|
14
|
+
Requires-Dist: rich
|
|
15
|
+
Requires-Dist: typer
|
|
16
|
+
Requires-Dist: jinja2>=3.1.5
|
|
17
|
+
|
|
18
|
+
# pyprefab
|
|
19
|
+
|
|
20
|
+
A template-driven command line interface (CLI) that creates the scaffolding
|
|
21
|
+
for a fully-functional, modern Python package. The goal of pyprefab is to get
|
|
22
|
+
you straight to writing application code by handling project startup tasks
|
|
23
|
+
like logging setup and creating a test harness.
|
|
24
|
+
|
|
25
|
+
The scaffolding includes:
|
|
26
|
+
|
|
27
|
+
- project files in the [src layout](https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/) format
|
|
28
|
+
- `pyproject.toml` with [dependency groups](https://packaging.python.org/en/latest/specifications/dependency-groups/#dependency-groups)
|
|
29
|
+
- `CHANGELOG.md`, `CONTRIBUTING.md`, `.gitignore`, and `README.md`
|
|
30
|
+
- automated package versioning with [setuptools-scm](https://pypi.org/project/setuptools-scm/)
|
|
31
|
+
- [structlog](https://www.structlog.org/)-based pre-configured logging
|
|
32
|
+
- a [pytest](https://docs.pytest.org)-based test harness
|
|
33
|
+
- a [pre-commit](https://pre-commit.com/) configuration with common plugins like
|
|
34
|
+
[ruff](https://docs.astral.sh/ruff/) for linting (optional)
|
|
35
|
+
- GitHub workflow that automatically runs code checks, tests, and a test
|
|
36
|
+
coverage report
|
|
37
|
+
- GitHub workflows to publish the package to TestPyPI and PyPI
|
|
38
|
+
|
|
39
|
+
## Quickstart
|
|
40
|
+
|
|
41
|
+
If you have `uv` installed,
|
|
42
|
+
[`uv tool run`](https://docs.astral.sh/uv/reference/cli/#uv-tool-run) is the
|
|
43
|
+
fastest way to create a new Python package with pyprefab:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
uvx pyprefab <name-of-new-package>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Otherwise, use `pip` or `pipx` to install pyprefab:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
pip install pyprefab
|
|
53
|
+
|
|
54
|
+
pyprefab <name-of-new-package>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Details
|
|
58
|
+
|
|
59
|
+
### pyprefab CLI
|
|
60
|
+
|
|
61
|
+
By design, pyprefab requires only a few pieces of information to create the
|
|
62
|
+
boilerplate for a Python package.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
➜ pyprefab --help
|
|
66
|
+
|
|
67
|
+
Usage: pyprefab [OPTIONS] NAME
|
|
68
|
+
|
|
69
|
+
🐍 Create Python package boilerplate 🐍
|
|
70
|
+
|
|
71
|
+
╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
|
72
|
+
│ * name TEXT Name of the project │
|
|
73
|
+
│ [required] │
|
|
74
|
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
75
|
+
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
|
76
|
+
│ * --author TEXT Project author │
|
|
77
|
+
│ [required] │
|
|
78
|
+
│ * --description TEXT Project description │
|
|
79
|
+
│ [required] │
|
|
80
|
+
│ * --dir PATH Directory that will contain the project │
|
|
81
|
+
│ [required] │
|
|
82
|
+
│ --help Show this message and exit. │
|
|
83
|
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
For example:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
pyprefab project_test --author lassie --description "this is a pet project for lassie" --dir ~/code/lassie
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
If you don't explicitly pass the `--author`, `--description`, and `--dir` options,
|
|
93
|
+
pyprefab will prompt you for them:
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
➜ pyprefab project_test
|
|
97
|
+
Project author: lassie
|
|
98
|
+
Project description: this is a pet project for lassie
|
|
99
|
+
Project directory: /Users/dogs/code/lassie
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Creating a dev environment for the new package
|
|
103
|
+
|
|
104
|
+
Follow the steps below to create a development environment for Python packages
|
|
105
|
+
generated by pyprefab.
|
|
106
|
+
|
|
107
|
+
These directions use `uv`, but you can use your preferred tooling.
|
|
108
|
+
|
|
109
|
+
1. `cd` to the directory of the new Python package
|
|
110
|
+
|
|
111
|
+
2. Create a virtual environment and install the project dependencies:
|
|
112
|
+
|
|
113
|
+
```script
|
|
114
|
+
uv sync
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
3. Test the project setupt:
|
|
118
|
+
|
|
119
|
+
```script
|
|
120
|
+
uv run <your_package_name>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
You should see a log output stating that the project has been set up correctly.
|
|
124
|
+
|
|
125
|
+
For example:
|
|
126
|
+
`2025-01-13 02:29:08 [info ] project_test successfully created.`
|
|
127
|
+
|
|
128
|
+
You can also run the tests:
|
|
129
|
+
|
|
130
|
+
```script
|
|
131
|
+
uv run pytest
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Optional:**
|
|
135
|
+
|
|
136
|
+
- Add the new project to a git repository:
|
|
137
|
+
|
|
138
|
+
```script
|
|
139
|
+
git init
|
|
140
|
+
git add .
|
|
141
|
+
git commit -am "Initial commit"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- If you use [pre-commit](https://pre-commit.com/), pyprefab's boilerplate
|
|
145
|
+
includes a baseline `pre-commit-config.yaml` configuration. To use it, make
|
|
146
|
+
sure the project has been added to git (see above) and run the following
|
|
147
|
+
command to install the pre-commit git hook scripts:
|
|
148
|
+
|
|
149
|
+
```script
|
|
150
|
+
pre-commit install
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Contributing to pyprefab
|
|
154
|
+
|
|
155
|
+
Please refer to
|
|
156
|
+
[CONTRIBUTING.md](https://github.com/bsweger/pyprefab/blob/main/CONTRIBUTING.md).
|
pyprefab-0.4.0/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# pyprefab
|
|
2
|
+
|
|
3
|
+
A template-driven command line interface (CLI) that creates the scaffolding
|
|
4
|
+
for a fully-functional, modern Python package. The goal of pyprefab is to get
|
|
5
|
+
you straight to writing application code by handling project startup tasks
|
|
6
|
+
like logging setup and creating a test harness.
|
|
7
|
+
|
|
8
|
+
The scaffolding includes:
|
|
9
|
+
|
|
10
|
+
- project files in the [src layout](https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/) format
|
|
11
|
+
- `pyproject.toml` with [dependency groups](https://packaging.python.org/en/latest/specifications/dependency-groups/#dependency-groups)
|
|
12
|
+
- `CHANGELOG.md`, `CONTRIBUTING.md`, `.gitignore`, and `README.md`
|
|
13
|
+
- automated package versioning with [setuptools-scm](https://pypi.org/project/setuptools-scm/)
|
|
14
|
+
- [structlog](https://www.structlog.org/)-based pre-configured logging
|
|
15
|
+
- a [pytest](https://docs.pytest.org)-based test harness
|
|
16
|
+
- a [pre-commit](https://pre-commit.com/) configuration with common plugins like
|
|
17
|
+
[ruff](https://docs.astral.sh/ruff/) for linting (optional)
|
|
18
|
+
- GitHub workflow that automatically runs code checks, tests, and a test
|
|
19
|
+
coverage report
|
|
20
|
+
- GitHub workflows to publish the package to TestPyPI and PyPI
|
|
21
|
+
|
|
22
|
+
## Quickstart
|
|
23
|
+
|
|
24
|
+
If you have `uv` installed,
|
|
25
|
+
[`uv tool run`](https://docs.astral.sh/uv/reference/cli/#uv-tool-run) is the
|
|
26
|
+
fastest way to create a new Python package with pyprefab:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
uvx pyprefab <name-of-new-package>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Otherwise, use `pip` or `pipx` to install pyprefab:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
pip install pyprefab
|
|
36
|
+
|
|
37
|
+
pyprefab <name-of-new-package>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Details
|
|
41
|
+
|
|
42
|
+
### pyprefab CLI
|
|
43
|
+
|
|
44
|
+
By design, pyprefab requires only a few pieces of information to create the
|
|
45
|
+
boilerplate for a Python package.
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
➜ pyprefab --help
|
|
49
|
+
|
|
50
|
+
Usage: pyprefab [OPTIONS] NAME
|
|
51
|
+
|
|
52
|
+
🐍 Create Python package boilerplate 🐍
|
|
53
|
+
|
|
54
|
+
╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
|
55
|
+
│ * name TEXT Name of the project │
|
|
56
|
+
│ [required] │
|
|
57
|
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
58
|
+
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
|
59
|
+
│ * --author TEXT Project author │
|
|
60
|
+
│ [required] │
|
|
61
|
+
│ * --description TEXT Project description │
|
|
62
|
+
│ [required] │
|
|
63
|
+
│ * --dir PATH Directory that will contain the project │
|
|
64
|
+
│ [required] │
|
|
65
|
+
│ --help Show this message and exit. │
|
|
66
|
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
For example:
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
pyprefab project_test --author lassie --description "this is a pet project for lassie" --dir ~/code/lassie
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
If you don't explicitly pass the `--author`, `--description`, and `--dir` options,
|
|
76
|
+
pyprefab will prompt you for them:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
➜ pyprefab project_test
|
|
80
|
+
Project author: lassie
|
|
81
|
+
Project description: this is a pet project for lassie
|
|
82
|
+
Project directory: /Users/dogs/code/lassie
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Creating a dev environment for the new package
|
|
86
|
+
|
|
87
|
+
Follow the steps below to create a development environment for Python packages
|
|
88
|
+
generated by pyprefab.
|
|
89
|
+
|
|
90
|
+
These directions use `uv`, but you can use your preferred tooling.
|
|
91
|
+
|
|
92
|
+
1. `cd` to the directory of the new Python package
|
|
93
|
+
|
|
94
|
+
2. Create a virtual environment and install the project dependencies:
|
|
95
|
+
|
|
96
|
+
```script
|
|
97
|
+
uv sync
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
3. Test the project setupt:
|
|
101
|
+
|
|
102
|
+
```script
|
|
103
|
+
uv run <your_package_name>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
You should see a log output stating that the project has been set up correctly.
|
|
107
|
+
|
|
108
|
+
For example:
|
|
109
|
+
`2025-01-13 02:29:08 [info ] project_test successfully created.`
|
|
110
|
+
|
|
111
|
+
You can also run the tests:
|
|
112
|
+
|
|
113
|
+
```script
|
|
114
|
+
uv run pytest
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Optional:**
|
|
118
|
+
|
|
119
|
+
- Add the new project to a git repository:
|
|
120
|
+
|
|
121
|
+
```script
|
|
122
|
+
git init
|
|
123
|
+
git add .
|
|
124
|
+
git commit -am "Initial commit"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
- If you use [pre-commit](https://pre-commit.com/), pyprefab's boilerplate
|
|
128
|
+
includes a baseline `pre-commit-config.yaml` configuration. To use it, make
|
|
129
|
+
sure the project has been added to git (see above) and run the following
|
|
130
|
+
command to install the pre-commit git hook scripts:
|
|
131
|
+
|
|
132
|
+
```script
|
|
133
|
+
pre-commit install
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Contributing to pyprefab
|
|
137
|
+
|
|
138
|
+
Please refer to
|
|
139
|
+
[CONTRIBUTING.md](https://github.com/bsweger/pyprefab/blob/main/CONTRIBUTING.md).
|
|
@@ -3,7 +3,7 @@ name = 'pyprefab'
|
|
|
3
3
|
description = 'Python application template for personal use'
|
|
4
4
|
license = {text = 'MIT License'}
|
|
5
5
|
readme = 'README.md'
|
|
6
|
-
requires-python = '>=3.9'
|
|
6
|
+
requires-python = '>=3.9,<3.14'
|
|
7
7
|
classifiers = [
|
|
8
8
|
'Programming Language :: Python :: 3',
|
|
9
9
|
'License :: OSI Approved :: MIT License',
|
|
@@ -19,6 +19,7 @@ dependencies = [
|
|
|
19
19
|
|
|
20
20
|
[dependency-groups]
|
|
21
21
|
dev = [
|
|
22
|
+
'build',
|
|
22
23
|
'coverage',
|
|
23
24
|
'freezegun',
|
|
24
25
|
'mypy',
|
|
@@ -26,6 +27,7 @@ dev = [
|
|
|
26
27
|
'pytest',
|
|
27
28
|
"pytest-random-order>=1.1.1",
|
|
28
29
|
'ruff',
|
|
30
|
+
"tomli>=2.2.1",
|
|
29
31
|
]
|
|
30
32
|
|
|
31
33
|
[project.scripts]
|
|
@@ -33,6 +35,7 @@ pyprefab = "pyprefab.cli:app"
|
|
|
33
35
|
|
|
34
36
|
[project.urls]
|
|
35
37
|
Repository = "https://github.com/bsweger/pyprefab.git"
|
|
38
|
+
Changelog = "https://github.com/bsweger/pyprefab/blob/main/CHANGELOG.md"
|
|
36
39
|
|
|
37
40
|
[build-system]
|
|
38
41
|
# Minimum requirements for the build system to execute.
|