commit 47915d7bcdd266a6621d386fcd713181c8ed7d4e Author: NATHAN Solal Date: Sat May 25 10:13:55 2024 +0200 intial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..23fbaa4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# python generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info + +# venv +.venv + +# ruff +.ruff_cache \ No newline at end of file diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..871f80a --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12.3 diff --git a/README.md b/README.md new file mode 100644 index 0000000..2803e8a --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# test-pkg + +Python packaging tests using Rye (and some typer CLI interface) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f630168 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,33 @@ +[project] +name = "test-pkg" +version = "0.1.0" +description = "Add your description here" +authors = [ + { name = "Otthorn", email = "otthorn@crans.org" } +] +dependencies = [ + "typer>=0.12.3", +] +readme = "README.md" +requires-python = ">= 3.8" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.rye] +managed = true +dev-dependencies = [] + +[tool.hatch.metadata] +allow-direct-references = true + +[tool.hatch.build.targets.wheel] +packages = ["src/test_pkg"] + +[tool.ruff.lint] +select = ["I"] + +[tool.rye.scripts] +test_pkg = { call = "test_pkg.utils:app" } +cli = { call = "test_pkg.cli:app" } diff --git a/requirements-dev.lock b/requirements-dev.lock new file mode 100644 index 0000000..eff5d88 --- /dev/null +++ b/requirements-dev.lock @@ -0,0 +1,27 @@ +# generated by rye +# use `rye lock` or `rye sync` to update this lockfile +# +# last locked with the following flags: +# pre: false +# features: [] +# all-features: false +# with-sources: false +# generate-hashes: false + +-e file:. +click==8.1.7 + # via typer +markdown-it-py==3.0.0 + # via rich +mdurl==0.1.2 + # via markdown-it-py +pygments==2.18.0 + # via rich +rich==13.7.1 + # via typer +shellingham==1.5.4 + # via typer +typer==0.12.3 + # via test-pkg +typing-extensions==4.12.0 + # via typer diff --git a/requirements.lock b/requirements.lock new file mode 100644 index 0000000..eff5d88 --- /dev/null +++ b/requirements.lock @@ -0,0 +1,27 @@ +# generated by rye +# use `rye lock` or `rye sync` to update this lockfile +# +# last locked with the following flags: +# pre: false +# features: [] +# all-features: false +# with-sources: false +# generate-hashes: false + +-e file:. +click==8.1.7 + # via typer +markdown-it-py==3.0.0 + # via rich +mdurl==0.1.2 + # via markdown-it-py +pygments==2.18.0 + # via rich +rich==13.7.1 + # via typer +shellingham==1.5.4 + # via typer +typer==0.12.3 + # via test-pkg +typing-extensions==4.12.0 + # via typer diff --git a/src/test_pkg/__init__.py b/src/test_pkg/__init__.py new file mode 100644 index 0000000..2bdc247 --- /dev/null +++ b/src/test_pkg/__init__.py @@ -0,0 +1,4 @@ +import test_pkg.core as core +import test_pkg.utils as utils + +__all__ = ["core", "utils"] diff --git a/src/test_pkg/cli.py b/src/test_pkg/cli.py new file mode 100644 index 0000000..4d23835 --- /dev/null +++ b/src/test_pkg/cli.py @@ -0,0 +1,18 @@ + +import typer + +app = typer.Typer(no_args_is_help=True) + +@app.callback() +def callback(): + """ + Nice defintion + """ + +@app.command() +def do(): + print("something") + +@app.command() +def dont(): + print("nothing") \ No newline at end of file diff --git a/src/test_pkg/core.py b/src/test_pkg/core.py new file mode 100644 index 0000000..512eadb --- /dev/null +++ b/src/test_pkg/core.py @@ -0,0 +1,6 @@ +from test_pkg.utils import do_something + + +def main(): + do_something() + do_something() diff --git a/src/test_pkg/utils.py b/src/test_pkg/utils.py new file mode 100644 index 0000000..8fb8356 --- /dev/null +++ b/src/test_pkg/utils.py @@ -0,0 +1,25 @@ +import time + +import typer +from rich.progress import track + +app = typer.Typer() + + +@app.command() +def do_something(): + print("something") + + +@app.command() +def do(arg1: str = "b", arg2: str = "a"): + print(f"arg1 = {arg1}, arg2 = {arg2}") + +@app.command() +def prog_test(): + total = 0 + for value in track(range(100), description="Processing..."): + # Fake processing time + time.sleep(0.01) + total += 1 + print(f"Processed {total} things.") \ No newline at end of file