diff --git a/.github/workflows/postsubmit.yml b/.github/workflows/postsubmit.yml index 0250fe5a0f683..c93e6a1688d19 100644 --- a/.github/workflows/postsubmit.yml +++ b/.github/workflows/postsubmit.yml @@ -194,10 +194,6 @@ jobs: runs-on: windows-latest timeout-minutes: 90 steps: - - name: Install 7Zip PowerShell - shell: powershell - run: Install-Module 7Zip4PowerShell -Force -Verbose - - uses: actions/checkout@v2 with: submodules: "recursive" @@ -209,49 +205,21 @@ jobs: - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.0.2 - - name: Download And Install Vulkan - shell: powershell - run: | - Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.2.189.0/windows/VulkanSDK-1.2.189.0-Installer.exe" -OutFile VulkanSDK.exe - $installer = Start-Process -FilePath VulkanSDK.exe -Wait -PassThru -ArgumentList @("/S"); - $installer.WaitForExit(); - - name: Build shell: powershell run: | - $env:Path += ";C:/VulkanSDK/1.2.189.0/Bin" - cd C:\ - Remove-item alias:curl - curl --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/taichi-llvm-10.0.0-msvc2019.zip -LO - 7z x taichi-llvm-10.0.0-msvc2019.zip -otaichi_llvm - curl --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/clang-10.0.0-win.zip -LO - 7z x clang-10.0.0-win.zip -otaichi_clang - $env:PATH = ";C:\taichi_llvm\bin;C:\taichi_clang\bin;" + $env:PATH - clang --version - cd D:\a\taichi\taichi - python -m pip install -r requirements_dev.txt - python -m pip install -r requirements_test.txt - cd python - git fetch origin master - $env:TAICHI_CMAKE_ARGS = $env:CI_SETUP_CMAKE_ARGS - python build.py build - cd ..\dist - $env:WHL = $(dir *.whl) - python -m pip install $env:WHL - env: - PYTHON: C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe - CI_SETUP_CMAKE_ARGS: -G "Visual Studio 16 2019" -A x64 -DLLVM_DIR=C:\taichi_llvm\lib\cmake\llvm -DTI_WITH_VULKAN:BOOL=ON - VULKAN_SDK: C:/VulkanSDK/1.2.189.0 + .\.github\workflows\scripts\win_build.ps1 -installVulkan -install -libsDir C:\ - name: Test shell: powershell run: | $env:PATH = ";C:\taichi_llvm\bin;C:\taichi_clang\bin;" + $env:PATH + . venv\Scripts\activate.ps1 python -c "import taichi" python examples/algorithm/laplace.py - python bin/taichi diagnose - python bin/taichi changelog - python bin/taichi test -vr2 -t2 + ti diagnose + ti changelog + ti test -vr2 -t2 env: PYTHON: C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe @@ -306,7 +274,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - submodules: 'recursive' + submodules: "recursive" - name: Build & Install run: | diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index 307fc33585478..ea717d5d31979 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -36,7 +36,7 @@ jobs: run: | echo "=============== list modified files ===============" git diff --name-only @^ - + echo "========== check paths of modified files ==========" git diff --name-only @^ > files.txt while IFS= read -r file @@ -376,10 +376,6 @@ jobs: runs-on: windows-latest timeout-minutes: 90 steps: - - name: Install 7Zip PowerShell - shell: powershell - run: Install-Module 7Zip4PowerShell -Force -Verbose - - uses: actions/checkout@v2 with: submodules: "recursive" @@ -391,45 +387,13 @@ jobs: - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.0.2 - - name: Download And Install Vulkan - shell: powershell - run: | - if ( "${{needs.check_files.outputs.run_job}}" -eq "false" ) { - exit 0 - } - Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.2.189.0/windows/VulkanSDK-1.2.189.0-Installer.exe" -OutFile VulkanSDK.exe - $installer = Start-Process -FilePath VulkanSDK.exe -Wait -PassThru -ArgumentList @("/S"); - $installer.WaitForExit(); - - name: Build shell: powershell run: | if ( "${{needs.check_files.outputs.run_job}}" -eq "false" ) { exit 0 } - $env:Path += ";C:/VulkanSDK/1.2.189.0/Bin" - cd C:\ - Remove-item alias:curl - curl --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/taichi-llvm-10.0.0-msvc2019.zip -LO - 7z x taichi-llvm-10.0.0-msvc2019.zip -otaichi_llvm - curl --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/clang-10.0.0-win.zip -LO - 7z x clang-10.0.0-win.zip -otaichi_clang - $env:PATH = ";C:\taichi_llvm\bin;C:\taichi_clang\bin;" + $env:PATH - clang --version - cd D:\a\taichi\taichi - python -m pip install -r requirements_dev.txt - python -m pip install -r requirements_test.txt - cd python - git fetch origin master - $env:TAICHI_CMAKE_ARGS = $env:CI_SETUP_CMAKE_ARGS - python build.py build - cd ..\dist - $env:WHL = $(dir *.whl) - python -m pip install $env:WHL - env: - PYTHON: C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe - CI_SETUP_CMAKE_ARGS: -G "Visual Studio 16 2019" -A x64 -DLLVM_DIR=C:\taichi_llvm\lib\cmake\llvm -DTI_WITH_VULKAN:BOOL=ON - VULKAN_SDK: C:/VulkanSDK/1.2.189.0 + .\.github\workflows\scripts\win_build.ps1 -installVulkan -install -libsDir C:\ - name: Test shell: powershell @@ -438,11 +402,12 @@ jobs: exit 0 } $env:PATH = ";C:\taichi_llvm\bin;C:\taichi_clang\bin;" + $env:PATH + . venv\Scripts\activate.ps1 python -c "import taichi" python examples/algorithm/laplace.py - python bin/taichi diagnose - python bin/taichi changelog - python bin/taichi test -vr2 -t2 + ti diagnose + ti changelog + ti test -vr2 -t2 env: PYTHON: C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c98b6b0e7b79a..d7ba65f9d9a0a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -288,10 +288,6 @@ jobs: matrix: ${{ fromJson(needs.matrix_prep.outputs.matrix) }} runs-on: windows-latest steps: - - name: Install 7Zip PowerShell - shell: powershell - run: Install-Module 7Zip4PowerShell -Force -Verbose - - uses: actions/checkout@v2 with: submodules: "recursive" @@ -303,39 +299,13 @@ jobs: - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.0.2 - - name: Download And Install Vulkan - shell: powershell - run: | - Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.2.189.0/windows/VulkanSDK-1.2.189.0-Installer.exe" -OutFile VulkanSDK.exe - $installer = Start-Process -FilePath VulkanSDK.exe -Wait -PassThru -ArgumentList @("/S"); - $installer.WaitForExit(); - - name: Build Python Wheel shell: powershell run: | - $env:Path += ";C:/VulkanSDK/1.2.189.0/Bin" - cd C:\ - Remove-item alias:curl - curl --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/taichi-llvm-10.0.0-msvc2019.zip -LO - 7z x taichi-llvm-10.0.0-msvc2019.zip -otaichi_llvm - curl --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/clang-10.0.0-win.zip -LO - 7z x clang-10.0.0-win.zip -otaichi_clang - $env:PATH = ";C:\taichi_llvm\bin;C:\taichi_clang\bin;" + $env:PATH - clang --version - cd D:\a\taichi\taichi - python -m pip install -r requirements_dev.txt - python -m pip install -r requirements_test.txt - cd python - git fetch origin master - $env:TAICHI_CMAKE_ARGS = $env:CI_SETUP_CMAKE_ARGS - python build.py build --project_name $env:PROJECT_NAME - cd ..\dist - $env:WHL = $(dir *.whl) - python -m pip install $env:WHL + .\.github\workflows\scripts\win_build.ps1 -installVulkan -libsDir C:\ + venv\Scripts\python -m pip install $(dir dist\*.whl) env: - CI_SETUP_CMAKE_ARGS: -G "Visual Studio 16 2019" -A x64 -DLLVM_DIR=C:\taichi_llvm\lib\cmake\llvm -DTI_WITH_VULKAN:BOOL=ON PROJECT_NAME: ${{ matrix.name }} - VULKAN_SDK: C:/VulkanSDK/1.2.189.0 - name: Archive Wheel Artifacts uses: actions/upload-artifact@v2 @@ -348,10 +318,11 @@ jobs: shell: powershell run: | $env:PATH = ";C:\taichi_llvm\bin;C:\taichi_clang\bin;" + $env:PATH + . venv\Scripts\activate.ps1 python -c "import taichi" python examples/algorithm/laplace.py - python bin/taichi diagnose - python bin/taichi test -vr2 -t2 + ti diagnose + ti test -vr2 -t2 - name: Upload PyPI shell: powershell diff --git a/.github/workflows/scripts/win_build.ps1 b/.github/workflows/scripts/win_build.ps1 new file mode 100644 index 0000000000000..217bebedbad29 --- /dev/null +++ b/.github/workflows/scripts/win_build.ps1 @@ -0,0 +1,77 @@ +# Build script for windows + +param ( + [switch]$clone = $false, + [switch]$installVulkan = $false, + [switch]$develop = $false, + [switch]$install = $false, + [string]$libsDir = "." +) + +$RepoURL = 'https://github.com/taichi-dev/taichi' + +function WriteInfo($text) { + Write-Host -ForegroundColor Green "[BUILD] $text" +} + +WriteInfo("Install 7Zip") +Install-Module 7Zip4PowerShell -Force -Verbose -Scope CurrentUser + +if ($clone) { + WriteInfo("Clone the repository") + git clone --recurse-submodules $RepoURL + Set-Location .\taichi +} + +$libsDir = (Resolve-Path $libsDir).Path + +if (-not (Test-Path $libsDir)) { + New-Item -ItemType Directory -Path $libsDir +} +Push-Location $libsDir +WriteInfo("Download and extract LLVM") +if (-not (Test-Path "taichi_llvm")) { + curl.exe --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/taichi-llvm-10.0.0-msvc2019.zip -LO + 7z x taichi-llvm-10.0.0-msvc2019.zip -otaichi_llvm +} +WriteInfo("Download and extract Clang") +if (-not (Test-Path "taichi_clang")) { + curl.exe --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/clang-10.0.0-win.zip -LO + 7z x clang-10.0.0-win.zip -otaichi_clang +} +$env:PATH = "$libsDir\taichi_llvm\bin;$libsDir\taichi_clang\bin;$env:PATH" +$env:TAICHI_CMAKE_ARGS = "-G 'Visual Studio 16 2019' -A x64 -DLLVM_DIR=$libsDir\taichi_llvm\lib\cmake\llvm" +if ($installVulkan) { + WriteInfo("Download and install Vulkan") + if (-not (Test-Path "VulkanSDK.exe")) { + curl.exe --retry 10 --retry-delay 5 https://sdk.lunarg.com/sdk/download/1.2.189.0/windows/VulkanSDK-1.2.189.0-Installer.exe -Lo VulkanSDK.exe + } + $installer = Start-Process -FilePath VulkanSDK.exe -Wait -PassThru -ArgumentList @("/S"); + $installer.WaitForExit(); + $env:VULKAN_SDK = "$libsDir\VulkanSDK\1.2.189.0" + $env:PATH += ";$env:VULKAN_SDK\Bin" + $env:TAICHI_CMAKE_ARGS += " -DTI_WITH_VULKAN:BOOL=ON" +} + +Pop-Location +clang --version + +WriteInfo("Setting up Python environment") +python -m venv venv +. venv\Scripts\activate.ps1 +python -m pip install wheel +python -m pip install -r requirements_dev.txt +python -m pip install -r requirements_test.txt +WriteInfo("Building Taichi") +$env:CXX = "$libsDir\taichi_clang\bin\clang++.exe" +if ($install) { + if ($develop) { + python -m pip install -v -e . + } else { + python -m pip install -v . + } + WriteInfo("Build and install finished") +} else { + python setup.py bdist_wheel + WriteInfo("Build finished") +} diff --git a/cmake/PythonNumpyPybind11.cmake b/cmake/PythonNumpyPybind11.cmake index 5957afc7999c3..cbc998ed264d0 100644 --- a/cmake/PythonNumpyPybind11.cmake +++ b/cmake/PythonNumpyPybind11.cmake @@ -51,10 +51,14 @@ execute_process(COMMAND ${PYTHON_EXECUTABLE} -c sys.stdout.write(str(sys.version_info[1]))" OUTPUT_VARIABLE PYTHON_MINOR_VERSION) + if (WIN32) - link_directories(${PYTHON_LIBRARY_DIR}/../../libs) - set(PYTHON_LIBRARIES ${PYTHON_LIBRARY_DIR}/../../libs/python3.lib) - set(PYTHON_LIBRARIES ${PYTHON_LIBRARY_DIR}/../../libs/python3${PYTHON_MINOR_VERSION}.lib) + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c + "import sys;sys.stdout.write(sys.base_prefix.replace('\\\\', '/'))" + OUTPUT_VARIABLE PYTHON_BASE_PREFIX) + link_directories(${PYTHON_BASE_PREFIX}/libs) + set(PYTHON_LIBRARIES ${PYTHON_BASE_PREFIX}/libs/python3.lib) + set(PYTHON_LIBRARIES ${PYTHON_BASE_PREFIX}/libs/python3${PYTHON_MINOR_VERSION}.lib) else() find_library(PYTHON_LIBRARY NAMES python${PYTHON_VERSION} python${PYTHON_VERSION}m PATHS ${PYTHON_LIBRARY_DIR} NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH PATH_SUFFIXES x86_64-linux-gnu)