summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2023-03-31 18:47:59 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2023-03-31 18:47:59 +0200
commit6b8700270e2c32e876dfca081dbbec832aa4e7a0 (patch)
tree8854826529acd9042acc4d10d2ea92c773e0432b
parent7d55ce4e3d81705264398a15ffaa1896f4e1aefc (diff)
downloadpsutil-6b8700270e2c32e876dfca081dbbec832aa4e7a0.tar.gz
Makefile: define num CPUs for parallel workers
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
-rw-r--r--Makefile11
1 files changed, 6 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index f5472bf4..7bbb0693 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,7 @@ PY2_DEPS = \
mock
PY_DEPS = `$(PYTHON) -c \
"import sys; print('$(PY3_DEPS)' if sys.version_info[0] == 3 else '$(PY2_DEPS)')"`
+NUM_WORKERS = `$(PYTHON) -c "import os; print(os.cpu_count() or 1)"`
# "python3 setup.py build" can be parallelized on Python >= 3.6.
BUILD_OPTS = `$(PYTHON) -c \
"import sys, os; \
@@ -191,10 +192,10 @@ test-coverage: ## Run test coverage.
# ===================================================================
flake8: ## Run flake8 linter.
- @git ls-files '*.py' | xargs $(PYTHON) -m flake8 --config=.flake8
+ @git ls-files '*.py' | xargs $(PYTHON) -m flake8 --config=.flake8 --jobs=${NUM_WORKERS}
isort: ## Run isort linter.
- @git ls-files '*.py' | xargs $(PYTHON) -m isort --check-only
+ @git ls-files '*.py' | xargs $(PYTHON) -m isort --check-only --jobs=${NUM_WORKERS}
c-linter: ## Run C linter.
@git ls-files '*.c' '*.h' | xargs $(PYTHON) scripts/internal/clinter.py
@@ -209,11 +210,11 @@ lint-all: ## Run all linters
# ===================================================================
fix-flake8: ## Run autopep8, fix some Python flake8 / pep8 issues.
- @git ls-files '*.py' | xargs $(PYTHON) -m autopep8 --in-place --jobs 0 --global-config=.flake8
- @git ls-files '*.py' | xargs $(PYTHON) -m autoflake --in-place --jobs 0 --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys
+ @git ls-files '*.py' | xargs $(PYTHON) -m autopep8 --in-place --jobs=${NUM_WORKERS} --global-config=.flake8
+ @git ls-files '*.py' | xargs $(PYTHON) -m autoflake --in-place --jobs=${NUM_WORKERS} --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys
fix-imports: ## Fix imports with isort.
- @git ls-files '*.py' | xargs $(PYTHON) -m isort
+ @git ls-files '*.py' | xargs $(PYTHON) -m isort --jobs=${NUM_WORKERS}
fix-all: ## Run all code fixers.
${MAKE} fix-flake8