Skip to content

Commit

Permalink
improve makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
grigaut committed Jul 7, 2023
1 parent f797ac9 commit 9c53d2c
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions {{cookiecutter.package_name}}/Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
PYTHON = $(shell command -v python 2> /dev/null)
GLOBAL_PYTHON := ${shell}command -v python 2> /dev/null)
GLOBAL_POETRY := ${shell}command -v poetry 2> /dev/null)

VIRTUAL_ENV = .venv
HOOKS = .git/hooks
ifeq ($(OS), Windows_NT)
ifeq (${OS}, Windows_NT)
BIN = ${VIRTUAL_ENV}/Scripts/
else
BIN = ${VIRTUAL_ENV}/bin/
endif
STREAMLIT_MAIN_SCRIPT = app/main.py

# Main Rules

clean:
rm -rf ${VIRTUAL_ENV}
rm -rf ${HOOKS}

# Poetry Tatgets

check-poetry:
@if [ -z ${GLOBAL_POETRY} ]; then echo "Poetry is not installed on your global python. Use 'make install-poetry' to install Poetry on your global python."; exit 2 ;fi

install-poetry:
curl -sSL https://install.python-poetry.org | ${GLOBAL_PYTHON} -

${VIRTUAL_ENV}:
${PYTHON} -m venv ${VIRTUAL_ENV}
${BIN}python -m pip install poetry

.PHONY: poetry-install
poetry-install: pyproject.toml poetry.lock
${BIN}poetry install --only main --ansi
${MAKE} -s check-poetry
${GLOBAL_POETRY} install --only main --ansi

.PHONY: install
install:
Expand All @@ -31,7 +40,8 @@ install:

.PHONY: poetry-install-dev
poetry-install-dev: pyproject.toml poetry.lock
${BIN}poetry install --ansi
${MAKE} -s check-poetry
${GLOBAL_POETRY} install --ansi

.PHONY: hooks_install
hooks-install: .pre-commit-config.yaml
Expand All @@ -52,29 +62,30 @@ tests:

.PHONY: poetry-install-docs
poetry-install-docs: poetry.lock
$(BIN)poetry install --only docs --ansi
${MAKE} -s check-poetry
${GLOBAL_POETRY} install --only docs --ansi


.PHONY: install-docs
install-docs:
$(MAKE) -s ${VIRTUAL_ENV}
$(MAKE) -s poetry-install-docs
${MAKE} -s ${VIRTUAL_ENV}
${MAKE} -s poetry-install-docs

.PHONY: view-docs
view-docs:
$(MAKE) -s install-docs
$(BIN)mkdocs serve
${MAKE} -s install-docs
${BIN}mkdocs serve

./site:
$(MAKE) -s install-docs
$(BIN)mkdocs build
${MAKE} -s install-docs
${BIN}mkdocs build

.PHONY: build-docs
build-docs:
$(MAKE) -s ./site
${MAKE} -s ./site

.PHONY: deploy-docs
deploy-docs:
$(MAKE) -s install-docs
$(BIN)mkdocs gh-deploy
${MAKE} -s install-docs
${BIN}mkdocs gh-deploy
rm -r -f ./site

0 comments on commit 9c53d2c

Please sign in to comment.