diff --git a/doctools/src-tree.sh b/doctools/src-tree.sh index 574377992..c1f422c25 100755 --- a/doctools/src-tree.sh +++ b/doctools/src-tree.sh @@ -16,6 +16,10 @@ source build/common.sh # log export PYTHONPATH=. +src-tree-py() { + PYTHONPATH='.:vendor/' doctools/src_tree.py "$@" +} + install-deps() { sudo apt-get install moreutils # for isutf8 } @@ -141,7 +145,7 @@ all-html-to-files() { log "=== $lang ===" cat $BASE_DIR/$lang.txt | xargs _tmp/micro-syntax/micro_syntax -l $lang -w \ - | doctools/src_tree.py write-html-fragments $out_dir + | $0 src-tree-py write-html-fragments $out_dir log '' done } @@ -184,7 +188,7 @@ highlight() { time all-html-to-files $www_dir > $attrs # Now write index.html dir listings - time doctools/src_tree.py dirs $www_dir < $attrs + time src-tree-py dirs $www_dir < $attrs } soil-run() { diff --git a/doctools/ul-table-test.ysh b/doctools/ul-table-test.ysh index 6ed5b13af..3c3b2fd07 100755 --- a/doctools/ul-table-test.ysh +++ b/doctools/ul-table-test.ysh @@ -53,9 +53,14 @@ source $LIB_OSH/task-five.sh #source $LIB_YSH/yblocks.ysh proc run-py { + ### Run with the shebang setting PYTHONPATH='.:vendor/' @ARGV } +proc run-py3 { + PYTHONPATH='.' python3 @ARGV +} + deps() { # Good: only 3 files: ul_table, lazylex/html, util.py build/dynamic-deps.sh py-tool doctools.ul_table @@ -76,7 +81,7 @@ test-unit-py2() { # Problem: We import cmark, which imports ctypes test-unit-py3() { # like test/unit.sh - run-py python3 doctools/ul_table_test.py + run-py3 doctools/ul_table_test.py } # Taken from unit test @@ -116,7 +121,7 @@ test-without-cmark-py2() { } test-without-cmark-py3() { - echo $TD_ATTRS | cmark-bin --unsafe | run-py python3 doctools/ul_table.py + echo $TD_ATTRS | cmark-bin --unsafe | run-py3 doctools/ul_table.py } proc run-tests() { diff --git a/doctools/util.py b/doctools/util.py index 986913137..00903d8bb 100644 --- a/doctools/util.py +++ b/doctools/util.py @@ -1,12 +1,9 @@ #!/usr/bin/env python2 -"""util.py.""" from __future__ import print_function import sys -# Note: from typing import Any causes ImportError when PYTHONPATH is not .:vendor -# So we import from vendor.typing which is a little inconsistent -from vendor.typing import Any +from typing import Any def log(msg, *args): diff --git a/test/spec-runner.sh b/test/spec-runner.sh index 4821e7a4f..17010ef2c 100755 --- a/test/spec-runner.sh +++ b/test/spec-runner.sh @@ -345,12 +345,16 @@ all-parallel() { time $0 _all-parallel "$@" } +src-tree-py() { + PYTHONPATH='.:vendor/' doctools/src_tree.py "$@" +} + all-tests-to-html() { local manifest=$1 local output_base_dir=$2 # ignore attrs output head -n $NUM_SPEC_TASKS $manifest \ - | xargs --verbose -- doctools/src_tree.py spec-files $output_base_dir >/dev/null + | xargs --verbose -- $0 src-tree-py spec-files $output_base_dir >/dev/null #| xargs -n 1 -P $MAX_PROCS -- $0 test-to-html $output_base_dir log "done: all-tests-to-html"