mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
build-deps - support overriding PYTHON_VERSION
This commit is contained in:
@@ -9,7 +9,6 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
python: ['3.9.11', '3.10.3', '3.11.8', '3.12.1', '3.13.0']
|
|
||||||
arch: ['x64']
|
arch: ['x64']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
@@ -30,14 +29,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
choco install -y sed 7zip.install awscli
|
choco install -y sed 7zip.install awscli
|
||||||
|
|
||||||
- name: Install Python
|
|
||||||
run: |
|
|
||||||
$installer = "python-${{ matrix.python }}-amd64.exe"
|
|
||||||
$url = "https://www.python.org/ftp/python/${{ matrix.python }}/$installer"
|
|
||||||
Invoke-WebRequest -Uri $url -OutFile $installer
|
|
||||||
Start-Process -Wait -FilePath .\$installer -ArgumentList '/quiet InstallAllUsers=0 PrependPath=0 Include_test=0 TargetDir=C:\Python\${{ matrix.python }}'
|
|
||||||
Remove-Item .\$installer
|
|
||||||
|
|
||||||
- name: Unpack Dependencies
|
- name: Unpack Dependencies
|
||||||
run: |
|
run: |
|
||||||
cd _deps-vs2022-x64-installed
|
cd _deps-vs2022-x64-installed
|
||||||
@@ -54,21 +45,12 @@ jobs:
|
|||||||
# and with default 500MB some cache gets deleted, leading to misses.
|
# and with default 500MB some cache gets deleted, leading to misses.
|
||||||
max-size: 5000MB
|
max-size: 5000MB
|
||||||
|
|
||||||
- name: Run Build Script
|
- name: Run Build Script And Pack .zip Archives
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
setlocal EnableDelayedExpansion
|
|
||||||
SET PYTHON_VERSION=${{ matrix.python }}
|
|
||||||
for /f "tokens=1,2,3 delims=." %%a in ("%PYTHON_VERSION%") do (
|
|
||||||
set PY_VER_MAJOR_MINOR=%%a%%b
|
|
||||||
)
|
|
||||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
||||||
SET IFCOS_INSTALL_PYTHON=FALSE
|
|
||||||
cd win
|
cd win
|
||||||
echo y | call build-deps.cmd vs2022-x64 Release
|
python build-all-win.py
|
||||||
SET PYTHONHOME=C:\Python\${{ matrix.python }}
|
|
||||||
call run-cmake.bat vs2022-x64 -DENABLE_BUILD_OPTIMIZATIONS=On -DGLTF_SUPPORT=ON -DADD_COMMIT_SHA=ON -DVERSION_OVERRIDE=ON
|
|
||||||
call install-ifcopenshell.bat vs2022-x64 Release
|
|
||||||
|
|
||||||
- name: Pack Dependencies
|
- name: Pack Dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -90,35 +72,6 @@ jobs:
|
|||||||
git commit -m "Update build artifacts [skip ci]" || echo "No changes to commit"
|
git commit -m "Update build artifacts [skip ci]" || echo "No changes to commit"
|
||||||
git push || echo "Push failed"
|
git push || echo "Push failed"
|
||||||
|
|
||||||
- name: Package .zip Archives
|
|
||||||
run: |
|
|
||||||
$VERSION = 'v' + ((Get-Content VERSION).Trim())
|
|
||||||
$SHA = ${env:GITHUB_SHA}.Substring(0, 7)
|
|
||||||
$OUTPUT_DIR = "$env:USERPROFILE\output"
|
|
||||||
New-Item -ItemType Directory -Force -Path $OUTPUT_DIR
|
|
||||||
|
|
||||||
if ("${{ matrix.python }}" -eq "3.9.11") {
|
|
||||||
# only for the first python version the executables are assembled for upload
|
|
||||||
cd _installed-vs2022-x64/bin
|
|
||||||
Get-ChildItem -Path . | ForEach-Object {
|
|
||||||
echo $_
|
|
||||||
$exe = $_.Name
|
|
||||||
$baseName = $exe.Substring(0, $exe.Length - 4)
|
|
||||||
$zipName = "${baseName}-$VERSION-$SHA-win64.zip"
|
|
||||||
7z a $zipName $exe
|
|
||||||
}
|
|
||||||
mv *.zip $OUTPUT_DIR
|
|
||||||
}
|
|
||||||
|
|
||||||
$pyVersion = "${{ matrix.python }}"
|
|
||||||
$pyVersionMajor = ($pyVersion -split '\.')[0..1] -join ''
|
|
||||||
cd C:\Python\${{ matrix.python }}\Lib\site-packages
|
|
||||||
Remove-Item -Recurse -Force ifcopenshell\__pycache__ -ErrorAction SilentlyContinue
|
|
||||||
Get-ChildItem -Path ifcopenshell -Filter "*.pyc" -Recurse | Remove-Item -Force
|
|
||||||
$zipName = "ifcopenshell-python-$pyVersionMajor-$VERSION-$SHA-win64.zip"
|
|
||||||
7z a $zipName ifcopenshell
|
|
||||||
mv $zipName $OUTPUT_DIR
|
|
||||||
|
|
||||||
- name: Configure AWS Credentials
|
- name: Configure AWS Credentials
|
||||||
uses: aws-actions/configure-aws-credentials@v4
|
uses: aws-actions/configure-aws-credentials@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
"""
|
||||||
|
It's not really a full version of nix/build-all.py for Windows,
|
||||||
|
but serves the similar purpose - build all packages during CI (though by using cmd scripts),
|
||||||
|
but also archives them to '~/outputs'.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
from zipfile import ZipFile
|
||||||
|
|
||||||
|
assert Path.cwd() == Path(__file__).parent, "Run this script from the 'win' directory."
|
||||||
|
|
||||||
|
PYTHON_VERSIONS = ["3.9.13", "3.10.3", "3.11.8", "3.12.1", "3.13.0"]
|
||||||
|
REPO_PATH = Path(__file__).parent.parent
|
||||||
|
REPO_WIN = REPO_PATH / "win"
|
||||||
|
VERSION = (REPO_PATH / "VERSION").read_text().strip()
|
||||||
|
if "GITHUB_SHA" in os.environ:
|
||||||
|
SHA = os.environ["GITHUB_SHA"][:7]
|
||||||
|
else:
|
||||||
|
SHA = subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip()
|
||||||
|
OUTPUT_DIR = Path.home() / "output"
|
||||||
|
OUTPUT_DIR.mkdir(exist_ok=True)
|
||||||
|
print("Output directory:", OUTPUT_DIR)
|
||||||
|
ZIP_TEMPLATE = f"{{package_name}}-v{VERSION}-{SHA}-win64.zip"
|
||||||
|
|
||||||
|
|
||||||
|
def run(command: list[str]) -> None:
|
||||||
|
print("Running:", command)
|
||||||
|
subprocess.check_call(command) # nosec B603
|
||||||
|
|
||||||
|
|
||||||
|
def build() -> None:
|
||||||
|
for python_version in PYTHON_VERSIONS:
|
||||||
|
os.environ["PYTHON_VERSION"] = python_version
|
||||||
|
print(f"Building for Python {python_version}...")
|
||||||
|
subprocess.run(
|
||||||
|
[str(REPO_WIN / "build-deps.cmd"), "vs2022-x64", "Release"],
|
||||||
|
check=True,
|
||||||
|
text=True,
|
||||||
|
input="y\n",
|
||||||
|
)
|
||||||
|
run(
|
||||||
|
[
|
||||||
|
str(REPO_WIN / "run-cmake.bat"),
|
||||||
|
"vs2022-x64",
|
||||||
|
"-DENABLE_BUILD_OPTIMIZATIONS=ON",
|
||||||
|
"-DGLTF_SUPPORT=ON",
|
||||||
|
"-DADD_COMMIT_SHA=ON",
|
||||||
|
"-DVERSION_OVERRIDE=ON",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
run([str(REPO_WIN / "install-ifcopenshell.bat"), "vs2022-x64", "Release"])
|
||||||
|
|
||||||
|
|
||||||
|
def archive_executables() -> None:
|
||||||
|
# Typically '_installed-vs2022-x64'.
|
||||||
|
install_dir = next(d for d in REPO_PATH.iterdir() if d.is_dir() and d.name.startswith("_installed"))
|
||||||
|
|
||||||
|
for file in (install_dir / "bin").iterdir():
|
||||||
|
if file.suffix.lower() != ".exe":
|
||||||
|
continue
|
||||||
|
zip_name = ZIP_TEMPLATE.format(package_name=file.stem)
|
||||||
|
with ZipFile(OUTPUT_DIR / zip_name, "w") as zipf:
|
||||||
|
zipf.write(file, arcname=file.name)
|
||||||
|
print(f"{file} -> {zip_name}")
|
||||||
|
|
||||||
|
|
||||||
|
def archive_python_package(python_version: str, python_path: Path) -> None:
|
||||||
|
python_version_major_minor = "".join(python_version.split(".")[:2])
|
||||||
|
site_packages = python_path / "Lib" / "site-packages"
|
||||||
|
package_path = site_packages / "ifcopenshell"
|
||||||
|
|
||||||
|
# Clean cache.
|
||||||
|
for file in package_path.rglob("*.pyc"):
|
||||||
|
file.unlink()
|
||||||
|
|
||||||
|
zip_name = ZIP_TEMPLATE.format(package_name=f"ifcopenshell-python-{python_version_major_minor}")
|
||||||
|
with ZipFile(OUTPUT_DIR / zip_name, "w") as zipf:
|
||||||
|
for file in package_path.rglob("*"):
|
||||||
|
arcname = file.relative_to(site_packages)
|
||||||
|
zipf.write(file, arcname=arcname)
|
||||||
|
print(f"{package_path} -> {zip_name}")
|
||||||
|
|
||||||
|
|
||||||
|
def archive_python_packages() -> None:
|
||||||
|
deps_path = REPO_PATH / "_deps"
|
||||||
|
python_versions: list[str] = []
|
||||||
|
for d in deps_path.iterdir():
|
||||||
|
if d.is_dir() and d.name.startswith("python."):
|
||||||
|
python_version = d.name.partition(".")[2]
|
||||||
|
python_path = d / "tools"
|
||||||
|
archive_python_package(python_version, python_path)
|
||||||
|
python_versions.append(d.name.partition(".")[2])
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
build()
|
||||||
|
archive_executables()
|
||||||
|
archive_python_packages()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
+5
-1
@@ -175,7 +175,11 @@ cd "%DEPS_DIR%"
|
|||||||
set HDF5_VERSION=1_13_1
|
set HDF5_VERSION=1_13_1
|
||||||
set OCCT_VERSION=7.8.1
|
set OCCT_VERSION=7.8.1
|
||||||
:: NOTE If updating the default Python version, change PY_VER_MAJOR_MINOR accordingly in run-cmake.bat
|
:: NOTE If updating the default Python version, change PY_VER_MAJOR_MINOR accordingly in run-cmake.bat
|
||||||
set PYTHON_VERSION=3.11.7
|
IF DEFINED PYTHON_VERSION (
|
||||||
|
echo Using overridden PYTHON_VERSION: '%PYTHON_VERSION%'
|
||||||
|
) else (
|
||||||
|
set PYTHON_VERSION=3.11.7
|
||||||
|
)
|
||||||
|
|
||||||
:: VERSION DERIVATIONS
|
:: VERSION DERIVATIONS
|
||||||
set OCC_INCLUDE_DIR=%INSTALL_DIR%\opencascade-%OCCT_VERSION%\inc>>"%~dp0\%BUILD_DEPS_CACHE_PATH%"
|
set OCC_INCLUDE_DIR=%INSTALL_DIR%\opencascade-%OCCT_VERSION%\inc>>"%~dp0\%BUILD_DEPS_CACHE_PATH%"
|
||||||
|
|||||||
Reference in New Issue
Block a user