Skip to content

Instantly share code, notes, and snippets.

@zachlewis
Last active October 7, 2025 10:34
Show Gist options
  • Select an option

  • Save zachlewis/21ceda798459e7d357c3ab3a53f9b417 to your computer and use it in GitHub Desktop.

Select an option

Save zachlewis/21ceda798459e7d357c3ab3a53f9b417 to your computer and use it in GitHub Desktop.

Revisions

  1. zachlewis revised this gist Jun 17, 2025. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions uv_package.py
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,6 @@ def variants():


    def pre_build_commands():
    import platform as p
    url_root = "https://github.com/astral-sh/uv/releases/download/%s.%s.%s" % (this.version[0:3])
    env.REZ_BUILD_URL_ROOT = url_root
    env.UV_UNMANAGED_INSTALL = "%s/bin" % build.install_path
    @@ -30,8 +29,8 @@ def pre_build_commands():

    @early()
    def build_command():
    import platform as p
    if p.system() == "Windows":
    import platform
    if platform.system() == "Windows":
    return 'powershell -ExecutionPolicy ByPass -c "irm $REZ_BUILD_URL_ROOT/uv-installer.ps1 | iex'
    return "curl --proto '=https' --tlsv1.2 -LsSf $REZ_BUILD_URL_ROOT/uv-installer.sh | sh"

  2. zachlewis created this gist Jun 17, 2025.
    69 changes: 69 additions & 0 deletions python_package.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    name = "python"

    version = "3.13.1"

    authors = ["Guido van Rossum"]

    description = "The Python programming language"

    private_build_requires = ['uv-0.7.13+<1']

    @early()
    def variants():
    import rez.package_py_utils as rezutils
    import platform

    p = (
    "platform-%s"
    % {"darwin": "osx", "windows": "windows", "linux": "linux"}[
    platform.system().lower()
    ]
    )
    return [rezutils.expand_requires(p, "arch-**")]

    @early()
    def tools():
    maj, mnr = this.version.split(".")[0:2]
    pyver = ".".join([maj, mnr])
    all_vers = ["python{0}", "python{0}-config", "pip{0}"]
    return [
    "python",
    f"python{maj}",
    f"python{pyver}",
    "python-config",
    f"python{maj}-config",
    f"python{pyver}-config",
    "pip",
    f"pip{maj}",
    f"pip{pyver}",
    f"idle{maj}",
    f"idle{pyver}",
    f"pydoc{maj}",
    f"pydoc{pyver}",
    "2to3",
    f"2to3-{pyver}",
    ]


    def pre_build_commands():
    env.REZ_BUILD_PYTHON_VERSION = "{this.version.major}.{this.version.minor}.{this.version.patch}"


    build_command = """
    uv python install $REZ_BUILD_PYTHON_VERSION -i {install_path}
    ln -sfv {install_path}/cpython* {install_path}/ext
    """

    def pre_commands():
    from tempfile import gettempdir
    import os
    # Unset PYTHONHOME to avoid conflicts with libraries provided by Rez
    env.PYTHONHOME.unset()
    # Allow .pyc files to be written to a temporary directory, instead of attempting
    # to write to the package payload.
    env.PYTHONPYCACHEPREFIX = os.path.join(gettempdir(), "rez-pycache")


    def commands():
    pyroot = "{this.root}/ext"
    env.PATH.prepend("{pyroot}/bin")
    40 changes: 40 additions & 0 deletions uv_package.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    name = "uv"

    version = "0.7.13"

    authors = ["Astral.sh"]

    description = "An extremely fast Python package and project manager, written in Rust."

    uuid = "94A2BD31-7E8D-4611-BA9F-8F16D09ED3F8"

    tools = ["uv", "uvx"]


    @early()
    def variants():
    import rez.package_py_utils, platform
    p = ("platform-%s"
    % {"darwin": "osx", "windows": "windows", "linux": "linux"}[
    platform.system().lower()])
    return [rez.package_py_utils.expand_requires(p, "arch-**")]


    def pre_build_commands():
    import platform as p
    url_root = "https://github.com/astral-sh/uv/releases/download/%s.%s.%s" % (this.version[0:3])
    env.REZ_BUILD_URL_ROOT = url_root
    env.UV_UNMANAGED_INSTALL = "%s/bin" % build.install_path
    env.INSTALLER_NO_MODIFY_PATH = 1


    @early()
    def build_command():
    import platform as p
    if p.system() == "Windows":
    return 'powershell -ExecutionPolicy ByPass -c "irm $REZ_BUILD_URL_ROOT/uv-installer.ps1 | iex'
    return "curl --proto '=https' --tlsv1.2 -LsSf $REZ_BUILD_URL_ROOT/uv-installer.sh | sh"


    def commands():
    env.PATH.append("{root}/bin")