-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In #166, create_venv was switched to perform a `uv pip sync`, but this has slightly different semantics than `uv pip install`. The latter will expand the input requirements as needed, while the former treats the input as a complete lockfile. To achieve both behaviors, revert `create_venv` to its old functionality and add a `sync_venv` macro that runs `uv pip sync`.
- Loading branch information
Showing
6 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
UV="{{uv}}" | ||
RESOLVED_PYTHON="{{resolved_python}}" | ||
REQUIREMENTS_TXT="{{requirements_txt}}" | ||
|
||
PYTHON="$(realpath "$RESOLVED_PYTHON")" | ||
|
||
bold="$(tput bold)" | ||
normal="$(tput sgr0)" | ||
|
||
if [ $# -gt 1 ]; then | ||
echo "create-venv takes one optional argument, the path to the virtual environment." | ||
exit -1 | ||
elif [ $# == 0 ] || [ -z "$1" ]; then | ||
target="{{destination_folder}}" | ||
else | ||
target="$1" | ||
fi | ||
|
||
if [ "${target}" == "/" ] || [ "${target}" == "." ] | ||
then | ||
echo "${bold}Invalid venv target '${target}'${normal}" | ||
exit -1 | ||
fi | ||
|
||
"$UV" venv "$BUILD_WORKSPACE_DIRECTORY/$target" --python "$PYTHON" --allow-existing | ||
source "$BUILD_WORKSPACE_DIRECTORY/$target/bin/activate" | ||
"$UV" pip sync "$REQUIREMENTS_TXT" {{args}} | ||
|
||
site_packages_extra_files=({{site_packages_extra_files}}) | ||
if [ ! -z ${site_packages_extra_files+x} ]; then | ||
site_packages_dir=$(find "$BUILD_WORKSPACE_DIRECTORY/$target/lib" -type d -name 'site-packages') | ||
for file in "${site_packages_extra_files[@]}"; do | ||
cp "$file" "$site_packages_dir"/ | ||
done | ||
fi | ||
|
||
echo "${bold}Created '${target}', to activate run:${normal}" | ||
echo " source ${target}/bin/activate" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
"uv based virtual env generation" | ||
|
||
load("//uv/private:venv.bzl", _create_venv = "create_venv") | ||
load("//uv/private:venv.bzl", _create_venv = "create_venv", _sync_venv = "sync_venv") | ||
|
||
create_venv = _create_venv | ||
sync_venv = _sync_venv |