Implement venv requirement

This commit is contained in:
Colin Goutte 2023-08-23 16:10:04 +02:00
parent ed704f8957
commit 28db07d765
6 changed files with 82 additions and 0 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
Pipfile.lock
__pycache__/
.venv*
*.py[o|c]

View File

@ -4,3 +4,9 @@ tdd:
test:
pipenv run pytest $(opt)
requirements:
pipenv requirements > requirements.txt
pipenv requirements --dev-only > requirements_dev.txt

29
MakefileVenv Normal file
View File

@ -0,0 +1,29 @@
PY_MINOR=11
VENV_NAME=.venv_$(PY_MINOR)
VENV=$(CURDIR)/$(VENV_NAME)
python=$(VENV)/bin/python
pip=$(python) -m pip
_delete_venv:
( [ -d $(VENV_NAME) ] && rm -fr $(VENV_NAME) ) || echo "no venv to drop"
_create_venv:
python3.$(PY_MINOR) -m venv $(VENV_NAME)
clean: _delete_venv _create_venv
install:
$(python) -m pip install -r requirements.txt
test:
$(python) -m unittest --discover .
run:
$(python) dev.py

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
-i https://pypi.org/simple

5
requirements_dev.txt Normal file
View File

@ -0,0 +1,5 @@
-i https://pypi.org/simple
iniconfig==2.0.0 ; python_version >= '3.7'
packaging==23.1 ; python_version >= '3.7'
pluggy==1.2.0 ; python_version >= '3.7'
pytest==7.4.0

38
test_guidelines.py Normal file
View File

@ -0,0 +1,38 @@
"""
Testing guidelines and install
"""
import unittest
from subprocess import run
import pathlib
class TestGuidelines(unittest.TestCase):
def test_git(self):
"The poj"
assert run(["git", "status"], check=True)
def test_has_requirement(self):
root_dir = run(
["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True
).stdout.strip()
target = pathlib.Path(root_dir) / "requirements.txt"
assert target.exists()
assert target.isFile()
def test_environment(self):
"""We want to make sure that the project is virtualenv compatible.
we may provie and extra makefile for that (and automate build phase)
"""
venv = "-f", "MakefileVenv"
for step in ["clean", "install", "test"]:
with self.subTest(setp=step):
try:
run(["make", *venv, step], check=True)
except Exception as E:
print(E.output)
raise