Skip to content

Commit

Permalink
chore: adds python to examples along with READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman committed Oct 23, 2024
1 parent 140b567 commit 01db83f
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Go Example

This is an example Go CLI application that prints `"Hello, [name]"` to the screen.
It's configured to be released as both a standalone binary and as a container.
Additionally, it produces artifacts for both x86 and ARM variants of Linux/macOS.
1 change: 1 addition & 0 deletions examples/python/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
5 changes: 5 additions & 0 deletions examples/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Python Example

This is an example Python CLI application that prints `"Hello, [name]"` to the screen.
Unlike other examples, this one does not include an existing `Earthfile` or `blueprint.cue`.
It is intended to be used as the starting point for learning about Catalyst Forge.
26 changes: 26 additions & 0 deletions examples/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[project]
name = "hello"
version = "0.1.0"
description = "A simple hello world CLI"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"click>=8.1.7",
]

[project.scripts]
hello = "hello.hello:cli"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src/hello"]

[project.optional-dependencies]
dev = [
"black>=24.8.0",
"pytest>=8.3.3",
"ruff>=0.6.5",
]
Empty file.
15 changes: 15 additions & 0 deletions examples/python/src/hello/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import click


def hello(name: str = "World") -> str:
return f"Hello, {name}!"


@click.command()
@click.argument("name", required=False, default="World")
def cli(name):
click.echo(hello(name))


if __name__ == "__main__":
cli()
7 changes: 7 additions & 0 deletions examples/python/tests/hello_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from hello.hello import hello


def test_hello():
assert hello("Alice") == "Hello, Alice!"
assert hello() == "Hello, World!"

160 changes: 160 additions & 0 deletions examples/python/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions examples/rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Rust Example

This is an example Rust CLI application that prints `"Hello, [name]"` to the screen.
It's configured to be released as both a standalone binary and as a container.
Additionally, it produces artifacts for both x86 and ARM variants of Linux.

0 comments on commit 01db83f

Please sign in to comment.