Skip to content

Commit

Permalink
Update dependencies & Make commands for Apple silicon.
Browse files Browse the repository at this point in the history
  • Loading branch information
toddbirchard committed Jan 10, 2023
1 parent d7d2e5a commit 47974b6
Show file tree
Hide file tree
Showing 12 changed files with 399 additions and 511 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FLASK_APP=wsgi.py
FLASK_ENV=development
FLASK_DEBUG=False
SECRET_KEY=randomstringofcharacters
LESS_BIN=/usr/local/bin/lessc
ASSETS_DEBUG=False
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ venv.bak/
# mkdocs documentation
/site

# mypy
# MyPy
.mypy_cache/

# DS Store
.DS_Store

# Pycharm
# IDEs
.idea
.vscode

# Etc
.DS_Store
102 changes: 59 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
PROJECT_NAME := $(shell basename $CURDIR)
VIRTUAL_ENVIRONMENT := $(CURDIR)/.venv
LOCAL_PYTHON := $(VIRTUAL_ENVIRONMENT)/bin/python3
VIRTUAL_ENV := $(CURDIR)/.venv
LOCAL_PYTHON := $(VIRTUAL_ENV)/bin/python3

define HELP
Manage $(PROJECT_NAME). Usage:

make run - Run $(PROJECT_NAME).
make install - Create virtual env, install dependencies, and run project.
make deploy - Install and run script by running `make install` and `make run` in succession.
make update - Update pip dependencies via Poetry and export output to requirements.txt.
make format - Format code with Pythons `Black` library.
make lint - Check code formatting with `flake8`.
make clean - Remove cached files and lock files.
make run - Run $(PROJECT_NAME) locally.
make install - Create local virtualenv & install dependencies.
make deploy - Set up project & run locally.
make update - Update dependencies via Poetry and output resulting `requirements.txt`.
make format - Run Python code formatter & sort dependencies.
make lint - Check code formatting with flake8.
make clean - Remove extraneous compiled files, caches, logs, etc.

endef
export HELP


.PHONY: run install deploy update format lint clean help

requirements: .requirements.txt
env: ./.venv/bin/activate

all help:
@echo "$$HELP"

.requirements.txt: requirements.txt
$(shell . .venv/bin/activate && pip install -r requirements.txt)

env: $(VIRTUAL_ENV)

all help:
@echo "$$HELP"

$(VIRTUAL_ENV):
if [ ! -d $(VIRTUAL_ENV) ]; then \
echo "Creating Python virtual env in \`${VIRTUAL_ENV}\`"; \
python3 -m venv $(VIRTUAL_ENV); \
fi


.PHONY: run
run: env
flask run
uwsgi --http 127.0.0.1:8081 --master --module wsgi:app --processes 4 --threads 2


.PHONY: install
install:
if [ ! -d "./.venv" ]; then python3 -m venv $(VIRTUAL_ENVIRONMENT); fi
. .venv/bin/activate
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel
$(LOCAL_PYTHON) -m pip install -r requirements.txt
install: env
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \
$(LOCAL_PYTHON) -m pip install --no-cache-dir uwsgi && \
$(LOCAL_PYTHON) -m pip install -r requirements.txt && \
echo Installed dependencies in \`${VIRTUAL_ENV}\`;


.PHONY: deploy
Expand All @@ -50,40 +53,53 @@ deploy:
make run


.PHONY: test
test: env
$(LOCAL_PYTHON) -m \
coverage run -m pytest -vv \
--disable-pytest-warnings && \
coverage html --title='Coverage Report' -d .reports && \
open .reports/index.html


.PHONY: update
update:
if [ ! -d "./.venv" ]; then python3 -m venv $(VIRTUAL_ENVIRONMENT); fi
.venv/bin/python3 -m pip install --upgrade pip setuptools wheel
poetry update
poetry export -f requirements.txt --output requirements.txt --without-hashes
update: env
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \
poetry update && \
poetry export -f requirements.txt --output requirements.txt --without-hashes && \
echo Installed dependencies in \`${VIRTUAL_ENV}\`;


.PHONY: format
format: env
isort --multi-line=3 .
black .
$(LOCAL_PYTHON) -m isort --multi-line=3 .
$(LOCAL_PYTHON) -m black .


.PHONY: lint
lint:
flake8 . --count \
lint: env
$(LOCAL_PYTHON) -m flake8 . --count \
--select=E9,F63,F7,F82 \
--exclude .git,.github,__pycache__,.pytest_cache,.venv,logs,creds,.venv,docs,logs \
--exclude .git,.github,__pycache__,.pytest_cache,.venv,logs,creds,.venv,docs,logs,.reports \
--show-source \
--statistics


.PHONY: clean
clean:
find . -name '*.pyc' -delete
find . -name '__pycache__' -delete
find . -name 'poetry.lock' -delete
find . -name '*.log' -delete
find . -name '.DS_Store' -delete
find . -wholename 'logs/*.json' -delete
find . -wholename '.pytest_cache' -delete
find . -wholename '**/.pytest_cache' -delete
find . -wholename './logs/*.json' -delete
find . -wholename './logs' -delete
find . -wholename '*.html' -delete
find . -wholename '**/.webassets-cache' -delete
find . -name 'poetry.lock' -delete && \
find . -name '.coverage' -delete && \
find . -name '*.pyc' -delete \
find . -name '__pycache__' -delete \
find . -name 'poetry.lock' -delete \
find . -name '*.log' -delete \
find . -name '.DS_Store' -delete \
find . -wholename '**/*.pyc' -delete && \
find . -wholename '*.html' -delete && \
find . -type d -wholename '__pycache__' -exec rm -rf {} + && \
find . -type d -wholename '.venv' -exec rm -rf {} + && \
find . -type d -wholename '.pytest_cache' -exec rm -rf {} + && \
find . -type d -wholename '**/.pytest_cache' -exec rm -rf {} + && \
find . -type d -wholename './logs/*' -exec rm -rf {} + && \
find . -type d -wholename './.reports/*' -exec rm -rf {} + && \
find . -type d -wholename '**/.webassets-cache' -exec rm -rf {} +
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Flask Blueprint Tutorial

![Python](https://img.shields.io/badge/Python-v^3.8-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
![Flask](https://img.shields.io/badge/Flask-v2.1.1-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
![Python](https://img.shields.io/badge/Python-v^3.9-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
![Flask](https://img.shields.io/badge/Flask-v2.2.2-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
![Flask-Assets](https://img.shields.io/badge/Flask--Assets-v2.0-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
![GitHub Last Commit](https://img.shields.io/github/last-commit/google/skia.svg?style=flat-square&colorA=4c566a&colorB=a3be8c&logo=GitHub)
[![GitHub Issues](https://img.shields.io/github/issues/hackersandslackers/flask-blueprint-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-blueprint-tutorial/issues)
Expand All @@ -15,8 +15,7 @@ Structure your Flask apps in a scalable and intelligent way using Blueprints.
* **Tutorial**: https://hackersandslackers.com/flask-blueprints/
* **Demo**: https://flaskblueprints.hackersandslackers.app/


# Getting Started
## Getting Started

Get set up locally in two steps:

Expand All @@ -32,18 +31,17 @@ Replace the values in **.env.example** with your values and rename this file to
* `LESS_RUN_IN_DEBUG` *(optional)*: Debug LESS while in `development`.
* `COMPRESSOR_DEBUG` *(optional)*: Debug asset compression while in `development`.


*Remember never to commit secrets saved in .env files to Github.*

### Installation

Get up and running with `make deploy`:

```shell
$ git clone https://github.com/hackersandslackers/flask-blueprint-tutorial.git
$ cd flask-blueprint-tutorial
$ make deploy
```
git clone https://github.com/hackersandslackers/flask-blueprint-tutorial.git
cd flask-blueprint-tutorial
make deploy
```

-----

Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Config:
"""Configuration from environment variables."""

SECRET_KEY = environ.get("SECRET_KEY")
FLASK_ENV = environ.get("FLASK_ENV")
FLASK_ENV = environ.get("FLASK_DEBUG")
FLASK_APP = "wsgi.py"

# Flask-Assets
Expand Down
14 changes: 0 additions & 14 deletions deploy.sh

This file was deleted.

4 changes: 4 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[mypy]
python_version = 3.9
warn_return_any = True
warn_unused_configs = True
Loading

0 comments on commit 47974b6

Please sign in to comment.