From becea40287973d63214e469b85a3d557ce194c6e Mon Sep 17 00:00:00 2001 From: Chin Yeung Li Date: Fri, 2 Jul 2021 16:52:56 +0800 Subject: [PATCH] Fixed #27 and Fixed #28 - Update configuration scripts - configuration scripts will now check if wget/curl is installed - no longer using tmp as the virtualenv Signed-off-by: Chin Yeung Li --- .gitignore | 1 + .travis.yml | 2 +- azure-pipelines.yml | 14 +++++------ configure | 25 ++++++++++++------- configure.bat | 58 +++++++++++++++++++++++++-------------------- 5 files changed, 58 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 68de2d2273..b61e5c430f 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ /share/ /tcl/ /.eggs/ +/etc/thirdparty/ # Installer logs pip-log.txt diff --git a/.travis.yml b/.travis.yml index 1a90a38568..514b94764a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,4 +19,4 @@ python: install: ./configure --dev # Scripts to run at script stage -script: tmp/bin/pytest +script: bin/pytest diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 31ef36f096..f12e0331f0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,7 +13,7 @@ jobs: image_name: ubuntu-16.04 python_versions: ['3.6', '3.7', '3.8', '3.9'] test_suites: - all: tmp/bin/pytest -vvs + all: bin/pytest -vvs - template: etc/ci/azure-posix.yml parameters: @@ -21,7 +21,7 @@ jobs: image_name: ubuntu-18.04 python_versions: ['3.6', '3.7', '3.8', '3.9'] test_suites: - all: tmp/bin/pytest -n 2 -vvs + all: bin/pytest -n 2 -vvs - template: etc/ci/azure-posix.yml parameters: @@ -29,7 +29,7 @@ jobs: image_name: ubuntu-20.04 python_versions: ['3.6', '3.7', '3.8', '3.9'] test_suites: - all: tmp/bin/pytest -n 2 -vvs + all: bin/pytest -n 2 -vvs - template: etc/ci/azure-posix.yml parameters: @@ -37,7 +37,7 @@ jobs: image_name: macos-10.14 python_versions: ['3.6', '3.7', '3.8', '3.9'] test_suites: - all: tmp/bin/pytest -n 2 -vvs + all: bin/pytest -n 2 -vvs - template: etc/ci/azure-posix.yml parameters: @@ -45,7 +45,7 @@ jobs: image_name: macos-10.15 python_versions: ['3.6', '3.7', '3.8', '3.9'] test_suites: - all: tmp/bin/pytest -n 2 -vvs + all: bin/pytest -n 2 -vvs - template: etc/ci/azure-win.yml parameters: @@ -53,7 +53,7 @@ jobs: image_name: vs2017-win2016 python_versions: ['3.6', '3.7', '3.8', '3.9'] test_suites: - all: tmp\Scripts\pytest -n 2 -vvs + all: Scripts\pytest -n 2 -vvs - template: etc/ci/azure-win.yml parameters: @@ -61,4 +61,4 @@ jobs: image_name: windows-2019 python_versions: ['3.6', '3.7', '3.8', '3.9'] test_suites: - all: tmp\Scripts\pytest -n 2 -vvs + all: Scripts\pytest -n 2 -vvs diff --git a/configure b/configure index 25ab0ce9ca..5a2519facd 100755 --- a/configure +++ b/configure @@ -30,12 +30,17 @@ REQUIREMENTS="--editable ." DEV_REQUIREMENTS="--editable .[testing]" # where we create a virtualenv -VIRTUALENV_DIR=tmp +VIRTUALENV_DIR=. # Cleanable files and directories with the --clean option CLEANABLE=" build - tmp" + tmp + bin + Lib + Scripts + pyvenv.cfg + etc/thirdparty/virtualenv.pyz" # extra arguments passed to pip PIP_EXTRA_ARGS=" " @@ -115,12 +120,16 @@ create_virtualenv() { if [ ! -f "$CFG_BIN_DIR/python" ]; then mkdir -p "$CFG_ROOT_DIR/$VENV_DIR" - - if [ -f "$CFG_ROOT_DIR/etc/thirdparty/virtualenv.pyz" ]; then - VIRTUALENV_PYZ="$CFG_ROOT_DIR/etc/thirdparty/virtualenv.pyz" - else - VIRTUALENV_PYZ="$CFG_ROOT_DIR/$VENV_DIR/virtualenv.pyz" - wget -O "$VIRTUALENV_PYZ" "$VIRTUALENV_PYZ_URL" + VIRTUALENV_PYZ="$CFG_ROOT_DIR/etc/thirdparty/virtualenv.pyz" + + if [ ! -f VIRTUALENV_PYZ ]; then + if [ -x "$(which wget)" ] ; then + wget -O "$VIRTUALENV_PYZ" "$VIRTUALENV_PYZ_URL" + elif [ -x "$(which curl)" ]; then + curl -o "$VIRTUALENV_PYZ" "$VIRTUALENV_PYZ_URL" + else + echo "Could not find curl or wget, please install one." >&2 + fi fi $PYTHON_EXECUTABLE "$VIRTUALENV_PYZ" \ diff --git a/configure.bat b/configure.bat index bafa126e93..cdf4aa6997 100644 --- a/configure.bat +++ b/configure.bat @@ -28,10 +28,10 @@ set "REQUIREMENTS=--editable ." set "DEV_REQUIREMENTS=--editable .[testing]" @rem # where we create a virtualenv -set "VIRTUALENV_DIR=tmp" +set "VIRTUALENV_DIR=." @rem # Cleanable files and directories to delete with the --clean option -set "CLEANABLE=build tmp" +set "CLEANABLE=build tmp bin Lib Scripts pyvenv.cfg etc\thirdparty\virtualenv.pyz" @rem # extra arguments passed to pip set "PIP_EXTRA_ARGS= " @@ -90,37 +90,39 @@ if not defined PYTHON_EXECUTABLE ( @rem # presence is not consistent across Linux distro and sometimes pip is not @rem # included either by default. The virtualenv.pyz app cures all these issues. -if not exist ""%CFG_BIN_DIR%\python.exe"" ( +if not exist "%CFG_BIN_DIR%\python.exe" ( if not exist "%CFG_BIN_DIR%" ( mkdir %CFG_BIN_DIR% ) - if exist ""%CFG_ROOT_DIR%\etc\thirdparty\virtualenv.pyz"" ( - %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%\etc\thirdparty\virtualenv.pyz" ^ - --wheel embed --pip embed --setuptools embed ^ - --seeder pip ^ - --never-download ^ - --no-periodic-update ^ - --no-vcs-ignore ^ - %CFG_QUIET% ^ - %CFG_ROOT_DIR%\%VIRTUALENV_DIR% - ) else ( - if not exist ""%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\virtualenv.pyz"" ( - curl -o "%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\virtualenv.pyz" %VIRTUALENV_PYZ_URL% - - if %ERRORLEVEL% neq 0 ( - exit /b %ERRORLEVEL% + if not exist "%CFG_ROOT_DIR%\etc\thirdparty\virtualenv.pyz" ( + @rem # Check if curl or wget is installed + where curl >nul 2>nul + if %ERRORLEVEL% == 0 ( + curl -o "%CFG_ROOT_DIR%\etc\thirdparty\virtualenv.pyz" %VIRTUALENV_PYZ_URL% + ) else ( + where wget >nul 2>nul + if %ERRORLEVEL% == 0 ( + wget -O "%CFG_ROOT_DIR%\etc\thirdparty\virtualenv.pyz" %VIRTUALENV_PYZ_URL% + ) else ( + echo "Please download and install curl or wget." + exit /b ) ) - %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\virtualenv.pyz" ^ - --wheel embed --pip embed --setuptools embed ^ - --seeder pip ^ - --never-download ^ - --no-periodic-update ^ - --no-vcs-ignore ^ - %CFG_QUIET% ^ - %CFG_ROOT_DIR%\%VIRTUALENV_DIR% + + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) ) + + %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%\etc\thirdparty\virtualenv.pyz" ^ + --wheel embed --pip embed --setuptools embed ^ + --seeder pip ^ + --never-download ^ + --no-periodic-update ^ + --no-vcs-ignore ^ + %CFG_QUIET% ^ + %CFG_ROOT_DIR%\%VIRTUALENV_DIR% ) if %ERRORLEVEL% neq 0 ( @@ -142,7 +144,11 @@ if %ERRORLEVEL% neq 0 ( %PIP_EXTRA_ARGS% ^ %CFG_REQUIREMENTS% + @rem # Create junction to bin to have the same directory between linux and windows +if exist ""%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\bin"" ( + rmdir /s /q "%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\bin" + ) mklink /J %CFG_ROOT_DIR%\%VIRTUALENV_DIR%\bin %CFG_ROOT_DIR%\%VIRTUALENV_DIR%\Scripts if %ERRORLEVEL% neq 0 (