Skip to content

Commit

Permalink
Add automatic dependency installation
Browse files Browse the repository at this point in the history
We only need Python packages and a submodule, so automatically create a
local virtual environment and use it in commands.

Signed-off-by: Benjamin Gray <[email protected]>
  • Loading branch information
BenjaminGrayNp1 authored and ajdlinux committed Dec 8, 2023
1 parent 16d5484 commit 688e1a5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.\#*
*~
output/
venv
35 changes: 26 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PY?=python
VENV?=venv
PELICAN?=pelican
PELICANOPTS=

Expand All @@ -7,6 +8,7 @@ INPUTDIR=$(BASEDIR)/content
OUTPUTDIR=$(BASEDIR)/output
CONFFILE=$(BASEDIR)/pelicanconf.py
PUBLISHCONF=$(BASEDIR)/publishconf.py
PY_VENV=. $(VENV)/bin/activate

DEBUG ?= 0
ifeq ($(DEBUG), 1)
Expand All @@ -22,6 +24,7 @@ help:
@echo 'Makefile for a pelican Web site '
@echo ' '
@echo 'Usage: '
@echo ' make install Install dependencies '
@echo ' make html (re)generate the web site '
@echo ' make clean remove the generated files '
@echo ' make regenerate regenerate files upon modification '
Expand All @@ -32,19 +35,33 @@ help:
@echo 'Set the RELATIVE variable to 1 to enable relative urls '
@echo ' '

html:
$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
html: install
$(PY_VENV) && $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)

clean:
[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)

regenerate:
$(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
regenerate: install
$(PY_VENV) && $(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)

watch:
$(PELICAN) $(PELICANOPTS) --relative-urls --listen --autoreload -s $(CONFFILE) $(INPUTDIR) -o $(OUTPUTDIR)
watch: install
$(PY_VENV) && $(PELICAN) $(PELICANOPTS) --relative-urls --listen --autoreload -s $(CONFFILE) $(INPUTDIR) -o $(OUTPUTDIR)

publish:
$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)
publish: install
$(PY_VENV) && $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)

.PHONY: html help clean regenerate watch publish
pelican-octopress-theme/.git: .gitmodules
git submodule update --init

submodules: pelican-octopress-theme/.git

$(VENV)/makestamp: requirements.txt
[ -d $(VENV) ] || $(PY) -m venv $(VENV)
$(PY_VENV) && pip install -r requirements.txt
touch $(VENV)/makestamp

venv: $(VENV)/makestamp

install: venv submodules

.PHONY: html help clean install regenerate watch publish venv submodules

0 comments on commit 688e1a5

Please sign in to comment.