diff --git a/Makefile b/Makefile index d5ace8e..d4c37ed 100644 --- a/Makefile +++ b/Makefile @@ -7,10 +7,6 @@ DOCKER_CONTEXT_PREPROD := cookie-pulsheberg .PHONY: logs -# ifeq ($(OS),Windows_NT) -# else -# endif - all: start-f logs start: @@ -46,11 +42,6 @@ exec: exec-pp: @scripts/docker_service_exec.sh $(DOCKER_SERVICE_PREPROD) $(DOCKER_CONTEXT_PREPROD) -env-setup: - @python3 -m venv $(VENV_NAME) - @make env - @pip install -r requirements.txt - dev: @docker compose -f $(DOCKER_COMPOSE_FILE_DEV) up -d --remove-orphans --build diff --git a/README.md b/README.md index 7a51750..0876ff8 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,15 @@ Feel free to fork the project while adhering to the license and acknowledging th For seamless integration of your modifications, submitting pull requests to the original bot version is recommended. +## Setup local project + +Install virtual python environnement on Unix +``` +python -m venv .venv +source ./.venv/bin/activate +pip install -r requirements.txt +``` + ## License [MIT](https://choosealicense.com/licenses/mit/) diff --git a/scripts/environnement.py b/scripts/environnement.py index a48c8c3..7678679 100644 --- a/scripts/environnement.py +++ b/scripts/environnement.py @@ -1,6 +1,10 @@ import argparse import subprocess import sys +import os +import shutil + +from pathlib import Path def build_image(): subprocess.run("docker build -t local/pyramid .", shell=True) @@ -11,11 +15,26 @@ def build_images_archs(): def remove_dangling_images(): subprocess.run("docker --log-level debug image prune -f", shell=True) +def clean_python_cache(directory): + count = 0 + for root, dirs, files in os.walk(directory): + if '__pycache__' in dirs: + shutil.rmtree(os.path.join(root, '__pycache__')) + count += 1 + if '.pytest_cache' in dirs: + shutil.rmtree(os.path.join(root, '.pytest_cache')) + count += 1 + if '.coverage' in files: + os.remove(os.path.join(root, '.coverage')) + count += 1 + print(f"{count} python cache was deleted.") + def parse_arguments(): parser = argparse.ArgumentParser(description="Manage application environnement") parser.add_argument("--images-purge", action="store_true", help="Remove all Docker images without tags.") parser.add_argument("--build", action="store_true", help="Build docker image.") parser.add_argument("--build-archs", action="store_true", help="Build docker images for all supported arch.") + parser.add_argument("--clean", action="store_true", help="Delete python cache.") return parser.parse_args() def main(): @@ -28,6 +47,10 @@ def main(): build_images_archs() elif args.images_purge: remove_dangling_images() + elif args.clean: + current_file_directory = Path(__file__).resolve().parent + parent_directory = current_file_directory.parent + clean_python_cache(parent_directory) else: print("No action specified. Use --help for usage information.") return