From: "Rebecca Cran" <rebecca@bsdio.com>
To: devel@edk2.groups.io, Andrew Fish <afish@apple.com>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Bob Feng <bob.c.feng@intel.com>,
Yuwei Chen <yuwei.chen@intel.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Subject: [PATCH v2 4/7] BaseTools: Remove Python2/Python3 detection from toolset.bat
Date: Sat, 6 May 2023 11:23:59 -0600 [thread overview]
Message-ID: <20230506172402.116-5-rebecca@bsdio.com> (raw)
In-Reply-To: <20230506172402.116-1-rebecca@bsdio.com>
Since Python3 is now required, we can remove the checks for PYTHON3_ENABLE
and PYTHON3 and simplify the code in toolsetup.bat. Also, remove the
leftover from when we supported freezing Python code.
While here, fix a couple of typos and improve error messages.
Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
---
BaseTools/toolsetup.bat | 64 +++++---------------
1 file changed, 16 insertions(+), 48 deletions(-)
diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat
index 25d13d559cd6..3d13e9fad286 100755
--- a/BaseTools/toolsetup.bat
+++ b/BaseTools/toolsetup.bat
@@ -305,18 +305,8 @@ goto check_build_environment
)
:defined_python
-if defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (
- goto check_python_available
-)
-if defined PYTHON3_ENABLE (
- if "%PYTHON3_ENABLE%" EQU "TRUE" (
- set PYTHON_COMMAND=py -3
- goto check_python_available
- ) else (
- goto check_python2
- )
-)
-if not defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (
+
+if not defined PYTHON_COMMAND (
set PYTHON_COMMAND=py -3
py -3 %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1
setlocal enabledelayedexpansion
@@ -328,56 +318,40 @@ if not defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (
set PYTHON_COMMAND=
echo.
echo !!! ERROR !!! Binary python tools are missing.
- echo PYTHON_COMMAND, PYTHON3_ENABLE or PYTHON_HOME
- echo Environment variable is not set successfully.
- echo They is required to build or execute the python tools.
+ echo PYTHON_COMMAND or PYTHON_HOME
+ echo Environment variable is not set correctly.
+ echo They are required to build or execute the python tools.
echo.
goto end
- ) else (
- goto check_python2
)
- ) else (
- goto check_freezer_path
)
)
-:check_python2
endlocal
+
if defined PYTHON_HOME (
if EXIST "%PYTHON_HOME%" (
set PYTHON_COMMAND=%PYTHON_HOME%\python.exe
- goto check_python_available
+ ) else (
+ echo .
+ echo !!! ERROR !!! PYTHON_HOME="%PYTHON_HOME%" does not exist.
+ echo .
+ goto end
)
)
-if defined PYTHONHOME (
- if EXIST "%PYTHONHOME%" (
- set PYTHON_HOME=%PYTHONHOME%
- set PYTHON_COMMAND=%PYTHON_HOME%\python.exe
- goto check_python_available
- )
-)
-echo.
-echo !!! ERROR !!! PYTHON_HOME is not defined or The value of this variable does not exist
-echo.
-goto end
-:check_python_available
+
%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1
setlocal enabledelayedexpansion
set /p PythonCheck=<"PythonCheck.txt"
del PythonCheck.txt
if "!PythonCheck!" NEQ "TRUE" (
echo.
- echo ! ERROR ! "%PYTHON_COMMAND%" is not installed or added to environment variables
+ echo ! ERROR ! PYTHON_COMMAND="%PYTHON_COMMAND%" is not installed or added to environment variables
echo.
goto end
- ) else (
- goto check_freezer_path
- )
+)
-
-
-:check_freezer_path
- endlocal
+endlocal
%PYTHON_COMMAND% -c "import edk2basetools" >NUL 2>NUL
if %ERRORLEVEL% EQU 0 (
@@ -404,13 +378,7 @@ goto end
:print_python_info
echo PATH = %PATH%
- if defined PYTHON3_ENABLE if "%PYTHON3_ENABLE%" EQU "TRUE" (
- echo PYTHON3_ENABLE = %PYTHON3_ENABLE%
- echo PYTHON3 = %PYTHON_COMMAND%
- ) else (
- echo PYTHON3_ENABLE = FALSE
- echo PYTHON_COMMAND = %PYTHON_COMMAND%
- )
+ echo PYTHON_COMMAND = %PYTHON_COMMAND%
echo PYTHONPATH = %PYTHONPATH%
echo.
--
2.40.0.windows.1
next prev parent reply other threads:[~2023-05-06 17:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-06 17:23 [PATCH v2 0/7] edksetup.bat, BaseTools: Improve Windows environment setup and BaseTools C compilation Rebecca Cran
2023-05-06 17:23 ` [PATCH v2 1/7] BaseSynchronizationLib: Fix LoongArch64 synchronization functions Rebecca Cran
2023-05-06 17:23 ` [PATCH v2 2/7] OvmfPkg: move OvmfTpmPei.fdf.inc to Include/Fdf Rebecca Cran
2023-05-06 17:23 ` [PATCH v2 3/7] OvmfPkg: move OvmfTpmDxe.fdf.inc " Rebecca Cran
2023-05-06 17:23 ` Rebecca Cran [this message]
2023-05-06 17:24 ` [PATCH v2 5/7] BaseTools: use threading.current_thread in NmakeSubdirs.py Rebecca Cran
2023-05-06 17:24 ` [PATCH v2 6/7] edksetup.bat: if toolsetup.bat fails, just exit Rebecca Cran
2023-05-06 17:24 ` [PATCH v2 7/7] BaseTools: Update toolsetup.bat and Tests/PythonTest.py to check ver Rebecca Cran
2023-05-06 19:16 ` [edk2-devel] [PATCH v2 0/7] edksetup.bat, BaseTools: Improve Windows environment setup and BaseTools C compilation Pedro Falcato
2023-05-06 19:32 ` Rebecca Cran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230506172402.116-5-rebecca@bsdio.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox