An open API service indexing awesome lists of open source software.

https://github.com/ulgens/python-anything

Python project starter with a modern setup
https://github.com/ulgens/python-anything

copier python template

Last synced: 3 months ago
JSON representation

Python project starter with a modern setup

Awesome Lists containing this project

README

          

# python-anything

[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json)](https://github.com/copier-org/copier)

A [Copier](https://copier.readthedocs.io/) template for Python projects with opinionated tooling.

> **Warning**
> This template is in a pretty early stage of development. Things can be unstable and changed without notice. Use at your own risk.

## What's included

- **GitHub Actions**: CI workflows for git hooks and tests
- **[uv](https://github.com/astral-sh/uv)**: Python dependency management
- **[prek](https://github.com/j178/prek)**: Git hooks manager/wrapper
- **[ruff](https://github.com/astral-sh/ruff)**: Linting and formatting
- **[ty](https://github.com/astral-sh/ty)**: Type checking (optional)
- **[Renovate](https://github.com/renovatebot/renovate)**: Automated dependency updates
- **[pytest](https://docs.pytest.org/)** + **[pytest-xdist](https://github.com/pytest-dev/pytest-xdist)** + **[pytest-randomly](https://github.com/pytest-dev/pytest-randomly)**: Python testing
- **[Codecov](https://about.codecov.io/)**: Test coverage reporting (optional)

## Requirements

- [Copier](https://copier.readthedocs.io/) >= 9.0.0
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
- [prek](https://prek.j178.dev/installation/)

## Usage

### Create a new project

```bash
copier copy --trust gh:ulgens/python-anything ./my-project
```

### Template questions

| Question | Description | Default |
|---|---|---|
| `project_name` | Project name (e.g., `my-awesome-project`) | `my-awesome-project` |
| `project_description` | One-line description | `""` |
| `author_name` | Author full name | `Jane Doe` |
| `author_email` | Author email | `janedoe@example.com` |
| `github_username` | GitHub username or organization | `janedoe` |
| `python_version` | Python minor version | `3.14` |
| `license` | License type | `MIT` (MIT, BSD-3-Clause, Apache-2.0, GPL-3.0, None) |
| `frameworks` | Frameworks & libraries | `[]` (Click, FastAPI, LangChain) |
| `use_codecov` | Enable Codecov integration | `true` |
| `use_ty` | Enable ty type checker | `false` |

### After generation

```bash
cd my-project
prek install
git remote add origin git@github.com:/.git
git commit -m "Initial commit"
git push -u origin main
```

### Adapt an existing project

To adopt this template in a project that already exists:

1. Make sure all changes are committed so you can review the template's changes as a diff:
```bash
git status # should be clean
```

2. Run `copier copy` from the project root:
```bash
copier copy --trust gh:ulgens/python-anything .
```

3. Answer the template questions to match your existing project (name, author, Python version, etc.).

4. Review the changes. Key files to check:
- **`pyproject.toml`**: Merge your existing dependencies into the template's structure. The template uses `dependency-groups` for dev dependencies and pinned versions.
- **Source layout**: The template expects code in `src/` and tests in `src/tests/`. Move your code if it lives elsewhere.
- **`.github/workflows/`**: Decide whether to keep your existing CI or adopt the template's.
- **Config files** (`ruff.toml`, `.pre-commit-config.yaml`, etc.): Generally safe to accept the template's versions.

5. If you made manual changes after the copy (e.g., merging dependencies, moving files), run the hooks again:
```bash
prek run --all-files
```

6. Review the full diff and commit:
```bash
git diff --staged
git commit -m "Adopt python-anything template"
```

After this, `.copier-answers.yml` enables `copier update --trust` for future template updates.

### Update an existing project

```bash
copier update --trust
```

## What gets generated

```
my-project/
├── .copier-answers.yml
├── .github/
│ └── workflows/
│ ├── git-hooks.yml
│ └── tests.yml
├── .gitignore
├── .pre-commit-config.yaml
├── LICENSE # (if license != None)
├── README.md
├── pyproject.toml
├── renovate.json5
├── ruff.toml
├── src/
│ └── tests/
│ ├── __init__.py
│ └── test_sample.py
├── uv.lock # (generated by post-copy task)
└── yamlfmt.yaml
```

## Framework-specific features

Selecting frameworks affects:

- **pyproject.toml**: Adds pinned dependencies for the selected frameworks
- **ruff.toml**: Enables framework-specific lint rules:
- FastAPI: `FAST` rules

## Codecov setup

If you enabled Codecov integration (`use_codecov: true`), follow these steps after generation:

1. Sign up at [codecov.io](https://about.codecov.io/) and add your repository.
2. Copy the upload token from Codecov's repository settings.
3. Add the token as a GitHub Actions secret named `CODECOV_TOKEN` in your repository settings (Settings > Secrets and variables > Actions).

Once configured, coverage reports will be uploaded automatically on every push to `main` and on pull requests.

## Related templates

- **Django**: Use [ulgens/django-blasphemy](https://github.com/ulgens/django-blasphemy) for Django projects.

## License

MIT License - see [LICENSE](LICENSE) for details.