diff --git a/examples/webserver/.gitignore b/examples/webserver/.gitignore new file mode 100644 index 0000000..21db2b6 --- /dev/null +++ b/examples/webserver/.gitignore @@ -0,0 +1,3 @@ +.pixi/ +output/ +__pycache__/ diff --git a/examples/webserver/README.md b/examples/webserver/README.md new file mode 100644 index 0000000..d0ca8c1 --- /dev/null +++ b/examples/webserver/README.md @@ -0,0 +1,13 @@ +# Webserver + +This is a simple web server that runs FastAPI. + +## Run the server + +```bash +rattler-build build -r recipe/recipe.yaml +pixi-pack pack -e prod --platform win-64 --inject output/noarch/my-webserver-*.conda +``` + +> [!NOTE] +> The file `my-webserver-0.1.0-pyh4616a5c_0.conda` is only for testing, in a real scenario it would be in the `output/noarch` directory generated by `rattler-build`. diff --git a/examples/webserver/my-webserver-0.1.0-pyh4616a5c_0.conda b/examples/webserver/my-webserver-0.1.0-pyh4616a5c_0.conda new file mode 100644 index 0000000..d790735 Binary files /dev/null and b/examples/webserver/my-webserver-0.1.0-pyh4616a5c_0.conda differ diff --git a/examples/webserver/my_webserver/__init__.py b/examples/webserver/my_webserver/__init__.py new file mode 100644 index 0000000..52f0d71 --- /dev/null +++ b/examples/webserver/my_webserver/__init__.py @@ -0,0 +1,8 @@ +from fastapi import FastAPI + +app = FastAPI() + + +@app.get("/") +def hello(): + return "Hello, World!" diff --git a/examples/webserver/pixi.toml b/examples/webserver/pixi.toml new file mode 100644 index 0000000..1632789 --- /dev/null +++ b/examples/webserver/pixi.toml @@ -0,0 +1,21 @@ +[project] +name = "pixi-docker-example" +channels = ["conda-forge"] +platforms = ["osx-arm64", "linux-64", "linux-aarch64", "win-64"] + +[tasks] +dev = "uvicorn my_project:app --reload" +start = "uvicorn my_project:app --host 0.0.0.0" + +[dependencies] +fastapi = "*" +uvicorn = "*" + +[feature.dev.dependencies] +pytest = "*" +ruff = "*" +mypy = "*" + +[environments] +default = { features = ["dev"], solve-group = "prod" } +prod = { features = [], solve-group = "prod" } diff --git a/examples/webserver/pyproject.toml b/examples/webserver/pyproject.toml new file mode 100644 index 0000000..b6d0850 --- /dev/null +++ b/examples/webserver/pyproject.toml @@ -0,0 +1,16 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "my-webserver" +description = "Example web server" +version = "0.1.0" +classifiers = [ + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.12", +] +requires-python = ">=3.12" +# pixi handles the dependencies +# since we don't want to distribute this to pypi, we don't need to specify them here +dependencies = [] diff --git a/examples/webserver/recipe/recipe.yaml b/examples/webserver/recipe/recipe.yaml new file mode 100644 index 0000000..5c48d96 --- /dev/null +++ b/examples/webserver/recipe/recipe.yaml @@ -0,0 +1,31 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json + +package: + name: my-webserver + version: '0.1.0' + +source: + path: ../ + +build: + number: 0 + noarch: python + script: + - python -m pip install . --no-deps --ignore-installed -vv --no-build-isolation --disable-pip-version-check + +requirements: + host: + - python >=3.12 + - pip + - hatchling + run: + - python >=3.12 + - fastapi + +tests: + - python: + imports: + - my_webserver + - package_contents: + site_packages: + - my_webserver/__init__.py