@@ -198,25 +198,32 @@ echo [OK] Virtual environment ready at %VENV_DIR%
198198echo .
199199
200200:: ----------------------------------------------------------------------------
201- :: 4b. Upgrade pip, setuptools, wheel (required before any other installs)
202- :: --trusted-host flags handle corporate proxies with SSL inspection
201+ :: 4b. Ensure setuptools and wheel are available in the venv.
202+ :: Python 3.10 venv ships these by default, but verify to be safe.
203+ :: --trusted-host flags handle corporate proxies with SSL inspection.
203204:: ----------------------------------------------------------------------------
204205set " PIP_TRUST = --trusted-host pypi.org --trusted-host files.pythonhosted.org"
205206
206- echo Upgrading pip, setuptools, and wheel...
207- python -m pip install --upgrade pip setuptools wheel %PIP_TRUST% --quiet 2 >& 1
207+ :: Check if setuptools is already in the venv (it usually is from python -m venv)
208+ python -c " import setuptools" > nul 2 >& 1
208209if %errorlevel% neq 0 (
209- echo [WARNING] Could not upgrade pip. Trying with certificate verification disabled ...
210- python -m pip install --upgrade pip setuptools wheel %PIP_TRUST% --quiet --cert " " 2 > nul
210+ echo Bootstrapping setuptools and wheel ...
211+ python -m pip install --upgrade pip setuptools wheel %PIP_TRUST% --quiet 2 >& 1
211212 if %errorlevel% neq 0 (
212- echo [WARNING] pip upgrade failed. Continuing with existing pip version .
213- echo If installs fail below, check your network/proxy settings .
213+ echo [WARNING] Could not install setuptools from network .
214+ echo MATLAB Engine API install may fail if build tools are missing .
214215 )
216+ ) else (
217+ echo [OK] setuptools already available in venv.
218+ :: Try upgrading pip quietly — not critical if it fails
219+ python -m pip install --upgrade pip %PIP_TRUST% --quiet 2 > nul
215220)
216221echo .
217222
218223:: ----------------------------------------------------------------------------
219- :: 5. Install MATLAB Engine API (into the venv — no admin needed)
224+ :: 5. Install MATLAB Engine API (fully offline — no downloads needed)
225+ :: --no-build-isolation tells pip to use the venv's setuptools instead of
226+ :: downloading a fresh copy into an isolated build environment.
220227:: ----------------------------------------------------------------------------
221228echo [4/6] Installing MATLAB Engine API for Python...
222229
@@ -230,17 +237,17 @@ python -c "import matlab.engine" >nul 2>&1
230237if %errorlevel% equ 0 (
231238 echo MATLAB Engine API already installed. Skipping.
232239) else (
233- echo Installing from !ENGINE_API_DIR! ...
234- pip install " !ENGINE_API_DIR! " %PIP_TRUST% --quiet 2 >& 1
240+ echo Installing from !ENGINE_API_DIR! (offline, no download needed ^ ) ...
241+ pip install " !ENGINE_API_DIR! " --no-build-isolation --quiet 2 >& 1
235242 if %errorlevel% neq 0 (
236243 echo .
237244 echo [WARNING] MATLAB Engine API installation failed.
238245 echo This can happen if your MATLAB version is incompatible
239- echo with Python %PYTHON_VERSION% , or due to network/proxy issues .
246+ echo with Python %PYTHON_VERSION% .
240247 echo .
241248 echo To install manually later, run:
242249 echo call " %VENV_DIR% \Scripts\activate.bat"
243- echo pip install " !ENGINE_API_DIR! "
250+ echo pip install " !ENGINE_API_DIR! " --no-build-isolation
244251 echo .
245252 echo Continuing with MCP server installation...
246253 ) else (
0 commit comments