Skip to content

Commit

Permalink
use export instead of pip compile
Browse files Browse the repository at this point in the history
  • Loading branch information
Askir committed Jan 17, 2025
1 parent 049bf2c commit 4c435c4
Show file tree
Hide file tree
Showing 6 changed files with 4,362 additions and 214 deletions.
4 changes: 2 additions & 2 deletions projects/extension/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN set -e; \
FROM base AS pgai-test-db
ENV PG_MAJOR=${PG_MAJOR}
ENV PIP_BREAK_SYSTEM_PACKAGES=1
RUN pip install uv==0.5.9
RUN pip install uv==0.5.20
WORKDIR /pgai
COPY . .
RUN just build install
Expand All @@ -59,7 +59,7 @@ FROM base
ENV WHERE_AM_I=docker
USER root

RUN pip install --break-system-packages uv==0.5.9
RUN pip install --break-system-packages uv==0.5.20

# install pgspot
RUN set -eux; \
Expand Down
22 changes: 14 additions & 8 deletions projects/extension/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def check_requirements() -> None:
try:
# Generate current requirements
subprocess.run(
f"uv pip compile pyproject.toml -o {tmp_file.name}",
f"uv export --quiet --format requirements-txt -o {tmp_file.name}",
shell=True,
check=True,
env=os.environ,
Expand All @@ -718,17 +718,23 @@ def check_requirements() -> None:
lock_file = ext_dir() / "requirements-lock.txt"
if not lock_file.exists():
fatal(
"requirements-lock.txt does not exist. Run 'uv pip compile pyproject.toml -o requirements-lock.txt' to create it."
"requirements-lock.txt does not exist. Run 'uv export --format requirements-txt -o requirements-lock.txt' to create it."
)

current_reqs = tmp_file.name
from difflib import unified_diff

# Compare files
with open(lock_file, "r") as f1, open(current_reqs, "r") as f2:
if f1.read() != f2.read():
with open(lock_file, "r") as f1, open(tmp_file.name, "r") as f2:
# Skip the first 3 lines when reading both files since the contain a line with the file name
# which will always be different
lock_contents = f1.readlines()[3:]
current_contents = f2.readlines()[3:]

diff = list(unified_diff(lock_contents, current_contents))
if diff:
fatal(
"requirements-lock.txt is out of sync with pyproject.toml. "
"Run 'uv pip compile pyproject.toml -o requirements-lock.txt' to update it."
"requirements-lock.txt is out of sync with uv.lock.\n"
"Run 'uv export --format requirements-txt -o requirements-lock.txt' to update it.\n"
"".join(diff)
)
finally:
# Clean up temporary file
Expand Down
2 changes: 1 addition & 1 deletion projects/extension/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dev = [
"fastapi==0.112.0",
"fastapi-cli==0.0.5",
"psycopg[binary]==3.2.1",
"uv==0.5.9",
"uv==0.5.20",
]

[tool.setuptools.dynamic]
Expand Down
Loading

0 comments on commit 4c435c4

Please sign in to comment.