-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(wrappers/python): fix windows venv activation
It turns out windows virtualenvs have a different directory structure than normal OSs: binaries are placed in `Scripts` instead of `bin`, and only `python` is available as an executable (no `python3`).
- Loading branch information
Showing
6 changed files
with
71 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
cd wrappers/python | ||
|
||
VIRTUAL_ENV="$PWD/.venv" | ||
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> "$GITHUB_ENV" | ||
|
||
if ! [ -d "$VIRTUAL_ENV" ]; then | ||
echo "No virtualenv found at $VIRTUAL_ENV" | ||
exit 127 | ||
fi | ||
|
||
# Ensure binaries from the virtualenv are available at the start of $PATH | ||
# see https://docs.python.org/3/library/venv.html#creating-virtual-environments | ||
if [ -d "$VIRTUAL_ENV/bin" ]; then | ||
# on unix systems, virtualenv puts executables in .venv/bin | ||
venv_bin_path="$VIRTUAL_ENV/bin" | ||
elif [ -d "$VIRTUAL_ENV/Scripts" ]; then | ||
# on windows, virtualenv places executables in .venv/Scripts | ||
venv_bin_path="$VIRTUAL_ENV/Scripts" | ||
fi | ||
|
||
echo "$venv_bin_path" >> "$GITHUB_PATH" | ||
# see https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path |
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,21 +1,39 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
cd wrappers/python | ||
export VIRTUAL_ENV="$PWD/.venv" | ||
export PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
||
echo "VIRTUAL_ENV=$VIRTUAL_ENV" | ||
|
||
# shellcheck disable=SC2016 | ||
echo '$PATH:' | ||
echo "$PATH" | tr ':' '\n - ' | ||
echo "$PATH" | tr ':' '\n' | sed 's/^/ - /g' | ||
|
||
echo | ||
echo " python ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " | ||
echo | ||
|
||
python --version | ||
command -v python | ||
command -v python3 | ||
stat ./.venv/bin/python \ | ||
|| stat ./.venv/Scripts/python.exe \ | ||
|| echo "missing .venv/bin/python{.exe}" | ||
|
||
echo | ||
echo " poetry ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " | ||
echo | ||
|
||
command -v poetry || echo "missing poetry" | ||
|
||
echo | ||
echo " mypy ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " | ||
echo | ||
|
||
if ! command -v mypy; then | ||
if command -v mypy.exe; then | ||
echo "missing mypy, but found mypy.exe" | ||
else | ||
echo "missing mypy{.exe}" | ||
fi | ||
fi | ||
stat ./.venv/bin/python || stat ./.venv/bin/python.exe || echo "missing .venv/bin/python{.exe}" | ||
python --version | ||
|
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,5 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
python3 -m mypy src scripts | ||
python3 -m ruff check | ||
python3 -m ruff format --check | ||
mypy src scripts | ||
ruff check | ||
ruff format --check |