Code Monkey home page Code Monkey logo

the-hatchlor's Introduction

๐ŸŒน The Hatchlor ๐ŸŒน Cookiecutter Template

The Hatchlor logo
Details Tests License - MIT GitHub Sponsors
Features Hatch project linting - Ruff types - mypy test - pytest Pre-Commit docs - mkdocs

The Hatchlor is a cookiecutter template featuring the modern and extensible Python project manager hatch ๐Ÿฃ.

With hatch, you no longer need to deal with files like requirements.txt, Pipfile or environment.yml, just configure everything in pyproject.toml. Thus, hatch is a sophisticated alternative to pipenv, poetry, conda, or direct virtualenv usage. Just think of hatch as a tool that allows you to easily define many isolated development environments, e.g. virtual but also docker environments, and helps you to manage them. A bit like what tox does for testing environments but for all kinds of environments, e.g. testing, linting your code, buildings your docs, and whatever you want.

Check out a vanilla Python project created by the Hatchlor.

โœจ Features

The Hatchlor integrates the following features:

  • hatch: Python packaging, environment management and test runner,
  • hatch-vcs: determine the package version automatically from git tags, e.g. v0.9,
  • hatch-pip-compile: support for lock-files,
  • pyproject.toml: all package, build and tool configuration in one file,
  • pytest: full-featured Python testing tool that helps you write better programs,
  • coverage: tool for measuring code coverage of Python programs with pytest integration,
  • GitHub Actions: workflows with dependabot, release-drafter, labeler, build docs, test & publish to PyPI,
  • ruff: extremely fast Python linter/formatter, which replaces isort, flake8, black, etc.,
  • mypy: optional static type checker for Python,
  • mkdocs: a fast, simple and downright gorgeous static site generator,
  • pre-commit: pre-commit git hooks that make your life easier,
  • Markdown: instead of reStructuredText, Markdown is used consistently for all text files,
  • EditorConfig: maintain consistent coding styles for multiple developers,
  • src-layout: the actual Python package is kept under a src folder avoiding many common errors.

The template includes a skeleton.py with a simple function fib that calculates the Fibonacci numbers as demonstration. This is tested with tests/test_skeleton.py to demonstrate the corresponding features from above. As an additional tidbit, skeleton.py also features Typer to show how fib can be exposed as a CLI command. These files are only for demonstration and can be safely deleted.

๐Ÿ’ซ Quickstart

Install the latest cookiecutter, i.e. >= 1.4, if not installed:

pip install -U cookiecutter

Then generate your Python project with:

cookiecutter https://github.com/florianwilhelm/the-hatchlor.git

๐ŸŽ‰ That's it! Now change into the created directory and check out README.md for more information.

๐Ÿชช License

The Hatchlor is distributed under the terms of the MIT license.

๐Ÿ™ Credits

To start this project off a lot of inspiration was taken from hatch, cookiecutter-pypackage and Pyscaffold.

the-hatchlor's People

Contributors

aviksaikat avatar florianwilhelm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

the-hatchlor's Issues

How to sync / apply script updates in `pyproject.toml` ?

  • Date you used The Hatchlor: 07 March 2024
  • Cookiecutter version used, if any: N/A
  • Python version, if any: 3.10
  • Operating System: UNIX

Hi @FlorianWilhelm and first of all thanks for this amazing project template!

Maybe I missed it in the docs but I'm facing issues when I update script entries in pyproject.toml
E.g. let's say I have the following entry and a fresh hatch project (i.e., never ran hatch run ... or hatch env create)

[project.scripts]
fibonacci = "autorag.fibonacci:app"

When I run hatch env create && hatch run fibonacci 10 it correctly executes the script.

Now I want to change ,e.g., the name of the script:

[project.scripts]
print_fibonacci = "autorag.fibonacci:app"

When I run hatch env create && hatch run print_fibonacci 10 it prints /bin/sh: print_fibonacci: command not found. Also, when I look into the venv bin dir, I can see the old fibonacci but not the new print_fibonacci.

The only way I found to update and sync the env is to completely remove my venv dir and create the env from scratch.

Is this behaviour on purpose or did I miss something here?

Prompting project informations runs into an error

  • Date you used The Hatchlor: April 26th, 2024
  • Cookiecutter version used, if any: 2.6.0
  • Python version, if any: 3.10
  • Operating System: Mac OS

Description

Hi @FlorianWilhelm , I saw your great talk at Pycon, and I am very keen to try out the-hatchlor. However, trying to answer the prompts after starting cookiecutter leads into an error that I am unable to resolve.
For every prompt, I set the defaul argument. Then I received the following prompt: "_ prompts _ [default] ". This seems to be a generic placeholder that should not pop up. When I pressed enter to chose the default, I got the error message "Error: Unable to decode to JSON". I expected to receive the next prompt instead.

What I Did

Bildschirmfoto 2024-04-26 um 08 44 59

cookiecutter https://github.com/florianwilhelm/the-hatchlor.git
You've downloaded /Users/thomasplischke/.cookiecutters/the-hatchlor before. Is it okay to delete and re-download it? [yes]: y
full_name [Florian Wilhelm]: 
email [[email protected]]: 
project_name [Python hatch project]: 
project_slug [python-hatch-project]: 
pkg_name [python_hatch_project]: 
project_short_description [Python project featuring the modern and extensible Python project manager hatch.]: 
Select open_source_license:
1 - MIT
2 - BSD-3-Clause
3 - ISC
4 - Apache-2.0
5 - GPL-3.0-only
6 - proprietary
Choose from 1, 2, 3, 4, 5, 6 [1]: 
Select target_python_version:
1 - 3.10
2 - 3.8
3 - 3.9
4 - 3.11
5 - 3.12
Choose from 1, 2, 3, 4, 5 [1]: 
github_username [FlorianWilhelm]: 
project_repo [https://github.com/FlorianWilhelm/python-hatch-project]: 
pypi_username [FlorianWilhelm]: 
lock_file_support [False]: 
__prompts__ [default]: 
Error: Unable to decode to JSON.

Feature request: Add git remote based upon prompts

Creating the project asks for the GitHub username and repository URL and populates some entries in pyproject.toml with them, but doesn't use them to set the origin remote in the initialized Git repo:

$ cookiecutter https://github.com/florianwilhelm/the-hatchlor.git
  [1/12] Provide your full name (Florian Wilhelm):
  [2/12] Provide your email ([email protected]):
  [3/12] Provide the human-readible project name (Python hatch project):
  [4/12] Provide the project slug (only ASCII letters/digits, underscores, hyphens, and periods) (python-hatch-project):
  [5/12] Provide the package name (only ASCII letters/digits, and underscores) (python_hatch_project):
  [6/12] Provide a short project description (Python project featuring the modern and extensible Python project manager hatch.):
  [7/12] Provide the license of this project
    1 - MIT
    2 - BSD-3-Clause
    3 - ISC
    4 - Apache-2.0
    5 - GPL-3.0-only
    6 - proprietary
    Choose from [1/2/3/4/5/6] (1):
  [8/12] Provide the minimum Python version
    1 - 3.10
    2 - 3.8
    3 - 3.9
    4 - 3.11
    5 - 3.12
    Choose from [1/2/3/4/5] (1):
  [9/12] Optionally, provide a Github user name (FlorianWilhelm):
  [10/12] Optionally, provide the repository url (https://github.com/FlorianWilhelm/python-hatch-project):
  [11/12] Optionally, provide a PyPI user name (FlorianWilhelm):
  [12/12] Activate support for lock files? [y/n] (n):
Initialized empty Git repository in ~/Desktop/python-hatch-project/.git/
[main (root-commit) 7fa49b1] Initial commit
 32 files changed, 1527 insertions(+)
 create mode 100644 .editorconfig
 create mode 100644 .github/dependabot.yml
 create mode 100644 .github/labels.yml
 create mode 100644 .github/release-drafter.yml
 create mode 100644 .github/workflows/build.yml
 create mode 100644 .github/workflows/documentation.yml
 create mode 100644 .github/workflows/draft.yml
 create mode 100644 .github/workflows/labeler.yml
 create mode 100644 .github/workflows/tests.yml
 create mode 100644 .gitignore
 create mode 100644 .pre-commit-config.yaml
 create mode 100644 AUTHORS.md
 create mode 100644 CHANGELOG.md
 create mode 100644 CONTRIBUTING.md
 create mode 100644 LICENSE.txt
 create mode 100644 README.md
 create mode 100644 docs/assets/images/favicon.svg
 create mode 100644 docs/authors.md
 create mode 100644 docs/changelog.md
 create mode 100644 docs/contributing.md
 create mode 100644 docs/index.md
 create mode 100644 docs/license.md
 create mode 100644 docs/scripts/gen_ref_nav.py
 create mode 100644 docs/snippets/links.txt
 create mode 100644 mkdocs.yml
 create mode 100644 notebooks/template.ipynb
 create mode 100644 pyproject.toml
 create mode 100644 src/python_hatch_project/__init__.py
 create mode 100644 src/python_hatch_project/skeleton.py
 create mode 100644 tests/__init__.py
 create mode 100644 tests/conftest.py
 create mode 100644 tests/test_skeleton.py
$ cd python-hatch-project
$ git remote -v
$

I ask because it is more annoying to do git remote add origin ... than it is git remote rm origin for the common use case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.