Joey Armstrong | 28eddda | 2023-01-10 03:09:34 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | ## ----------------------------------------------------------------------- |
Joey Armstrong | beef4cd | 2023-01-18 09:59:58 -0500 | [diff] [blame] | 3 | # Copyright 2017-2023 Open Networking Foundation |
Joey Armstrong | 28eddda | 2023-01-10 03:09:34 -0500 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | ## ----------------------------------------------------------------------- |
| 17 | |
Joey Armstrong | 3f575f7 | 2023-01-15 23:49:19 -0500 | [diff] [blame] | 18 | $(if $(DEBUG),$(warning ENTER)) |
Joey Armstrong | 28eddda | 2023-01-10 03:09:34 -0500 | [diff] [blame] | 19 | |
Joey Armstrong | 8384f8b | 2023-02-06 12:46:08 -0500 | [diff] [blame] | 20 | ##-------------------## |
| 21 | ##---] GLOBALS [---## |
| 22 | ##-------------------## |
| 23 | .PHONY: venv |
| 24 | |
| 25 | ##------------------## |
| 26 | ##---] LOCALS [---## |
| 27 | ##------------------## |
Joey Armstrong | 3f575f7 | 2023-01-15 23:49:19 -0500 | [diff] [blame] | 28 | venv-name ?= .venv |
| 29 | venv-abs-path := $(PWD)/$(venv-name) |
| 30 | |
| 31 | venv-activate-script := $(venv-name)/bin/activate# # dependency |
| 32 | activate ?= source $(venv-activate-script)# # cmd invocation |
| 33 | |
| 34 | ## ----------------------------------------------------------------------- |
| 35 | ## Intent: Activate script path dependency |
| 36 | ## Usage: |
| 37 | ## o place on the right side of colon as a target dependency |
| 38 | ## o When the script does not exist install the virtual env and display. |
| 39 | ## ----------------------------------------------------------------------- |
| 40 | $(venv-activate-script): |
| 41 | virtualenv -p python3 $(venv-name)\ |
| 42 | && source $(venv-name)/bin/activate\ |
| 43 | && python -m pip install --upgrade pip\ |
| 44 | && pip install --upgrade setuptools\ |
| 45 | && { [[ -r requirements.txt ]] && python -m pip install -r requirements.txt; }\ |
| 46 | && python --version |
| 47 | |
| 48 | ## ----------------------------------------------------------------------- |
| 49 | ## Intent: Explicit named installer target w/o dependencies. |
| 50 | ## Makefile targets should depend on venv-activate-script. |
| 51 | ## ----------------------------------------------------------------------- |
| 52 | venv: $(venv-activate-script) |
| 53 | |
| 54 | ## ----------------------------------------------------------------------- |
| 55 | ## Intent: Revert installation to a clean checkout |
| 56 | ## ----------------------------------------------------------------------- |
| 57 | sterile :: clean |
| 58 | $(RM) -r "$(venv-abs-path)" |
| 59 | |
| 60 | ## ----------------------------------------------------------------------- |
| 61 | ## ----------------------------------------------------------------------- |
| 62 | help :: |
| 63 | @echo |
| 64 | @echo '[VIRTUAL ENV]' |
Joey Armstrong | 068d645 | 2023-02-01 11:09:18 -0500 | [diff] [blame] | 65 | @echo ' venv Create a python virtual environment' |
| 66 | @echo ' venv-name= Subdir name for virtualenv install' |
Joey Armstrong | a516c32 | 2023-01-25 17:40:42 -0500 | [diff] [blame] | 67 | @echo ' venv-activate-script make macro name' |
| 68 | @echo ' $$(target) dependency install python virtualenv' |
| 69 | @echo ' source $$(macro) && cmd configure env and run cmd' |
Joey Armstrong | 3f575f7 | 2023-01-15 23:49:19 -0500 | [diff] [blame] | 70 | |
| 71 | $(if $(DEBUG),$(warning LEAVE)) |
Joey Armstrong | 28eddda | 2023-01-10 03:09:34 -0500 | [diff] [blame] | 72 | |
| 73 | # [EOF] |