Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: "Copy docker image dependencies"
run: cp pyproject.toml requirements.lock requirements-dev.lock .python-version README.md rust-toolchain.toml docker/
run: cp pyproject.toml uv.lock .python-version README.md rust-toolchain.toml docker/
shell: bash

- name: Build and push Docker image
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Update tags in code
shell: bash
run: |
rye run python bin/mk-release.py ${{ steps.tag.outputs.tag }}
uv run python bin/mk-release.py ${{ steps.tag.outputs.tag }}

- name: Build artifacts
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manage-runner-post/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ runs:
# Configure cache updates
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
# https://github.com/actions/cache/blob/main/examples.md#---bazel
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bazel', 'Cargo.Bazel.lock', 'requirements.lock') }}
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bazel', 'Cargo.Bazel.lock', 'uv.lock') }}
2 changes: 1 addition & 1 deletion .github/workflows/manage-runner-pre/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ runs:
# Configure cache updates
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
# https://github.com/actions/cache/blob/main/examples.md#---bazel
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bazel', 'Cargo.Bazel.lock', 'requirements.lock') }}
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bazel', 'Cargo.Bazel.lock', 'uv.lock') }}
restore-keys: |
${{ runner.os }}-bazel-

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
########################################
- name: "⚒️ Run autoupdate for ic-deps"
run: |
rye sync
rye run python3 scripts/auto-update-revisions.py
uv sync
uv run python3 scripts/auto-update-revisions.py

- name: "⚒️ Completely delete bazel cache and then recreate it"
run: |
Expand Down
3 changes: 3 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ exports_files([
"WORKSPACE.bazel",
"mypy.ini",
"pyproject.toml",
"uv.lock",
])

# requirements.lock is generated from uv.lock using: uv export --format requirements-txt --output-file requirements.lock

alias(
name = "rustfmt",
actual = "@rules_rust//:rustfmt",
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ types.requirements(
# rules_python's `pip.parse(...)`.
pip_requirements = "@python_deps//:requirements.bzl",
# also legal to pass a `requirements.in` here
requirements_txt = "//:requirements-dev.lock",
requirements_txt = "//:requirements.lock",
)
use_repo(types, "pip_types")

Expand Down
3 changes: 3 additions & 0 deletions bazel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports_files([
"generate_requirements_lock.sh",
])
33 changes: 33 additions & 0 deletions bazel/generate_requirements_lock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -euo pipefail

# This script is called by Bazel to ensure requirements.lock is up to date
# It generates requirements.lock from uv.lock if needed

PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$PROJECT_ROOT"

# Check if uv is available
if ! command -v uv &> /dev/null; then
echo "Warning: uv is not installed or not in PATH" >&2
echo "requirements.lock may be out of date" >&2
exit 0
fi

# Check if uv.lock exists
if [ ! -f "uv.lock" ]; then
echo "Warning: uv.lock not found" >&2
exit 0
fi

# Check if requirements.lock exists and is newer than uv.lock
if [ -f "requirements.lock" ] && [ "requirements.lock" -nt "uv.lock" ]; then
# requirements.lock is up to date
exit 0
fi

# Generate requirements.lock from uv.lock
echo "Generating requirements.lock from uv.lock..." >&2
uv export --format requirements-txt --output-file requirements.lock
echo "Updated requirements.lock" >&2
30 changes: 30 additions & 0 deletions bazel/requirements_lock.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Repository rule to generate requirements.lock from uv.lock"""

def _requirements_lock_impl(repository_ctx):
"""Generate requirements.lock from uv.lock"""

# Check if uv is available
uv_result = repository_ctx.execute(["which", "uv"])
if uv_result.return_code != 0:
# uv not found, create an empty requirements.lock
repository_ctx.file("requirements.lock", "# uv not found, please install uv and run: uv export --format requirements-txt --output-file requirements.lock")
return

# Check if uv.lock exists
uv_lock_path = repository_ctx.path("uv.lock")
if not uv_lock_path.exists:
repository_ctx.file("requirements.lock", "# uv.lock not found")
return

# Generate requirements.lock from uv.lock
result = repository_ctx.execute([
"uv", "export", "--format", "requirements-txt", "--output-file", "requirements.lock"
])

if result.return_code != 0:
fail("Failed to generate requirements.lock: " + result.stderr)

requirements_lock = repository_rule(
implementation = _requirements_lock_impl,
attrs = {},
)
10 changes: 5 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone &
echo Cleaning out APT cache for smaller images as per 'http://docs.projectatomic.io/container-best-practices/#_clearing_packaging_caches_and_temporary_package_downloads' >&2 && \
apt-get clean

ENV RYE_HOME="/opt/rye"
ENV PATH="$RYE_HOME/shims:$PATH"
ENV UV_HOME="/opt/uv"
ENV PATH="$UV_HOME/bin:$PATH"

RUN curl -sSf https://rye.astral.sh/get | RYE_NO_AUTO_INSTALL=1 RYE_INSTALL_OPTION="--yes" bash
RUN curl -LsSf https://astral.sh/uv/install.sh | sh

COPY pyproject.toml requirements.lock requirements-dev.lock .python-version README.md ./
COPY pyproject.toml uv.lock .python-version README.md ./

RUN rye sync --no-dev --no-lock
RUN uv sync --no-dev

# Install the "mold" linker for fast linking of Rust executables
ARG mold_version=1.11.0
Expand Down
12 changes: 6 additions & 6 deletions docker/runner.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ RUN ln -s /usr/local/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1 && \
rm -rf openssl


ENV RYE_HOME="/opt/rye"
ENV PATH="$RYE_HOME/shims:$PATH"
ENV UV_HOME="/opt/uv"
ENV PATH="$UV_HOME/bin:$PATH"

RUN curl -sSf https://rye.astral.sh/get | RYE_NO_AUTO_INSTALL=1 RYE_INSTALL_OPTION="--yes" bash
RUN curl -LsSf https://astral.sh/uv/install.sh | sh

COPY pyproject.toml requirements.lock requirements-dev.lock .python-version README.md ./
COPY pyproject.toml uv.lock .python-version README.md ./

RUN rye sync --no-dev --no-lock
RUN uv sync --no-dev

# Runner user
RUN adduser --disabled-password --gecos "" --uid $RUNNER_UID runner \
Expand Down Expand Up @@ -89,7 +89,7 @@ USER runner
WORKDIR /home/runner
SHELL [ "/bin/bash", "-c" ]

RUN source /opt/rye/env
RUN source /opt/uv/env

COPY rust-toolchain.toml /usr/src/rust-toolchain.toml

Expand Down
15 changes: 10 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ version = "0.6.6"
description = ""
authors = [{ name = "DRE Team", email = "[email protected]" }]
readme = "README.md"
# Note: You should add dependencies with `rye add <dependency>`
# Or to add dev-dependencies: `rye add --dev <dependency>`
requires-python = ">=3.12"
# Note: You should add dependencies with `uv add <dependency>`
# Or to add dev-dependencies: `uv add --group dev <dependency>`
# This will ensure that the dependency is added to the correct section and also updates the corresponding lock file(s).
dependencies = [
"requests>=2.32.3",
Expand Down Expand Up @@ -60,10 +61,14 @@ dependencies = [
"filelock==3.18.0",
]

[tool.rye]
[tool.uv]
package = false # This is a special mode in which the package itself is not installed, but only the dependencies are.

[tool.uv.pip]
universal = true # The dependency resolver will attempt to generate a resolution that's valid on all platforms, operating systems, and architectures, rather than a resolution that's specific to the current platform.
virtual = true # This is a special mode in which the package itself is not installed, but only the dependencies are.
dev-dependencies = ["black>=24"]

[dependency-groups]
dev = ["black>=24"]

[tool.black]
line-length = 120
Expand Down
Loading
Loading