Add some helper scripts to build a fully-locked wheel

This commit is contained in:
Damien Elmes 2025-06-14 14:18:32 +07:00
parent 7e3a5a26bb
commit b8a22f3078
6 changed files with 915 additions and 833 deletions

View file

@ -35,7 +35,7 @@ pub fn setup_pyenv(args: PyenvArgs) {
run_command(
Command::new(args.uv_bin)
.env("UV_PROJECT_ENVIRONMENT", args.pyenv_folder.clone())
.args(["sync"])
.args(["sync", "--frozen"])
.args(args.extra_args),
);

View file

@ -3,7 +3,10 @@ name = "anki-dev"
version = "0.0.0"
description = "Local-only environment"
requires-python = ">=3.9"
dependencies = [
classifiers = ["Private :: Do Not Upload"]
[dependency-groups]
dev = [
"black==24.8.0", # temporary pin during uv migration
"isort",
"mypy==1.11.2", # temporary pin during uv migration

1
qt/bundle/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
release/pyproject.toml

14
qt/bundle/publish-release.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
export UV_PUBLISH_TOKEN=$(pass show w/pypi-api-test)
# Get the project root (two levels up from qt/bundle)
PROJ_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
# Use extracted uv binary
UV="$PROJ_ROOT/out/extracted/uv/uv"
cd release
rm -rf dist
"$UV" build --wheel
"$UV" publish --index testpypi

58
qt/bundle/update-release.sh Executable file
View file

@ -0,0 +1,58 @@
#!/bin/bash
set -e
# Get the project root (two levels up from qt/bundle)
PROJ_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
# Use extracted uv binary
UV="$PROJ_ROOT/out/extracted/uv/uv"
# Prompt for wheel version
read -p "Wheel version: " VERSION
# Create release directory if it doesn't exist
mkdir -p release
# Export dependencies using uv
echo "Exporting dependencies..."
DEPS=$("$UV" export --no-hashes --no-annotate --no-header --extra audio --extra qt --all-packages --no-dev --no-emit-workspace)
# Generate the pyproject.toml file
cat > release/pyproject.toml << EOF
[project]
name = "anki-release"
version = "$VERSION"
description = "A package to lock Anki's dependencies"
requires-python = ">=3.9"
dependencies = [
"anki==$VERSION",
"aqt==$VERSION",
EOF
# Add the exported dependencies to the file
echo "$DEPS" | while IFS= read -r line; do
if [[ -n "$line" ]]; then
echo " \"$line\"," >> release/pyproject.toml
fi
done
# Complete the pyproject.toml file
cat >> release/pyproject.toml << 'EOF'
]
[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
# hatch throws an error if nothing is included
[tool.hatch.build.targets.wheel]
include = ["no-such-file"]
EOF
echo "Generated release/pyproject.toml with version $VERSION"

1668
uv.lock

File diff suppressed because it is too large Load diff