Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b8f3bb1

Browse filesBrowse files
cclausstargos
authored andcommitted
build: add lint-py which uses flake8
PR-URL: #21952 Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent 0f00ac9 commit b8f3bb1
Copy full SHA for b8f3bb1

File tree

Expand file treeCollapse file tree

3 files changed

+28
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+28
-1
lines changed
Open diff view settings
Collapse file

‎Makefile‎

Copy file name to clipboardExpand all lines: Makefile
+23-1Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,28 @@ lint-addon-docs: test/addons/.docbuildstamp
12081208
cpplint: lint-cpp
12091209
@echo "Please use lint-cpp instead of cpplint"
12101210

1211+
.PHONY: lint-py-build
1212+
# python -m pip install flake8
1213+
# Try with '--system' is to overcome systems that blindly set '--user'
1214+
lint-py-build:
1215+
@echo "Pip installing flake8 linter on $(shell $(PYTHON) --version)..."
1216+
$(PYTHON) -m pip install --upgrade -t tools/pip/site-packages flake8 || \
1217+
$(PYTHON) -m pip install --upgrade --system -t tools/pip/site-packages flake8
1218+
1219+
ifneq ("","$(wildcard tools/pip/site-packages)")
1220+
.PHONY: lint-py
1221+
# Lints the Python code with flake8.
1222+
# Flag the build if there are Python syntax errors or undefined names
1223+
lint-py:
1224+
PYTHONPATH=tools/pip $(PYTHON) -m flake8 . \
1225+
--count --show-source --statistics --select=E901,E999,F821,F822,F823 \
1226+
--exclude=deps,lib,src,tools/*_macros.py,tools/gyp,tools/jinja2,tools/pip
1227+
else
1228+
lint-py:
1229+
@echo "Python linting with flake8 is not avalible"
1230+
@echo "Run 'make lint-py-build'"
1231+
endif
1232+
12111233
.PHONY: lint
12121234
.PHONY: lint-ci
12131235
ifneq ("","$(wildcard tools/node_modules/eslint/)")
@@ -1221,7 +1243,7 @@ lint: ## Run JS, C++, MD and doc linters.
12211243
CONFLICT_RE=^>>>>>>> [0-9A-Fa-f]+|^<<<<<<< [A-Za-z]+
12221244

12231245
# Related CI job: node-test-linter
1224-
lint-ci: lint-js-ci lint-cpp lint-md lint-addon-docs
1246+
lint-ci: lint-js-ci lint-cpp lint-py lint-md lint-addon-docs
12251247
@if ! ( grep -IEqrs "$(CONFLICT_RE)" benchmark deps doc lib src test tools ) \
12261248
&& ! ( find . -maxdepth 1 -type f | xargs grep -IEqs "$(CONFLICT_RE)" ); then \
12271249
exit 0 ; \
Collapse file

‎tools/pip/.gitignore‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pyc
2+
site-packages
Collapse file

‎tools/pip/sitecustomize.py‎

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import os
2+
import site
3+
site.addsitedir(os.path.dirname(os.path.realpath(__file__)) + '/site-packages')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.