preen 0.1.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.
- preen-0.1.0/LICENSE +21 -0
- preen-0.1.0/PKG-INFO +303 -0
- preen-0.1.0/README.md +259 -0
- preen-0.1.0/preen/__init__.py +25 -0
- preen-0.1.0/preen/__main__.py +6 -0
- preen-0.1.0/preen/checks/__init__.py +10 -0
- preen-0.1.0/preen/checks/base.py +148 -0
- preen-0.1.0/preen/checks/ci_matrix.py +154 -0
- preen-0.1.0/preen/checks/citation.py +107 -0
- preen-0.1.0/preen/checks/codespell.py +216 -0
- preen-0.1.0/preen/checks/deps.py +114 -0
- preen-0.1.0/preen/checks/deptree.py +200 -0
- preen-0.1.0/preen/checks/links.py +202 -0
- preen-0.1.0/preen/checks/pydoclint.py +163 -0
- preen-0.1.0/preen/checks/pyright.py +177 -0
- preen-0.1.0/preen/checks/ruff.py +137 -0
- preen-0.1.0/preen/checks/runner.py +50 -0
- preen-0.1.0/preen/checks/structure.py +223 -0
- preen-0.1.0/preen/checks/tests.py +75 -0
- preen-0.1.0/preen/checks/version.py +205 -0
- preen-0.1.0/preen/cli.py +444 -0
- preen-0.1.0/preen/commands/__init__.py +1 -0
- preen-0.1.0/preen/commands/bump.py +243 -0
- preen-0.1.0/preen/commands/fix.py +133 -0
- preen-0.1.0/preen/commands/init.py +286 -0
- preen-0.1.0/preen/commands/release.py +194 -0
- preen-0.1.0/preen/config.py +117 -0
- preen-0.1.0/preen/interactive.py +182 -0
- preen-0.1.0/preen/syncer.py +561 -0
- preen-0.1.0/preen/templates/__init__.py +5 -0
- preen-0.1.0/preen/templates/manager.py +51 -0
- preen-0.1.0/preen.egg-info/PKG-INFO +303 -0
- preen-0.1.0/preen.egg-info/SOURCES.txt +38 -0
- preen-0.1.0/preen.egg-info/dependency_links.txt +1 -0
- preen-0.1.0/preen.egg-info/entry_points.txt +2 -0
- preen-0.1.0/preen.egg-info/requires.txt +19 -0
- preen-0.1.0/preen.egg-info/top_level.txt +1 -0
- preen-0.1.0/pyproject.toml +66 -0
- preen-0.1.0/setup.cfg +4 -0
- preen-0.1.0/tests/test_sync.py +75 -0
preen-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Gaurav Sood
|
|
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.
|
preen-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: preen
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An opinionated, agentic CLI for Python package hygiene and release
|
|
5
|
+
Author-email: Gaurav Sood <contact@gsood.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gojiplus/preen
|
|
8
|
+
Project-URL: Repository, https://github.com/gojiplus/preen
|
|
9
|
+
Project-URL: Documentation, https://gojiplus.github.io/preen
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/gojiplus/preen/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/gojiplus/preen/releases
|
|
12
|
+
Keywords: packaging,release,metadata,hygiene,cli,python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Development Status :: 3 - Alpha
|
|
20
|
+
Classifier: Intended Audience :: Developers
|
|
21
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: typer>=0.9
|
|
27
|
+
Requires-Dist: rich>=13.5
|
|
28
|
+
Requires-Dist: PyYAML>=6.0
|
|
29
|
+
Requires-Dist: Jinja2>=3.0
|
|
30
|
+
Requires-Dist: httpx>=0.24.0
|
|
31
|
+
Requires-Dist: pydoclint>=0.3.0
|
|
32
|
+
Requires-Dist: pyright>=1.1.350
|
|
33
|
+
Requires-Dist: codespell>=2.3.0
|
|
34
|
+
Requires-Dist: ruff>=0.14.0
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
38
|
+
Provides-Extra: docs
|
|
39
|
+
Requires-Dist: sphinx>=7.0; extra == "docs"
|
|
40
|
+
Requires-Dist: sphinx-rtd-theme>=2.0; extra == "docs"
|
|
41
|
+
Requires-Dist: myst-parser>=2.0; extra == "docs"
|
|
42
|
+
Requires-Dist: furo>=2024.0; extra == "docs"
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
|
|
45
|
+
# preen
|
|
46
|
+
|
|
47
|
+
[](https://badge.fury.io/py/preen)
|
|
48
|
+
[](https://github.com/gojiplus/preen/actions)
|
|
49
|
+
[](https://gojiplus.github.io/preen)
|
|
50
|
+
[](https://pepy.tech/project/preen)
|
|
51
|
+
|
|
52
|
+
**An opinionated, agentic CLI for Python package hygiene and release**
|
|
53
|
+
|
|
54
|
+
*"Get your feathers in order before you fly"*
|
|
55
|
+
|
|
56
|
+
`preen` is a comprehensive tool for Python package maintenance that treats `pyproject.toml` as the single source of truth. It automatically generates and synchronizes derived files, runs comprehensive pre-release checks, and provides an opinionated workflow for package development and release.
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
- 🔍 **12 comprehensive checks** - linting, tests, dependencies, CI matrix, project structure, version consistency, citation validation, link validation, documentation quality, static type checking, and spell checking
|
|
61
|
+
- 🔧 **Interactive fixes** - preview diffs and apply fixes automatically or selectively
|
|
62
|
+
- 📦 **Package initialization** - scaffold new packages with opinionated best practices
|
|
63
|
+
- 🔄 **File synchronization** - generate CI workflows, documentation config, and CITATION.cff from pyproject.toml
|
|
64
|
+
- 📈 **Version management** - semantic versioning with automatic derived file updates
|
|
65
|
+
- 🎯 **Modern tooling** - uv-native workflows, GitHub Actions, and trusted publishing
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install preen
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Requires Python 3.9+
|
|
74
|
+
|
|
75
|
+
## Quick Start
|
|
76
|
+
|
|
77
|
+
### Create a new package
|
|
78
|
+
```bash
|
|
79
|
+
preen init mypackage
|
|
80
|
+
cd mypackage
|
|
81
|
+
pip install -e .[dev]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Run checks and fixes
|
|
85
|
+
```bash
|
|
86
|
+
preen check # Interactive check with fix prompts
|
|
87
|
+
preen check --fix # Apply all fixes automatically
|
|
88
|
+
preen check --strict # Exit 1 if any issues (perfect for CI)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Sync derived files
|
|
92
|
+
```bash
|
|
93
|
+
preen sync # Update all derived files
|
|
94
|
+
preen sync --only citation # Update only CITATION.cff
|
|
95
|
+
preen sync --check # Check if files need updating (CI mode)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Manage versions
|
|
99
|
+
```bash
|
|
100
|
+
preen bump patch # 1.0.0 → 1.0.1
|
|
101
|
+
preen bump minor # 1.0.1 → 1.1.0
|
|
102
|
+
preen bump major # 1.1.0 → 2.0.0
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Commands
|
|
106
|
+
|
|
107
|
+
### `preen init`
|
|
108
|
+
Initialize new Python packages with opinionated structure:
|
|
109
|
+
- Modern `pyproject.toml` with setuptools backend
|
|
110
|
+
- `src/` layout for better import isolation
|
|
111
|
+
- Comprehensive `tests/` directory at project root
|
|
112
|
+
- GitHub Actions workflows for CI, docs, and release
|
|
113
|
+
- Pre-configured development dependencies (pytest, ruff)
|
|
114
|
+
- CITATION.cff for academic software
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
preen init mypackage # Interactive mode
|
|
118
|
+
preen init mypackage --dir ./custom # Specify directory
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### `preen check`
|
|
122
|
+
Run comprehensive pre-release checks:
|
|
123
|
+
|
|
124
|
+
| Check | Description |
|
|
125
|
+
|-------|-------------|
|
|
126
|
+
| **ruff** | Code linting and formatting |
|
|
127
|
+
| **tests** | Run pytest suite |
|
|
128
|
+
| **deps** | Find unused/missing dependencies (requires deptry) |
|
|
129
|
+
| **ci-matrix** | Verify CI tests all declared Python versions |
|
|
130
|
+
| **structure** | Enforce project structure best practices |
|
|
131
|
+
| **version** | Detect hardcoded version strings |
|
|
132
|
+
| **citation** | Ensure CITATION.cff matches pyproject.toml |
|
|
133
|
+
| **links** | Check for broken or dead links in project files |
|
|
134
|
+
| **pydoclint** | Check docstring quality and completeness |
|
|
135
|
+
| **pyright** | Static type checking for type safety |
|
|
136
|
+
| **codespell** | Check spelling in documentation and comments |
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
preen check # Interactive mode
|
|
140
|
+
preen check --fix # Auto-apply all fixes
|
|
141
|
+
preen check --only ruff,tests # Run specific checks
|
|
142
|
+
preen check --skip deps,links,pydoclint,pyright,codespell # Skip optional checks
|
|
143
|
+
preen check --strict # CI mode (exit 1 on issues)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### `preen sync`
|
|
147
|
+
Synchronize derived files from `pyproject.toml`:
|
|
148
|
+
- `.github/workflows/ci.yml` - CI matrix from Python classifiers
|
|
149
|
+
- `.github/workflows/docs.yml` - Documentation deployment
|
|
150
|
+
- `.github/workflows/release.yml` - PyPI publishing with trusted publisher
|
|
151
|
+
- `docs/conf.py` - Sphinx configuration
|
|
152
|
+
- `CITATION.cff` - Citation metadata for academic software
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
preen sync # Update all derived files
|
|
156
|
+
preen sync --only ci,citation # Update specific targets
|
|
157
|
+
preen sync --check # Verify files are up to date
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### `preen bump`
|
|
161
|
+
Semantic version management:
|
|
162
|
+
- Updates version in `pyproject.toml`
|
|
163
|
+
- Regenerates all derived files with new version
|
|
164
|
+
- Commits changes to git with conventional commit message
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
preen bump patch # Bug fixes: 1.0.0 → 1.0.1
|
|
168
|
+
preen bump minor # New features: 1.0.1 → 1.1.0
|
|
169
|
+
preen bump major # Breaking changes: 1.1.0 → 2.0.0
|
|
170
|
+
preen bump patch --dry-run # Preview changes
|
|
171
|
+
preen bump minor --no-commit # Skip git commit
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Configuration
|
|
175
|
+
|
|
176
|
+
Customize behavior in `pyproject.toml`:
|
|
177
|
+
|
|
178
|
+
```toml
|
|
179
|
+
[tool.preen]
|
|
180
|
+
# CI configuration
|
|
181
|
+
ci_os = ["ubuntu-latest", "macos-latest"]
|
|
182
|
+
ci_runner = "uv" # or "pip"
|
|
183
|
+
|
|
184
|
+
# Documentation
|
|
185
|
+
sphinx_theme = "furo"
|
|
186
|
+
use_myst = true
|
|
187
|
+
|
|
188
|
+
# Structure preferences
|
|
189
|
+
src_layout = true
|
|
190
|
+
tests_at_root = true
|
|
191
|
+
|
|
192
|
+
# Skip specific checks
|
|
193
|
+
skip_checks = ["deps", "structure"]
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Development Workflow
|
|
197
|
+
|
|
198
|
+
Typical workflow for package maintenance:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# 1. Initialize new package
|
|
202
|
+
preen init myawesome-package
|
|
203
|
+
cd myawesome-package
|
|
204
|
+
|
|
205
|
+
# 2. Develop your package
|
|
206
|
+
# ... write code, tests ...
|
|
207
|
+
|
|
208
|
+
# 3. Pre-release checks
|
|
209
|
+
preen check --fix
|
|
210
|
+
|
|
211
|
+
# 4. Version bump and release prep
|
|
212
|
+
preen bump minor
|
|
213
|
+
git push origin main
|
|
214
|
+
|
|
215
|
+
# 5. Manual steps (for now)
|
|
216
|
+
# - Create GitHub release
|
|
217
|
+
# - CI will build and publish to PyPI via trusted publisher
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Philosophy
|
|
221
|
+
|
|
222
|
+
**pyproject.toml as Single Source of Truth**
|
|
223
|
+
- All metadata lives in one place
|
|
224
|
+
- Derived files are generated, never edited manually
|
|
225
|
+
- Eliminates version mismatches and configuration drift
|
|
226
|
+
|
|
227
|
+
**Opinionated Best Practices**
|
|
228
|
+
- `src/` layout for better import isolation
|
|
229
|
+
- `tests/` at project root, not inside package
|
|
230
|
+
- Modern Python packaging (setuptools, trusted publishing)
|
|
231
|
+
- Comprehensive CI matrix matching declared Python support
|
|
232
|
+
|
|
233
|
+
**DRY Across Configuration**
|
|
234
|
+
- CI matrix generated from Python classifiers
|
|
235
|
+
- Documentation config reflects project metadata
|
|
236
|
+
- CITATION.cff stays in sync with authors and version
|
|
237
|
+
|
|
238
|
+
## Generated Files
|
|
239
|
+
|
|
240
|
+
When you run `preen sync`, these files are generated/updated:
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
.github/workflows/
|
|
244
|
+
├── ci.yml # Test matrix + linting
|
|
245
|
+
├── docs.yml # Documentation deployment
|
|
246
|
+
└── release.yml # PyPI publishing
|
|
247
|
+
|
|
248
|
+
docs/
|
|
249
|
+
└── conf.py # Sphinx configuration
|
|
250
|
+
|
|
251
|
+
CITATION.cff # Citation metadata
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
All generated files include a header indicating they're managed by preen:
|
|
255
|
+
```yaml
|
|
256
|
+
# Generated by preen — do not edit manually
|
|
257
|
+
# Regenerate with: preen sync
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Integration
|
|
261
|
+
|
|
262
|
+
**GitHub Actions**
|
|
263
|
+
```yaml
|
|
264
|
+
# .github/workflows/quality.yml
|
|
265
|
+
- name: Package hygiene
|
|
266
|
+
run: |
|
|
267
|
+
pip install preen
|
|
268
|
+
preen check --strict
|
|
269
|
+
preen sync --check
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Pre-commit Hook**
|
|
273
|
+
```yaml
|
|
274
|
+
# .pre-commit-config.yaml
|
|
275
|
+
repos:
|
|
276
|
+
- repo: local
|
|
277
|
+
hooks:
|
|
278
|
+
- id: preen-check
|
|
279
|
+
name: preen check
|
|
280
|
+
entry: preen check --strict
|
|
281
|
+
language: system
|
|
282
|
+
pass_filenames: false
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## License
|
|
286
|
+
|
|
287
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
288
|
+
|
|
289
|
+
## Contributing
|
|
290
|
+
|
|
291
|
+
1. Fork the repository
|
|
292
|
+
2. Create a feature branch
|
|
293
|
+
3. Make your changes
|
|
294
|
+
4. Run `preen check` to ensure code quality
|
|
295
|
+
5. Submit a pull request
|
|
296
|
+
|
|
297
|
+
For development setup:
|
|
298
|
+
```bash
|
|
299
|
+
git clone https://github.com/gojiplus/preen.git
|
|
300
|
+
cd preen
|
|
301
|
+
pip install -e .[dev]
|
|
302
|
+
preen check
|
|
303
|
+
```
|
preen-0.1.0/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# preen
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/preen)
|
|
4
|
+
[](https://github.com/gojiplus/preen/actions)
|
|
5
|
+
[](https://gojiplus.github.io/preen)
|
|
6
|
+
[](https://pepy.tech/project/preen)
|
|
7
|
+
|
|
8
|
+
**An opinionated, agentic CLI for Python package hygiene and release**
|
|
9
|
+
|
|
10
|
+
*"Get your feathers in order before you fly"*
|
|
11
|
+
|
|
12
|
+
`preen` is a comprehensive tool for Python package maintenance that treats `pyproject.toml` as the single source of truth. It automatically generates and synchronizes derived files, runs comprehensive pre-release checks, and provides an opinionated workflow for package development and release.
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- 🔍 **12 comprehensive checks** - linting, tests, dependencies, CI matrix, project structure, version consistency, citation validation, link validation, documentation quality, static type checking, and spell checking
|
|
17
|
+
- 🔧 **Interactive fixes** - preview diffs and apply fixes automatically or selectively
|
|
18
|
+
- 📦 **Package initialization** - scaffold new packages with opinionated best practices
|
|
19
|
+
- 🔄 **File synchronization** - generate CI workflows, documentation config, and CITATION.cff from pyproject.toml
|
|
20
|
+
- 📈 **Version management** - semantic versioning with automatic derived file updates
|
|
21
|
+
- 🎯 **Modern tooling** - uv-native workflows, GitHub Actions, and trusted publishing
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install preen
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Requires Python 3.9+
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
### Create a new package
|
|
34
|
+
```bash
|
|
35
|
+
preen init mypackage
|
|
36
|
+
cd mypackage
|
|
37
|
+
pip install -e .[dev]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Run checks and fixes
|
|
41
|
+
```bash
|
|
42
|
+
preen check # Interactive check with fix prompts
|
|
43
|
+
preen check --fix # Apply all fixes automatically
|
|
44
|
+
preen check --strict # Exit 1 if any issues (perfect for CI)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Sync derived files
|
|
48
|
+
```bash
|
|
49
|
+
preen sync # Update all derived files
|
|
50
|
+
preen sync --only citation # Update only CITATION.cff
|
|
51
|
+
preen sync --check # Check if files need updating (CI mode)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Manage versions
|
|
55
|
+
```bash
|
|
56
|
+
preen bump patch # 1.0.0 → 1.0.1
|
|
57
|
+
preen bump minor # 1.0.1 → 1.1.0
|
|
58
|
+
preen bump major # 1.1.0 → 2.0.0
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Commands
|
|
62
|
+
|
|
63
|
+
### `preen init`
|
|
64
|
+
Initialize new Python packages with opinionated structure:
|
|
65
|
+
- Modern `pyproject.toml` with setuptools backend
|
|
66
|
+
- `src/` layout for better import isolation
|
|
67
|
+
- Comprehensive `tests/` directory at project root
|
|
68
|
+
- GitHub Actions workflows for CI, docs, and release
|
|
69
|
+
- Pre-configured development dependencies (pytest, ruff)
|
|
70
|
+
- CITATION.cff for academic software
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
preen init mypackage # Interactive mode
|
|
74
|
+
preen init mypackage --dir ./custom # Specify directory
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### `preen check`
|
|
78
|
+
Run comprehensive pre-release checks:
|
|
79
|
+
|
|
80
|
+
| Check | Description |
|
|
81
|
+
|-------|-------------|
|
|
82
|
+
| **ruff** | Code linting and formatting |
|
|
83
|
+
| **tests** | Run pytest suite |
|
|
84
|
+
| **deps** | Find unused/missing dependencies (requires deptry) |
|
|
85
|
+
| **ci-matrix** | Verify CI tests all declared Python versions |
|
|
86
|
+
| **structure** | Enforce project structure best practices |
|
|
87
|
+
| **version** | Detect hardcoded version strings |
|
|
88
|
+
| **citation** | Ensure CITATION.cff matches pyproject.toml |
|
|
89
|
+
| **links** | Check for broken or dead links in project files |
|
|
90
|
+
| **pydoclint** | Check docstring quality and completeness |
|
|
91
|
+
| **pyright** | Static type checking for type safety |
|
|
92
|
+
| **codespell** | Check spelling in documentation and comments |
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
preen check # Interactive mode
|
|
96
|
+
preen check --fix # Auto-apply all fixes
|
|
97
|
+
preen check --only ruff,tests # Run specific checks
|
|
98
|
+
preen check --skip deps,links,pydoclint,pyright,codespell # Skip optional checks
|
|
99
|
+
preen check --strict # CI mode (exit 1 on issues)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### `preen sync`
|
|
103
|
+
Synchronize derived files from `pyproject.toml`:
|
|
104
|
+
- `.github/workflows/ci.yml` - CI matrix from Python classifiers
|
|
105
|
+
- `.github/workflows/docs.yml` - Documentation deployment
|
|
106
|
+
- `.github/workflows/release.yml` - PyPI publishing with trusted publisher
|
|
107
|
+
- `docs/conf.py` - Sphinx configuration
|
|
108
|
+
- `CITATION.cff` - Citation metadata for academic software
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
preen sync # Update all derived files
|
|
112
|
+
preen sync --only ci,citation # Update specific targets
|
|
113
|
+
preen sync --check # Verify files are up to date
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### `preen bump`
|
|
117
|
+
Semantic version management:
|
|
118
|
+
- Updates version in `pyproject.toml`
|
|
119
|
+
- Regenerates all derived files with new version
|
|
120
|
+
- Commits changes to git with conventional commit message
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
preen bump patch # Bug fixes: 1.0.0 → 1.0.1
|
|
124
|
+
preen bump minor # New features: 1.0.1 → 1.1.0
|
|
125
|
+
preen bump major # Breaking changes: 1.1.0 → 2.0.0
|
|
126
|
+
preen bump patch --dry-run # Preview changes
|
|
127
|
+
preen bump minor --no-commit # Skip git commit
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Configuration
|
|
131
|
+
|
|
132
|
+
Customize behavior in `pyproject.toml`:
|
|
133
|
+
|
|
134
|
+
```toml
|
|
135
|
+
[tool.preen]
|
|
136
|
+
# CI configuration
|
|
137
|
+
ci_os = ["ubuntu-latest", "macos-latest"]
|
|
138
|
+
ci_runner = "uv" # or "pip"
|
|
139
|
+
|
|
140
|
+
# Documentation
|
|
141
|
+
sphinx_theme = "furo"
|
|
142
|
+
use_myst = true
|
|
143
|
+
|
|
144
|
+
# Structure preferences
|
|
145
|
+
src_layout = true
|
|
146
|
+
tests_at_root = true
|
|
147
|
+
|
|
148
|
+
# Skip specific checks
|
|
149
|
+
skip_checks = ["deps", "structure"]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Development Workflow
|
|
153
|
+
|
|
154
|
+
Typical workflow for package maintenance:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# 1. Initialize new package
|
|
158
|
+
preen init myawesome-package
|
|
159
|
+
cd myawesome-package
|
|
160
|
+
|
|
161
|
+
# 2. Develop your package
|
|
162
|
+
# ... write code, tests ...
|
|
163
|
+
|
|
164
|
+
# 3. Pre-release checks
|
|
165
|
+
preen check --fix
|
|
166
|
+
|
|
167
|
+
# 4. Version bump and release prep
|
|
168
|
+
preen bump minor
|
|
169
|
+
git push origin main
|
|
170
|
+
|
|
171
|
+
# 5. Manual steps (for now)
|
|
172
|
+
# - Create GitHub release
|
|
173
|
+
# - CI will build and publish to PyPI via trusted publisher
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Philosophy
|
|
177
|
+
|
|
178
|
+
**pyproject.toml as Single Source of Truth**
|
|
179
|
+
- All metadata lives in one place
|
|
180
|
+
- Derived files are generated, never edited manually
|
|
181
|
+
- Eliminates version mismatches and configuration drift
|
|
182
|
+
|
|
183
|
+
**Opinionated Best Practices**
|
|
184
|
+
- `src/` layout for better import isolation
|
|
185
|
+
- `tests/` at project root, not inside package
|
|
186
|
+
- Modern Python packaging (setuptools, trusted publishing)
|
|
187
|
+
- Comprehensive CI matrix matching declared Python support
|
|
188
|
+
|
|
189
|
+
**DRY Across Configuration**
|
|
190
|
+
- CI matrix generated from Python classifiers
|
|
191
|
+
- Documentation config reflects project metadata
|
|
192
|
+
- CITATION.cff stays in sync with authors and version
|
|
193
|
+
|
|
194
|
+
## Generated Files
|
|
195
|
+
|
|
196
|
+
When you run `preen sync`, these files are generated/updated:
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
.github/workflows/
|
|
200
|
+
├── ci.yml # Test matrix + linting
|
|
201
|
+
├── docs.yml # Documentation deployment
|
|
202
|
+
└── release.yml # PyPI publishing
|
|
203
|
+
|
|
204
|
+
docs/
|
|
205
|
+
└── conf.py # Sphinx configuration
|
|
206
|
+
|
|
207
|
+
CITATION.cff # Citation metadata
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
All generated files include a header indicating they're managed by preen:
|
|
211
|
+
```yaml
|
|
212
|
+
# Generated by preen — do not edit manually
|
|
213
|
+
# Regenerate with: preen sync
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Integration
|
|
217
|
+
|
|
218
|
+
**GitHub Actions**
|
|
219
|
+
```yaml
|
|
220
|
+
# .github/workflows/quality.yml
|
|
221
|
+
- name: Package hygiene
|
|
222
|
+
run: |
|
|
223
|
+
pip install preen
|
|
224
|
+
preen check --strict
|
|
225
|
+
preen sync --check
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Pre-commit Hook**
|
|
229
|
+
```yaml
|
|
230
|
+
# .pre-commit-config.yaml
|
|
231
|
+
repos:
|
|
232
|
+
- repo: local
|
|
233
|
+
hooks:
|
|
234
|
+
- id: preen-check
|
|
235
|
+
name: preen check
|
|
236
|
+
entry: preen check --strict
|
|
237
|
+
language: system
|
|
238
|
+
pass_filenames: false
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## License
|
|
242
|
+
|
|
243
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
244
|
+
|
|
245
|
+
## Contributing
|
|
246
|
+
|
|
247
|
+
1. Fork the repository
|
|
248
|
+
2. Create a feature branch
|
|
249
|
+
3. Make your changes
|
|
250
|
+
4. Run `preen check` to ensure code quality
|
|
251
|
+
5. Submit a pull request
|
|
252
|
+
|
|
253
|
+
For development setup:
|
|
254
|
+
```bash
|
|
255
|
+
git clone https://github.com/gojiplus/preen.git
|
|
256
|
+
cd preen
|
|
257
|
+
pip install -e .[dev]
|
|
258
|
+
preen check
|
|
259
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Top-level package for preen.
|
|
2
|
+
|
|
3
|
+
This module exposes a small public API for programmatic use. At this stage the
|
|
4
|
+
implementation is minimal, providing only the `sync` function used by the
|
|
5
|
+
command‑line interface. Future versions will add additional helpers for
|
|
6
|
+
checking and releasing packages.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from importlib.metadata import version as _get_version # type: ignore
|
|
10
|
+
|
|
11
|
+
from .syncer import sync_project
|
|
12
|
+
|
|
13
|
+
__all__ = ["__version__", "sync_project"]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def __getattr__(name: str):
|
|
17
|
+
"""Lazily expose the package version.
|
|
18
|
+
|
|
19
|
+
The version is looked up using importlib.metadata when accessed. This
|
|
20
|
+
avoids importing pkg_resources at runtime and follows the recommended
|
|
21
|
+
pattern for modern packaging.
|
|
22
|
+
"""
|
|
23
|
+
if name == "__version__":
|
|
24
|
+
return _get_version(__name__)
|
|
25
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Check framework for preen.
|
|
2
|
+
|
|
3
|
+
This module provides the base infrastructure for running checks and
|
|
4
|
+
managing issues/fixes.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .base import Check, CheckResult, Issue, Fix, Severity
|
|
8
|
+
from .runner import run_checks
|
|
9
|
+
|
|
10
|
+
__all__ = ["Check", "CheckResult", "Issue", "Fix", "Severity", "run_checks"]
|