Skip to content

Instantly share code, notes, and snippets.

@zachlewis
Last active June 17, 2025 18:45
Show Gist options
  • Save zachlewis/21ceda798459e7d357c3ab3a53f9b417 to your computer and use it in GitHub Desktop.
Save zachlewis/21ceda798459e7d357c3ab3a53f9b417 to your computer and use it in GitHub Desktop.
rez packages: uv and python
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")
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():
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
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"
def commands():
env.PATH.append("{root}/bin")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment