Create Makefile
Browse files
Makefile
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#################################################################################
|
| 2 |
+
# GLOBALS #
|
| 3 |
+
#################################################################################
|
| 4 |
+
|
| 5 |
+
PROJECT_NAME = prompt-injection
|
| 6 |
+
PYTHON_VERSION = 3.10
|
| 7 |
+
PYTHON_INTERPRETER = python
|
| 8 |
+
|
| 9 |
+
#################################################################################
|
| 10 |
+
# COMMANDS #
|
| 11 |
+
#################################################################################
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
## Install Python Dependencies
|
| 15 |
+
.PHONY: requirements
|
| 16 |
+
requirements:
|
| 17 |
+
$(PYTHON_INTERPRETER) -m pip install -U pip
|
| 18 |
+
$(PYTHON_INTERPRETER) -m pip install -r requirements.txt
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
## Delete all compiled Python files
|
| 24 |
+
.PHONY: clean
|
| 25 |
+
clean:
|
| 26 |
+
find . -type f -name "*.py[co]" -delete
|
| 27 |
+
find . -type d -name "__pycache__" -delete
|
| 28 |
+
|
| 29 |
+
## Lint using flake8 and black (use `make format` to do formatting)
|
| 30 |
+
.PHONY: lint
|
| 31 |
+
lint:
|
| 32 |
+
flake8 prompt_injection
|
| 33 |
+
isort --check --diff --profile black prompt_injection
|
| 34 |
+
black --check --config pyproject.toml prompt_injection
|
| 35 |
+
|
| 36 |
+
## Format source code with black
|
| 37 |
+
.PHONY: format
|
| 38 |
+
format:
|
| 39 |
+
black --config pyproject.toml prompt_injection
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
## Set up python interpreter environment
|
| 45 |
+
.PHONY: create_environment
|
| 46 |
+
create_environment:
|
| 47 |
+
|
| 48 |
+
conda create --name $(PROJECT_NAME) python=$(PYTHON_VERSION) -y
|
| 49 |
+
|
| 50 |
+
@echo ">>> conda env created. Activate with:\nconda activate $(PROJECT_NAME)"
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
#################################################################################
|
| 56 |
+
# PROJECT RULES #
|
| 57 |
+
#################################################################################
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
#################################################################################
|
| 62 |
+
# Self Documenting Commands #
|
| 63 |
+
#################################################################################
|
| 64 |
+
|
| 65 |
+
.DEFAULT_GOAL := help
|
| 66 |
+
|
| 67 |
+
define PRINT_HELP_PYSCRIPT
|
| 68 |
+
import re, sys; \
|
| 69 |
+
lines = '\n'.join([line for line in sys.stdin]); \
|
| 70 |
+
matches = re.findall(r'\n## (.*)\n[\s\S]+?\n([a-zA-Z_-]+):', lines); \
|
| 71 |
+
print('Available rules:\n'); \
|
| 72 |
+
print('\n'.join(['{:25}{}'.format(*reversed(match)) for match in matches]))
|
| 73 |
+
endef
|
| 74 |
+
export PRINT_HELP_PYSCRIPT
|
| 75 |
+
|
| 76 |
+
help:
|
| 77 |
+
@python -c "${PRINT_HELP_PYSCRIPT}" < $(MAKEFILE_LIST)
|