https://github.com/sidisinsane/copier-python-hatch-template
A Copier template for Python projects managed by Hatch.
https://github.com/sidisinsane/copier-python-hatch-template
copier-template hatch project-template python scaffolding
Last synced: 10 days ago
JSON representation
A Copier template for Python projects managed by Hatch.
- Host: GitHub
- URL: https://github.com/sidisinsane/copier-python-hatch-template
- Owner: sidisinsane
- License: mit
- Created: 2024-03-25T08:09:30.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-27T10:13:57.000Z (about 2 years ago)
- Last Synced: 2024-03-27T20:01:45.555Z (about 2 years ago)
- Topics: copier-template, hatch, project-template, python, scaffolding
- Language: Jinja
- Homepage: https://sidisinsane.github.io/copier-python-hatch-template/
- Size: 684 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Copier Python Hatch Template
*A Copier template for Python projects managed by Hatch.*
[](https://github.com/sidisinsane/copier-python-hatch-template/blob/main/LICENSE)
[](https://github.com/sidisinsane/copier-python-hatch-template/blob/main/.github/workflows/ci.yml)
[](https://github.com/sidisinsane/copier-python-hatch-template/blob/main/.github/workflows/codeql.yml)
[](https://github.com/sidisinsane/copier-python-hatch-template/blob/main/.github/workflows/gh-pages-deploy.yml)
[](https://www.python.org/)
[](https://copier.readthedocs.io/en/stable/)
[](https://github.com/pypa/hatch)
[](https://squidfunk.github.io/mkdocs-material/)
[](https://pytest.org/)
[](https://github.com/DavidAnson/markdownlint)
[](https://commitlint.js.org/)
[](https://docs.astral.sh/ruff/)
[](https://github.com/PyCQA/bandit)
[](https://mypy-lang.org/)
## Prerequisites
### Copier
[Copier](https://copier.readthedocs.io/en/stable/) is a library and CLI app for rendering project templates.
#### Install Copier
> [!IMPORTANT]
> If you haven't already, install `pipx` first: `pip install --user pipx`.
```shell
pipx install copier
```
#### Inject Copier Templates Extensions
```shell
pipx inject copier copier-templates-extensions
```
### Hatch
[Hatch](https://hatch.pypa.io/latest/) is a modern, [PEP 621](https://peps.python.org/pep-0621/) compliant, extensible Python project manager.
#### Install Hatch
```shell
pipx install hatch
```
#### Configure Hatch
Store virtual environments in a directory named `.hatch` in each project directory.
```shell
hatch config set dirs.env.virtual .hatch
```
> [!NOTE]
> This adds the following to the configuration:
>
> ```toml
> [dirs.env]
> virtual = ".hatch"
> ```
>
> The [Configuration for Hatch](https://hatch.pypa.io/latest/config/hatch/) is stored in a `config.toml` file at i.e. `~/Library/Application Support/hatch` on macOS.
## Usage
### Generate a Project
```shell
copier copy --trust https://github.com/sidisinsane/copier-python-hatch-template.git PATH/TO/DESTINATION
```
or
```shell
copier copy --trust gh:sidisinsane/copier-python-hatch-template PATH/TO/DESTINATION
```
This will generate a new project with the following structure:
```ascii
YOUR-PROJECT-NAME
├── .github
│ └── workflows
│ ├── ci.yml
│ ├── codeql.yml
│ ├── gh-pages-deploy.yml
│ └── test.yml
├── .vscode
│ ├── extensions.json
│ └── settings.json
├── mkdocs
│ ├── images
│ │ ├── favicon.svg
│ │ └── logo.svg
│ ├── javascripts
│ │ └── mathjax.js
│ ├── index.md
│ └── license.md
├── src
│ └── YOUR_PROJECT_NAME
│ ├── __about__.py
│ ├── __init__.py
│ └── calc.py
├── tests
│ ├── __init__.py
│ └── test_calc.py
├── .coveragerc
├── .gitignore
├── .markdownlint.yml
├── .pre-commit-config.yaml
├── .pylintrc
├── bandit.yml
├── commitlint.config.js
├── LICENSE
├── mkdocs.yml
├── mypy.ini
├── pyproject.toml
├── pytest.ini
└── README.md
```
> [!NOTE]
> You can also clone the project template using `git clone https://github.com/sidisinsane/copier-python-hatch-template.git`, modify it and generate a project the locally cloned repo.
>
> ```shell
> copier copy --trust PATH/TO/CLONED/PROJECT/TEMPLATE PATH/TO/DESTINATION
> ```
## Aftermath
### Create Virtual Environment
```shell
cd PATH/TO/DESTINATION && hatch env create
```
> [!NOTE]
> You can locate environments by running `hatch env find`.
### Install Pre-Commit Hooks
```shell
git init && hatch run dev:pre-commit-install
```
> [!NOTE]
> After you have created a new empty GitHub project, you are ready to make your initial commit.
>
> ```shell
> git add .
> git commit -m "initial commit"
> git branch -M main
> git remote add origin
> git push -u origin main
> ```
See the [documentation](https://sidisinsane.github.io/copier-python-hatch-template/) for more details.