From d96d38b0834e18eac4bc7888949ebd7a14c847f7 Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Tue, 2 Feb 2021 17:52:25 +0100 Subject: [PATCH] unix poetry --- pyproject.toml | 7 ++++++- tools/build.sh | 21 +++++++++------------ tools/create_env.sh | 39 ++++++++++++++++++++++----------------- tools/create_zip.sh | 11 ++--------- tools/make_docs.sh | 15 ++++----------- tools/run_mongo.sh | 1 - tools/run_settings.sh | 10 ++-------- tools/run_tests.sh | 13 ++++--------- tools/run_tray.sh | 11 ++--------- 9 files changed, 51 insertions(+), 77 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fc2e46ff41..52e8017500 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,11 @@ license = "MIT License" python = "3.7.*" aiohttp_json_rpc = "*" # TVPaint server acre = { git = "https://github.com/pypeclub/acre.git" } -opentimelineio = { git = "https://github.com/pypeclub/OpenTimelineIO.git", branch="develop" } +opentimelineio = [ + { git = "https://github.com/pypeclub/OpenTimelineIO.git", branch="develop", markers = "sys_platform == 'win32'" }, + { git = "git+https://github.com/PixarAnimationStudios/OpenTimelineIO.git", markers = "sys_platform == 'darwin'" } +] + appdirs = "^1.4.3" blessed = "^1.17" # pype terminal formatting clique = "1.5.*" @@ -31,6 +35,7 @@ speedcopy = "^2.1" six = "^1.15" wsrpc_aiohttp = "^3.1.1" # websocket server pywin32 = { version = "300", markers = "sys_platform == 'win32'" } +jinxed = { version = "^1.0.1", markers = "sys_platform == 'darwin'" } [tool.poetry.dev-dependencies] flake8 = "^3.7" diff --git a/tools/build.sh b/tools/build.sh index 44bb22c4a6..a0cc398a35 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -63,15 +63,16 @@ BIWhite='\033[1;97m' # White ############################################################################### detect_python () { echo -e "${BIGreen}>>>${RST} Using Python \c" - local version_command="import sys;print('{0}.{1}'.format(sys.version_info[0], sys.version_info[1]))" - local python_version="$(python3 <<< ${version_command})" + local version_command + version_command="import sys;print('{0}.{1}'.format(sys.version_info[0], sys.version_info[1]))" + local python_version + python_version="$(python3 <<< ${version_command})" oIFS="$IFS" IFS=. set -- $python_version IFS="$oIFS" if [ "$1" -ge "3" ] && [ "$2" -ge "6" ] ; then echo -e "${BIWhite}[${RST} ${BIGreen}$1.$2${RST} ${BIWhite}]${RST}" - PYTHON="python3" else command -v python3 >/dev/null 2>&1 || { echo -e "${BIRed}FAILED${RST} ${BIYellow} Version [${RST}${BICyan}$1.$2${RST}]${BIYellow} is old and unsupported${RST}"; return 1; } fi @@ -103,7 +104,7 @@ clean_pyc () { # None ############################################################################### realpath () { - echo $(cd $(dirname "$1"); pwd)/$(basename "$1") + echo $(cd $(dirname "$1") || return; pwd)/$(basename "$1") } # Main @@ -113,9 +114,8 @@ echo -e "${RST}" detect_python || return 1 # Directories -current_dir=$(realpath "$(pwd)") pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}")))) -pushd "$pype_root" > /dev/null +pushd "$pype_root" || return > /dev/null version_command="import os;exec(open(os.path.join('$pype_root', 'pype', 'version.py')).read());print(__version__);" pype_version="$(python3 <<< ${version_command})" @@ -124,14 +124,11 @@ echo -e "${BIYellow}---${RST} Cleaning build directory ..." rm -rf "$pype_root/build" && mkdir "$pype_root/build" > /dev/null echo -e "${BIGreen}>>>${RST} Building Pype ${BIWhite}[${RST} ${BIGreen}$pype_version${RST} ${BIWhite}]${RST}" -# echo -e "${BIGreen}>>>${RST} Entering venv ..." -source "$pype_root/venv/bin/activate" echo -e "${BIGreen}>>>${RST} Cleaning cache files ..." clean_pyc echo -e "${BIGreen}>>>${RST} Building ..." -python "$pype_root/setup.py" build > "$pype_root/build/build.log" -python -B "$pype_root/tools/build_dependencies.py" -echo -e "${BIGreen}>>>${RST} Deactivating venv ..." -deactivate +poetry run python "$pype_root/setup.py" build > "$pype_root/build/build.log" +poetry run python "$pype_root/tools/build_dependencies.py" + echo -e "${BICyan}>>>${RST} All done. You will find Pype and build log in \c" echo -e "${BIWhite}$pype_root/build${RST} directory." diff --git a/tools/create_env.sh b/tools/create_env.sh index c847d7345a..d053e740c2 100755 --- a/tools/create_env.sh +++ b/tools/create_env.sh @@ -78,6 +78,12 @@ detect_python () { fi } +install_poetry () { + echo -e "${BIGreen}>>>${RST} Installing Poetry ..." + curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - + export PATH="$PATH:$HOME/.poetry/bin" +} + ############################################################################## # Clean pyc files in specified directory # Globals: @@ -114,26 +120,25 @@ echo -e "${RST}" detect_python || return 1 # Directories -current_dir=$(realpath "$(pwd)") pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}")))) -pushd "$pype_root" > /dev/null +pushd "$pype_root" || return > /dev/null -echo -e "${BIYellow}---${RST} Cleaning venv directory ..." -rm -rf "$pype_root/venv" && mkdir "$pype_root/venv" +echo -e "${BIGreen}>>>${RST} Reading Poetry ... \c" +if [ -f "$HOME/.poetry/bin/poetry" ]; then + echo -e "${BIGreen}OK${RST}" +else + echo -e "${BIYellow}NOT FOUND${RST}" + install_poetry +fi -echo -e "${BIGreen}>>>${RST} Creating venv ..." -python3 -m venv "$pype_root/venv" +if [ -f "$pype_root/poetry.lock" ]; then + echo -e "${BIGreen}>>>${RST} Updating dependencies ..." + poetry update +else + echo -e "${BIGreen}>>>${RST} Installing dependencies ..." + poetry install +fi -echo -e "${BIGreen}>>>${RST} Entering venv ..." -source "$pype_root/venv/bin/activate" - -echo -e "${BIGreen}>>>${RST} Updatng pip ..." -python -m pip install --upgrade pip - -echo -e "${BIGreen}>>>${RST} Installing wheel ..." -python -m pip install wheel -echo -e "${BIGreen}>>>${RST} Installing packages to new venv ..." -pip install -r "$pype_root/requirements.txt" echo -e "${BIGreen}>>>${RST} Cleaning cache files ..." clean_pyc -deactivate + diff --git a/tools/create_zip.sh b/tools/create_zip.sh index f88a55dd0c..a44d9d4be9 100755 --- a/tools/create_zip.sh +++ b/tools/create_zip.sh @@ -113,15 +113,8 @@ echo -e "${RST}" detect_python || return 1 # Directories -current_dir=$(realpath "$(pwd)") pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}")))) -pushd "$pype_root" > /dev/null - -echo -e "${BIGreen}>>>${RST} Entering venv ..." -source "$pype_root/venv/bin/activate" +pushd "$pype_root" || return > /dev/null echo -e "${BIGreen}>>>${RST} Generating zip from current sources ..." -python "$pype_root/start.py" generate-zip $@ - -echo -e "${BIGreen}>>>${RST} Deactivating venv ..." -deactivate +poetry run python "$pype_root/start.py" generate-zip "$@" diff --git a/tools/make_docs.sh b/tools/make_docs.sh index 3d3d82770d..68582ff5ae 100755 --- a/tools/make_docs.sh +++ b/tools/make_docs.sh @@ -70,19 +70,12 @@ art echo -e "${RST}" # Directories -current_dir=$(realpath "$(pwd)") pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}")))) -pushd "$pype_root" > /dev/null - -echo -e "${BIGreen}>>>${RST} Entering venv ..." -source "$pype_root/venv/bin/activate" +pushd "$pype_root" || return > /dev/null echo -e "${BIGreen}>>>${RST} Running apidoc ..." -sphinx-apidoc.exe -M -e -d 10 --ext-intersphinx --ext-todo --ext-coverage --ext-viewcode -o "$pype_root/docs/source" igniter -sphinx-apidoc.exe -M -e -d 10 --ext-intersphinx --ext-todo --ext-coverage --ext-viewcode -o "$pype_root/docs/source" pype vendor, pype\vendor +poetry run sphinx-apidoc -M -e -d 10 --ext-intersphinx --ext-todo --ext-coverage --ext-viewcode -o "$pype_root/docs/source" igniter +poetry run sphinx-apidoc -M -e -d 10 --ext-intersphinx --ext-todo --ext-coverage --ext-viewcode -o "$pype_root/docs/source" pype vendor, pype\vendor echo -e "${BIGreen}>>>${RST} Building html ..." -python setup.py build_sphinx - -echo -e "${BIGreen}>>>${RST} Deactivating venv ..." -deactivate +poetry run python "$pype_root/setup.py" build_sphinx diff --git a/tools/run_mongo.sh b/tools/run_mongo.sh index 95966fc145..6f9e0f5411 100755 --- a/tools/run_mongo.sh +++ b/tools/run_mongo.sh @@ -71,7 +71,6 @@ art echo -e "${RST}" # Directories -current_dir=$(realpath "$(pwd)") pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}")))) pushd "$pype_root" > /dev/null diff --git a/tools/run_settings.sh b/tools/run_settings.sh index 9009d5d7da..dbf1c5ba30 100755 --- a/tools/run_settings.sh +++ b/tools/run_settings.sh @@ -113,15 +113,9 @@ echo -e "${RST}" detect_python || return 1 # Directories -current_dir=$(realpath "$(pwd)") pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}")))) -pushd "$pype_root" > /dev/null - -echo -e "${BIGreen}>>>${RST} Entering venv ..." -source "$pype_root/venv/bin/activate" +pushd "$pype_root" || return> /dev/null echo -e "${BIGreen}>>>${RST} Generating zip from current sources ..." -python "$pype_root/start.py" settings --dev +poetry run python "$pype_root/start.py" settings --dev -echo -e "${BIGreen}>>>${RST} Deactivating venv ..." -deactivate diff --git a/tools/run_tests.sh b/tools/run_tests.sh index eae47ab4b6..7e68e0b0ab 100755 --- a/tools/run_tests.sh +++ b/tools/run_tests.sh @@ -113,18 +113,13 @@ echo -e "${RST}" detect_python || return 1 # Directories -current_dir=$(realpath "$(pwd)") pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}")))) -pushd "$pype_root" > /dev/null - -echo -e "${BIGreen}>>>${RST} Entering venv ..." -source "$pype_root/venv/bin/activate" +pushd "$pype_root" || return > /dev/null echo -e "${BIGreen}>>>${RST} Testing Pype ..." original_pythonpath=$PYTHONPATH export PYTHONPATH="$pype_root:$PYTHONPATH" -pytest -x --capture=sys --print -W ignore::DeprecationWarning "$pype_root/tests" -$env:PYTHONPATH = $original_pythonpath +poetry run pytest -x --capture=sys --print -W ignore::DeprecationWarning "$pype_root/tests" +PYTHONPATH=$original_pythonpath + -echo -e "${BIGreen}>>>${RST} Deactivating venv ..." -deactivate diff --git a/tools/run_tray.sh b/tools/run_tray.sh index b4979b578a..d7d3b979dc 100755 --- a/tools/run_tray.sh +++ b/tools/run_tray.sh @@ -113,15 +113,8 @@ echo -e "${RST}" detect_python || return 1 # Directories -current_dir=$(realpath "$(pwd)") pype_root=$(dirname $(realpath $(dirname $(dirname "${BASH_SOURCE[0]}")))) -pushd "$pype_root" > /dev/null - -echo -e "${BIGreen}>>>${RST} Entering venv ..." -source "$pype_root/venv/bin/activate" +pushd "$pype_root" || return > /dev/null echo -e "${BIGreen}>>>${RST} Running Pype Tray with debug option ..." -python "$pype_root/start.py" tray --debug - -echo -e "${BIGreen}>>>${RST} Deactivating venv ..." -deactivate +poetry run python "$pype_root/start.py" tray --debug