-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_ext.bat
More file actions
80 lines (66 loc) · 2.88 KB
/
Copy pathbuild_ext.bat
File metadata and controls
80 lines (66 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
@echo off
::
:: build_ext.bat — build autoite._core in-place for development (Windows)
::
:: Usage:
:: build_ext.bat — Release build
:: build_ext.bat Debug — Debug build
:: build_ext.bat clean — remove _build_ext/ directory
::
:: After a successful build, autoite\_core.cp313-win_amd64.pyd is written
:: into autoite/ and importable immediately without reinstalling the package.
::
setlocal
set BUILD_TYPE=%1
if "%BUILD_TYPE%"=="" set BUILD_TYPE=Release
if "%BUILD_TYPE%"=="clean" (
echo Cleaning _build_ext...
if exist _build_ext rmdir /s /q _build_ext
goto :eof
)
:: ── Locate VS 2019 Build Tools ──────────────────────────────────────────── ::
set VS_ROOT=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
if not exist "%VS_ROOT%" (
echo ERROR: VS 2019 Build Tools not found at "%VS_ROOT%"
exit /b 1
)
set CMAKE=%VS_ROOT%\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
set NINJA=%VS_ROOT%\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe
:: ── Activate 64-bit MSVC environment ────────────────────────────────────── ::
call "%VS_ROOT%\VC\Auxiliary\Build\vcvars64.bat" >nul 2>&1
:: ── Locate Python executable ─────────────────────────────────────────────:: ::
for /f "tokens=*" %%i in ('where python') do (
set PYTHON_EXE=%%i
goto :found_python
)
:found_python
:: ── CMake configure ──────────────────────────────────────────────────────:: ::
echo.
echo [1/2] Configuring (%BUILD_TYPE%)...
"%CMAKE%" -B _build_ext -S . ^
-G Ninja ^
-DCMAKE_MAKE_PROGRAM="%NINJA%" ^
-DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^
-DPython3_EXECUTABLE="%PYTHON_EXE%"
if errorlevel 1 (
echo ERROR: CMake configure failed.
exit /b 1
)
:: ── CMake build ──────────────────────────────────────────────────────────:: ::
echo.
echo [2/2] Building...
"%CMAKE%" --build _build_ext --config %BUILD_TYPE% --parallel
if errorlevel 1 (
echo ERROR: Build failed.
exit /b 1
)
:: ── Install in-place ─────────────────────────────────────────────────────:: ::
"%CMAKE%" --install _build_ext --prefix .
if errorlevel 1 (
echo ERROR: Install step failed.
exit /b 1
)
echo.
echo Build complete. Extension installed to autoite\_core*.pyd
python -c "from autoite._core import loo_objective; print(' Import test: OK')"
endlocal