From 60c3fa7ee9eb32213634ee91d8ba0a32cf9a0a87 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 25 Jul 2018 14:07:59 -0700 Subject: [PATCH] Handle windows python --- Makefile | 5 ++--- python/jsbeautifier/tests/shell-smoke-test.sh | 8 ++++---- tools/python-dev | 16 ++++++++++++++++ tools/python-rel | 16 ++++++++++++++++ 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100755 tools/python-dev create mode 100755 tools/python-rel diff --git a/Makefile b/Makefile index 224b837cc..884e306a8 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ python/dist/*: $(BUILD_DIR)/python $(wildcard python/**/*.py) python/jsbeautifie rm -f python/dist/* @cd python && \ $(PYTHON) setup.py sdist - ./build/python-rel/bin/pip install -U python/dist/* + $(SCRIPT_DIR)/python-rel pip install -U python/dist/* # Test generation $(BUILD_DIR)/generate: $(BUILD_DIR)/node test/generate-tests.js $(wildcard test/data/**/*) @@ -92,8 +92,7 @@ $(BUILD_DIR)/node: package.json package-lock.json | $(BUILD_DIR) $(BUILD_DIR)/python: python/setup.py | $(BUILD_DIR) $(BUILD_DIR)/virtualenv @$(PYTHON) --version - ls -alR ./build - ./build/python-dev/bin/pip install -e ./python + $(SCRIPT_DIR)/python-dev pip install -e ./python @touch $(BUILD_DIR)/python $(BUILD_DIR)/virtualenv: | $(BUILD_DIR) diff --git a/python/jsbeautifier/tests/shell-smoke-test.sh b/python/jsbeautifier/tests/shell-smoke-test.sh index 1edb1344d..9ff39b6a5 100755 --- a/python/jsbeautifier/tests/shell-smoke-test.sh +++ b/python/jsbeautifier/tests/shell-smoke-test.sh @@ -310,7 +310,7 @@ test_smoke_js_beautify() { echo ---------------------------------------- echo Testing beautify functionality... - $SCRIPT_DIR/../../js-beautify-test.py || exit 1 + $SCRIPT_DIR/../../../tools/python-dev python $SCRIPT_DIR/../../js-beautify-test.py || exit 1 } test_perf_js_beautify() @@ -326,11 +326,11 @@ main() { #test_cli_common css-beautify #test_cli_common html-beautify - test_cli_common js-beautify $SCRIPT_DIR/../../../build/python-dev/bin/js-beautify - test_cli_common js-beautify $SCRIPT_DIR/../../../build/python-rel/bin/js-beautify + test_cli_common js-beautify "$SCRIPT_DIR/../../../tools/python-dev js-beautify" + test_cli_common js-beautify "$SCRIPT_DIR/../../../tools/python-rel js-beautify" - test_cli_js_beautify $SCRIPT_DIR/../../../build/python-dev/bin/js-beautify + test_cli_js_beautify "$SCRIPT_DIR/../../../tools/python-dev js-beautify" test_perf_js_beautify echo ---------------------------------------- diff --git a/tools/python-dev b/tools/python-dev new file mode 100755 index 000000000..570efb29b --- /dev/null +++ b/tools/python-dev @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +REL_SCRIPT_DIR="`dirname \"$0\"`" +SCRIPT_DIR="`( cd \"$REL_SCRIPT_DIR\" && pwd )`" +PROJECT_DIR="`( cd \"$SCRIPT_DIR/..\" && pwd )`" +PYTHON_ENV=python-dev + +if [ -d "$PROJECT_DIR/build/$PYTHON_ENV/Scripts" ]; then + RUN_FILE="$PROJECT_DIR/build/$PYTHON_ENV/Scripts/$1" +else + RUN_FILE="$PROJECT_DIR/build/$PYTHON_ENV/bin/$1" +fi + +shift + +$RUN_FILE $@ diff --git a/tools/python-rel b/tools/python-rel new file mode 100755 index 000000000..93bc6fb3f --- /dev/null +++ b/tools/python-rel @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +REL_SCRIPT_DIR="`dirname \"$0\"`" +SCRIPT_DIR="`( cd \"$REL_SCRIPT_DIR\" && pwd )`" +PROJECT_DIR="`( cd \"$SCRIPT_DIR/..\" && pwd )`" +PYTHON_ENV=python-rel + +if [ -d "$PROJECT_DIR/build/$PYTHON_ENV/Scripts" ]; then + RUN_FILE="$PROJECT_DIR/build/$PYTHON_ENV/Scripts/$1" +else + RUN_FILE="$PROJECT_DIR/build/$PYTHON_ENV/bin/$1" +fi + +shift + +$RUN_FILE $@