Skip to content

Commit 11f699b

Browse files
authored
Update templates (#5)
* ignore envrc file used by direnv * add Makefile with install command * cleanup globals a la netid_arrest * python 3.8 EOL, use Flask 3
1 parent b57dc43 commit 11f699b

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ ipython_config.py
8484
# pyenv
8585
.python-version
8686

87+
# direnv
88+
.envrc
89+
8790
# pipenv
8891
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
8992
# However, in case of collaboration, if having platform-specific dependencies or dependencies

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.ONESHELL:
2+
3+
.PHONY: install
4+
install: ## Install the project in dev mode.
5+
@./venv/bin/pip install -U pip
6+
@./venv/bin/pip install --no-input 'urllib3<2' keyring keyrings.google-artifactregistry-auth
7+
@if ! poetry --version >/dev/null; then pip install poetry ; fi
8+
@poetry install --with=dev

example_app/app.template.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import importlib.metadata as importlib_metadata # Python ^3.9 change
23

34
from flask import Flask, jsonify
45

@@ -13,6 +14,7 @@ def index():
1314

1415
APP_VERSION = None
1516

17+
1618
@app.route("/status")
1719
def status():
1820
global APP_VERSION

pyproject.template.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ description = ""
55
authors = []
66

77
[tool.poetry.dependencies]
8-
python = "^3.8"
9-
Flask = "^2.0.2"
8+
python = "^3.9"
9+
Flask = "^3.0"
1010

1111
[tool.poetry.dev-dependencies]
1212
pytest = "^6.2.5"

scripts/globals.template.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ export APP_NAME="${template:app_name}"
44

55
function get_instance_status {
66
local stage="$1"
7-
local url="https://${APP_NAME}.iam${stage}.s.uw.edu/status"
8-
curl -sk $url
7+
# substitute '_' for '-' in APP_NAME
8+
local url="https://${APP_NAME//_/-}.iam${stage}.s.uw.edu/status"
9+
curl -sk "$url" || >&2 echo "Failed to check $url"
910
}
1011

1112
function get_poetry_version {
12-
cat pyproject.toml | grep 'version =' | cut -f2 -d\" | head -n1
13+
grep 'version =' pyproject.toml | cut -f2 -d\" | head -n1
1314
}
1415

1516

@@ -20,13 +21,13 @@ function get_promotion_version {
2021
local target=$1
2122
case $target in
2223
dev)
23-
echo $(get_poetry_version)
24+
get_poetry_version
2425
;;
2526
eval)
26-
echo $(get_instance_status dev | jq -r .version)
27+
get_instance_status dev | jq -r .version
2728
;;
2829
prod)
29-
echo $(get_instance_status eval | jq -r .version)
30+
get_instance_status eval | jq -r .version
3031
;;
3132
esac
3233
}

0 commit comments

Comments
 (0)