Skip to content

Commit 13caea4

Browse files
authored
Move Python virtual environment into venv from root (#1769)
* Move Python virtual environment into venv from root `--clear` is the recommended way to wipe and recreate a clean virtual environment. `python3 -m venv venv --clear` will purge files and directories, such as `.git` and `.my_special_config`, from the current directory. This would be Very Bad™. - Enhance `make distclean` such that it cleans both the docs directory and the virtual environment, then recreates the virtual environment and installs requirements into it. This is useful when your project gets confused about what exactly is in your virtual environment - Update internal Makefile command. No change to user commands. Credit to @MrTango * Add to .gitignore
1 parent 50e4c5f commit 13caea4

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Dependencies
2-
/bin
3-
/include
4-
/lib
5-
/lib64
2+
/venv
63

74
# Generated files
8-
pyvenv.cfg
95
/_build
106
/styles/Microsoft
117
/share

Makefile

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ SHELL = bash
55
# You can set these variables from the command line.
66
SPHINXOPTS ?=
77
PAPER ?=
8+
VALEOPTS ?=
89

910
# Internal variables.
10-
SPHINXBUILD = "$(realpath bin/sphinx-build)"
11-
SPHINXAUTOBUILD = "$(realpath bin/sphinx-autobuild)"
11+
SPHINXBUILD = "$(realpath venv/bin/sphinx-build)"
12+
SPHINXAUTOBUILD = "$(realpath venv/bin/sphinx-autobuild)"
1213
DOCS_DIR = ./docs/
1314
BUILDDIR = ../_build
1415
PAPEROPT_a4 = -D latex_paper_size=a4
@@ -29,20 +30,25 @@ clean: ## Clean docs build directory
2930
cd $(DOCS_DIR) && rm -rf $(BUILDDIR)/
3031

3132
.PHONY: distclean
32-
distclean: ## Clean docs build directory and Python virtual environment
33+
distclean: ## Clean docs build directory and Python virtual environment, then install requirements
3334
cd $(DOCS_DIR) && rm -rf $(BUILDDIR)/
34-
rm -rf ./bin/ ./lib/ ./lib64 ./include ./pyvenv.cfg
35-
35+
python3 -m venv venv --clear
36+
venv/bin/pip install -r requirements-initial.txt
37+
venv/bin/pip install -r requirements.txt
38+
@echo
39+
@echo "Installation of requirements completed."
3640

37-
bin/python:
38-
python3 -m venv .
39-
bin/pip install -r requirements-initial.txt
40-
bin/pip install -r requirements.txt
41+
venv/bin/python: ## Setup up Python virtual environment and install requirements
42+
python3 -m venv venv
43+
venv/bin/pip install -r requirements-initial.txt
44+
venv/bin/pip install -r requirements.txt
45+
@echo
46+
@echo "Installation of requirements completed."
4147

4248
docs/plone.api:
4349
git submodule init; \
4450
git submodule update; \
45-
bin/pip install -e submodules/plone.api/"[test]"; \
51+
venv/bin/pip install -e submodules/plone.api/"[test]"; \
4652
ln -s ../submodules/plone.api/docs ./docs/plone.api
4753
@echo
4854
@echo "Documentation of plone.api initialized."
@@ -62,7 +68,7 @@ docs/volto:
6268
@echo "Documentation of volto initialized."
6369

6470
.PHONY: deps
65-
deps: bin/python docs/volto docs/plone.restapi docs/plone.api ## Create Python virtual environment, install requirements, initialize or update the volto, plone.restapi, and plone.api submodules, and finally create symlinks to the source files.
71+
deps: venv/bin/python docs/volto docs/plone.restapi docs/plone.api ## Create Python virtual environment, install requirements, initialize or update the volto, plone.restapi, and plone.api submodules, and finally create symlinks to the source files.
6672

6773

6874
.PHONY: html
@@ -196,8 +202,8 @@ linkcheckbroken: deps ## Run linkcheck and show only broken links
196202

197203
.PHONY: vale
198204
vale: deps ## Run Vale style, grammar, and spell checks
199-
bin/vale sync
200-
bin/vale --no-wrap $(VALEFILES)
205+
venv/bin/vale sync
206+
venv/bin/vale --no-wrap $(VALEOPTS) $(VALEFILES)
201207
@echo
202208
@echo "Vale is finished; look for any errors in the above output."
203209

0 commit comments

Comments
 (0)