@@ -92,7 +92,6 @@ class Version:
9292class VersionedBranch :
9393 ref : str
9494 version : Version
95- pip_version : str = "" # halide-llvm version on pypi.halide-lang.org
9695
9796 @property
9897 def shortversion (self ):
@@ -107,26 +106,10 @@ LLVM_RELEASE_21 = "release_21"
107106LLVM_RELEASE_20 = "release_20"
108107
109108LLVM_BRANCHES = {
110- LLVM_MAIN : VersionedBranch (
111- ref = "main" ,
112- version = Version (23 , 0 , 0 ),
113- pip_version = "23.0.0.dev0+g80f627e6" ,
114- ),
115- LLVM_RELEASE_22 : VersionedBranch (
116- ref = "llvmorg-22.1.0-rc3" ,
117- version = Version (22 , 1 , 0 ),
118- pip_version = "22.1.0rc3" ,
119- ),
120- LLVM_RELEASE_21 : VersionedBranch (
121- ref = "llvmorg-21.1.8" ,
122- version = Version (21 , 1 , 8 ),
123- pip_version = "21.1.8" ,
124- ),
125- LLVM_RELEASE_20 : VersionedBranch (
126- ref = "llvmorg-20.1.8" ,
127- version = Version (20 , 1 , 8 ),
128- pip_version = "20.1.8" ,
129- ),
109+ LLVM_MAIN : VersionedBranch (ref = "main" , version = Version (23 , 0 , 0 )),
110+ LLVM_RELEASE_22 : VersionedBranch (ref = "llvmorg-22.1.0-rc3" , version = Version (22 , 1 , 0 )),
111+ LLVM_RELEASE_21 : VersionedBranch (ref = "llvmorg-21.1.8" , version = Version (21 , 1 , 8 )),
112+ LLVM_RELEASE_20 : VersionedBranch (ref = "llvmorg-20.1.8" , version = Version (20 , 1 , 8 )),
130113}
131114
132115# At any given time, Halide has a main branch, which supports (at least)
@@ -465,6 +448,18 @@ def save_environment(prop, allowlist):
465448 return extract_fn
466449
467450
451+ def extract_llvm_pip_version (llvm_ver ):
452+ def extract_fn (_rc , stdout , _stderr ):
453+ for line in stdout .splitlines ():
454+ if f"ci-llvm-{ llvm_ver } " in line :
455+ m = re .search (r"halide-llvm==([\w.+]+)" , line )
456+ if m :
457+ return {"HALIDE_LLVM_PIP_VERSION" : m .group (1 )}
458+ return {}
459+
460+ return extract_fn
461+
462+
468463def get_msvc_config_steps (factory , builder_type ):
469464 # ensure that we use the x64 host compiler, not the x86 host compiler
470465 arch_for_bits = {32 : "x64_x86" , 64 : "x64" }
@@ -586,28 +581,24 @@ def get_build_command(build_dir, targets=None):
586581
587582
588583def add_create_venv_step (factory , builder_type ):
584+ llvm_ver = LLVM_BRANCHES [builder_type .llvm_branch ].shortversion
585+ platform_tag = _PIP_PLATFORM_TAGS [(builder_type .arch , builder_type .bits , builder_type .os )]
586+
587+ group = f"ci-llvm-{ llvm_ver } " if platform_tag is None else "ci-base"
588+
589589 if builder_type .os == "windows" :
590- activate = r".venv\Scripts\activate"
591- env = "set"
592- remove = "rmdir /s /q"
590+ activate = r'"%UV_PROJECT_ENVIRONMENT%\Scripts\activate"'
591+ env_cmd = "set"
593592 else :
594- activate = ". .venv/bin/activate"
595- env = "env"
596- remove = "rm -rf"
593+ activate = '. "$UV_PROJECT_ENVIRONMENT/bin/activate"'
594+ env_cmd = "env"
597595
598596 factory .addStep (
599597 SetPropertyFromCommand (
600598 name = "Create virtual environment" ,
601599 locks = [performance_lock .access ("counting" )],
602600 workdir = get_source_path (),
603- command = (
604- f"{ remove } .venv && "
605- "python -m venv .venv && "
606- f"{ activate } && "
607- 'python -m pip install -U pip "setuptools[core]" wheel && '
608- "python -m pip install -r requirements.txt && "
609- f"{ env } "
610- ),
601+ command = f"uv sync --group { group } --no-install-project && { activate } && { env_cmd } " ,
611602 env = Property ("env" , {}),
612603 extract_fn = save_environment ("venv" , ["VIRTUAL_ENV" , "PATH" ]),
613604 )
@@ -638,70 +629,72 @@ _PIP_PLATFORM_TAGS = {
638629
639630
640631def add_install_llvm_step (factory , builder_type ):
641- pip_version = LLVM_BRANCHES [builder_type .llvm_branch ].pip_version
642- llvm_version = LLVM_BRANCHES [builder_type .llvm_branch ].shortversion
643- pip_spec = f"halide-llvm=={ pip_version } "
644- extra_index = "https://pypi.halide-lang.org/simple/"
645-
632+ llvm_ver = LLVM_BRANCHES [builder_type .llvm_branch ].shortversion
646633 platform_tag = _PIP_PLATFORM_TAGS [(builder_type .arch , builder_type .bits , builder_type .os )]
647634
648635 if platform_tag is None :
649- # Native install: pip install into the venv, then query the prefix
650- if builder_type .os == "windows" :
651- activate = r".venv\Scripts\activate"
652- else :
653- activate = ". .venv/bin/activate"
636+ # Native install: halide-llvm was already installed by uv sync
637+ factory .addStep (
638+ SetPropertyFromCommand (
639+ name = f"Get LLVM { llvm_ver } prefix" ,
640+ locks = [performance_lock .access ("counting" )],
641+ workdir = get_source_path (),
642+ haltOnFailure = True ,
643+ env = Property ("env" ),
644+ command = "halide-llvm --prefix" ,
645+ property = "HALIDE_LLVM_ROOT" ,
646+ )
647+ )
648+ else :
649+ # Cross install: use pip to install halide-llvm for a foreign platform
650+ extra_index = "https://pypi.halide-lang.org/simple/"
651+ target_dir = get_builddir_subpath ("halide-llvm-cross" )
654652
655653 factory .addStep (
656654 ShellCommand (
657- name = f "Install halide-llvm { llvm_version } " ,
655+ name = "Install pip " ,
658656 locks = [performance_lock .access ("counting" )],
659657 workdir = get_source_path (),
660658 haltOnFailure = True ,
661659 env = Property ("env" ),
662- command = f' { activate } && python -m pip install --pre " { pip_spec } " --extra-index-url { extra_index } ' ,
660+ command = "uv pip install pip" ,
663661 )
664662 )
663+
664+ cat = "type" if builder_type .os == "windows" else "cat"
665665 factory .addStep (
666666 SetPropertyFromCommand (
667- name = f"Get LLVM { llvm_version } prefix " ,
667+ name = f"Get halide-llvm { llvm_ver } version " ,
668668 locks = [performance_lock .access ("counting" )],
669669 workdir = get_source_path (),
670670 haltOnFailure = True ,
671- env = Property ("env" ),
672- command = f"{ activate } && halide-llvm --prefix" ,
673- property = "HALIDE_LLVM_ROOT" ,
671+ command = f"{ cat } pyproject.toml" ,
672+ extract_fn = extract_llvm_pip_version (llvm_ver ),
674673 )
675674 )
676- else :
677- # Cross install: use --target and --platform to fetch the right wheel
678- target_dir = get_builddir_subpath ("halide-llvm-cross" )
679675
680676 factory .addStep (
681677 RemoveDirectory (
682- name = f"Remove old halide-llvm { llvm_version } cross dir" ,
678+ name = f"Remove old halide-llvm { llvm_ver } cross dir" ,
683679 locks = [performance_lock .access ("counting" )],
684680 dir = target_dir ,
685681 haltOnFailure = False ,
686682 )
687683 )
688684
689- if builder_type .os == "windows" :
690- activate = r".venv\Scripts\activate"
691- else :
692- activate = ". .venv/bin/activate"
693-
694685 factory .addStep (
695686 ShellCommand (
696- name = f"Install halide-llvm { llvm_version } ({ platform_tag } )" ,
687+ name = f"Install halide-llvm { llvm_ver } ({ platform_tag } )" ,
697688 locks = [performance_lock .access ("counting" )],
698689 workdir = get_source_path (),
699690 haltOnFailure = True ,
700691 env = Property ("env" ),
701- command = Interpolate (f" { activate } && python -m pip install --pre --target " )
692+ command = Interpolate (" python -m pip install --pre --target " )
702693 + target_dir
703694 + Interpolate (
704- f' --platform { platform_tag } --only-binary=:all: "{ pip_spec } " --extra-index-url { extra_index } '
695+ f" --platform { platform_tag } --only-binary=:all: "
696+ '"halide-llvm==%(prop:HALIDE_LLVM_PIP_VERSION)s" '
697+ f"--extra-index-url { extra_index } "
705698 ),
706699 )
707700 )
@@ -710,7 +703,7 @@ def add_install_llvm_step(factory, builder_type):
710703 llvm_root = get_builddir_subpath ("halide-llvm-cross/halide_llvm/data" )
711704 factory .addStep (
712705 SetProperties (
713- name = f"Set LLVM { llvm_version } prefix (cross)" ,
706+ name = f"Set LLVM { llvm_ver } prefix (cross)" ,
714707 properties = {"HALIDE_LLVM_ROOT" : llvm_root },
715708 )
716709 )
0 commit comments