diff --git a/.rubocop.yml b/.rubocop.yml index fb5cfcd4..3e9d76d6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,6 +23,8 @@ AllCops: SuggestExtensions: false NewCops: enable + Exclude: + - 'venv/**/*' Layout/EmptyLineAfterGuardClause: Enabled: false diff --git a/Makefile b/Makefile index 049bbd34..41547c3c 100644 --- a/Makefile +++ b/Makefile @@ -63,6 +63,9 @@ define step set -e start=$$(date +%s%N) echo -e "\n\n\n+++ $(1) +++\n" + if [ -d "$(LOCAL)/venv" ]; then + source "$(LOCAL)/venv/bin/activate" + fi @bash $(LOCAL)/steps/$(1).sh echo "Finished$$("$${LOCAL}/help/tdiff.sh" "$${start}")" endef diff --git a/installs/install-pip.sh b/installs/install-pip.sh index 62d279a3..4e061a1f 100755 --- a/installs/install-pip.sh +++ b/installs/install-pip.sh @@ -27,7 +27,11 @@ set -o pipefail "${LOCAL}/help/assert-tool.sh" python3 --version "${LOCAL}/help/assert-tool.sh" pip3 --version -# see https://stackoverflow.com/a/76641565/187141 -rm -f /usr/lib/python3.*/EXTERNALLY-MANAGED +if [ ! -d "venv" ]; then + python3 -m venv venv +fi + +# shellcheck source=/dev/null +source venv/bin/activate pip3 install -r "${LOCAL}/requirements.txt" diff --git a/installs/install-texlive.sh b/installs/install-texlive-base.sh similarity index 100% rename from installs/install-texlive.sh rename to installs/install-texlive-base.sh diff --git a/steps/env.sh b/steps/env.sh index 5a47d116..8ebe268c 100755 --- a/steps/env.sh +++ b/steps/env.sh @@ -33,7 +33,7 @@ env bash_version=${BASH_VERSINFO:-0} if [ "${bash_version}" -lt 5 ]; then - "${SHELL}" -version + "${SHELL}" --version ps -p $$ echo "${SHELL} version is older than five: ${bash_version}" exit 1 diff --git a/steps/install.sh b/steps/install.sh index defd8e52..b7acfa7e 100755 --- a/steps/install.sh +++ b/steps/install.sh @@ -85,6 +85,16 @@ if ! inkscape --version >/dev/null 2>&1; then fi fi +if ! xmllint --version >/dev/null 2>&1; then + if "${LOCAL}/help/is-linux.sh"; then + "${LOCAL}/help/sudo.sh" apt-get install -y libxml2-utils + elif "${LOCAL}/help/is-macos.sh"; then + "${LOCAL}/help/sudo.sh" --as-user brew install libxml2 + else + "${LOCAL}/help/assert-tool.sh" xmllint --version + fi +fi + find "${LOCAL}/installs" -name 'install-*' | sort | while IFS= read -r i; do "${i}" done diff --git a/steps/lint.sh b/steps/lint.sh index abe4d2f6..d97ede02 100755 --- a/steps/lint.sh +++ b/steps/lint.sh @@ -27,11 +27,11 @@ cffconvert --validate mypy --strict "${LOCAL}/" -flake8 --max-line-length=140 "${LOCAL}/" +flake8 --max-line-length=140 --exclude venv "${LOCAL}/" export PYTHONPATH="${PYTHONPATH}:${LOCAL}/pylint_plugins/" -find "${LOCAL}" -type f -name '*.py' -print0 | xargs -0 -n1 pylint --enable-all-extensions --load-plugins=custom_checkers \ +find "${LOCAL}" -type f -name '*.py' -not -path "${LOCAL}/venv/**" -print0 | xargs -0 -n1 pylint --enable-all-extensions --load-plugins=custom_checkers \ --disable=empty-comment \ --disable=missing-module-docstring \ --disable=invalid-name \ @@ -53,7 +53,7 @@ bibcop tex/report.bib while IFS= read -r sh; do shellcheck --shell=bash --severity=style "${sh}" -done < <(find "$(realpath "${LOCAL}")" -name '*.sh' -type f -not -path "$(realpath "${TARGET}")/**") +done < <(find "$(realpath "${LOCAL}")" -name '*.sh' -type f -not -path "$(realpath "${TARGET}")/**" -not -path "$(realpath "${LOCAL}")/venv/**") header="Copyright (c) 2021-$(date +%Y) Yegor Bugayenko" failed="false" @@ -66,6 +66,7 @@ for mask in *.sh *.py *.rb *.yml *.java Makefile; do done < <(find "$(realpath "${LOCAL}")" -type f -name "${mask}" \ -not -path "$(realpath "${TARGET}")/**" \ -not -path "$(realpath "${LOCAL}")/fixtures/filters/unparseable/**" \ - -not -path "$(realpath "${LOCAL}")/test-zone/**") + -not -path "$(realpath "${LOCAL}")/test-zone/**" \ + -not -path "$(realpath "${LOCAL}")/venv/**") done if [[ "${failed}" = "true" ]]; then exit; fi