|
1 |
| -# Copyright 2021 The MLX Contributors |
| 1 | +# Copyright 2021-2022 The MLX Contributors |
2 | 2 | #
|
3 | 3 | # SPDX-License-Identifier: Apache-2.0
|
4 | 4 |
|
5 | 5 | # Acknowledgements:
|
6 | 6 | # - The help target was derived from https://stackoverflow.com/a/35730328/5601796
|
7 | 7 |
|
| 8 | +VENV ?= .venv |
| 9 | +export VIRTUAL_ENV := $(abspath ${VENV}) |
| 10 | +export PATH := ${VIRTUAL_ENV}/bin:${PATH} |
| 11 | +GITHUB_ACTION ?= false |
| 12 | + |
8 | 13 | .PHONY: help
|
9 | 14 | help: ## List the Make targets with description
|
10 | 15 | @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
|
11 | 16 | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'
|
12 | 17 |
|
| 18 | +.PHONY: venv |
| 19 | +venv: $(VENV)/bin/activate ## Create and activate Python virtual environment |
| 20 | +$(VENV)/bin/activate: api/client/setup.py api/server/setup.py api/server/requirements.txt |
| 21 | +# create/update the VENV when there was a change to setup.py or requirements.txt |
| 22 | +# check if api server or client is already installed (Travis/CI did during install step) |
| 23 | +# use pip from the specified VENV as opposed to any pip available in the shell |
| 24 | + @echo "VENV=$(VENV)" |
| 25 | + @test -d $(VENV) || python3 -m venv $(VENV) |
| 26 | + @$(VENV)/bin/pip show mlx-api >/dev/null 2>&1 || $(VENV)/bin/pip install -e api/server && $(VENV)/bin/pip install -r api/server/requirements.txt |
| 27 | + @$(VENV)/bin/pip show mlx-client >/dev/null 2>&1 || $(VENV)/bin/pip install -e api/client && $(VENV)/bin/pip install -r api/client/requirements.txt |
| 28 | + @if [ "$(GITHUB_ACTION)" = "false" ]; then touch $(VENV)/bin/activate; fi |
| 29 | + |
| 30 | +.PHONY: install |
| 31 | +install: venv ## Install Python packages in a virtual environment |
| 32 | + @echo "Run 'source $(VENV)/bin/activate' to activate the virtual environment." |
| 33 | + |
13 | 34 | .PHONY: check_npm_packages
|
14 | 35 | check_npm_packages: ## Verify NPM packages
|
15 | 36 | @python3 tools/python/verify_npm_packages.py --verify
|
@@ -39,15 +60,19 @@ check_license: ## Make sure source files have license header
|
39 | 60 |
|
40 | 61 | .PHONY: lint_python
|
41 | 62 | lint_python: venv ## Check Python code style compliance
|
42 |
| - @which flake8 > /dev/null || pip install flake8 || pip3 install flake8 |
43 |
| - @flake8 . --show-source --statistics \ |
| 63 | + @which flake8 > /dev/null || pip install flake8 |
| 64 | + @flake8 api/server api/client tools/python --show-source --statistics \ |
44 | 65 | --select=E9,E2,E3,E5,F63,F7,F82,F4,F841,W291,W292 \
|
45 |
| - --per-file-ignores ./*:F841 \ |
| 66 | + --per-file-ignores api/server/swagger_server/controllers/*,api/server/swagger_server/models/*,api/client/swagger_client/models/*,api/client/test/*:E252,F401,W291 \ |
46 | 67 | --exclude .git,__pycache__,docs/source/conf.py,old,build,dist,venv \
|
47 | 68 | --max-line-length=140
|
48 | 69 | @echo "$@: OK"
|
49 | 70 |
|
50 | 71 | .PHONY: lint_javascript
|
51 | 72 | lint_javascript: ## Check Javascript code style compliance
|
52 |
| - @cd dashboard/origin-mlx && npm run lint -- --fix |
| 73 | + @cd dashboard/origin-mlx && npm run lint:fix |
| 74 | + @echo "$@: OK" |
| 75 | + |
| 76 | +.PHONY: lint |
| 77 | +lint: lint_javascript lint_python ## Check for code style violations (JavaScript, Python) |
53 | 78 | @echo "$@: OK"
|
0 commit comments