Skip to content

Commit

Permalink
Don't use pipx
Browse files Browse the repository at this point in the history
  • Loading branch information
KapJI committed Sep 12, 2024
1 parent de53abc commit 75c502f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 53 deletions.
37 changes: 5 additions & 32 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,16 @@
name: "Setup Python Environment"
description: "Sets up pipx and Python environment paths for both bash and pwsh."

runs:
using: "composite"
steps:
- name: Setup environment in bash (Linux, macOS)
- name: Setup environment in bash
id: env-bash
shell: bash
if: runner.os != 'Windows'
run: |
PIPX_HOME="$HOME/.pipx"
PIPX_BIN_DIR="$PIPX_HOME/bin"
echo "PIPX_HOME=$PIPX_HOME" >> $GITHUB_ENV
echo "PIPX_BIN_DIR=$PIPX_BIN_DIR" >> $GITHUB_ENV
echo "$PIPX_BIN_DIR" >> $GITHUB_PATH
PYTHON_USER_BASE="$(python3 -m site --user-base)"
PYTHON_USER_BASE="$(python -m site --user-base)"
echo "$PYTHON_USER_BASE/bin" >> $GITHUB_PATH
echo "python-user-base=$PYTHON_USER_BASE" >> $GITHUB_OUTPUT
echo "pipx-home=$PIPX_HOME" >> $GITHUB_OUTPUT
- name: Setup environment in pwsh (Windows)
id: env-pwsh
shell: pwsh
if: runner.os == 'Windows'
run: |
$PIPX_HOME = "$env:USERPROFILE\.pipx"
$PIPX_BIN_DIR = "$PIPX_HOME\bin"
echo "PIPX_HOME=$PIPX_HOME" | Out-File -Append -FilePath $env:GITHUB_ENV
echo "PIPX_BIN_DIR=$PIPX_BIN_DIR" | Out-File -Append -FilePath $env:GITHUB_ENV
echo "$PIPX_BIN_DIR" | Out-File -Append -FilePath $env:GITHUB_PATH
$PYTHON_USER_BASE = (python -m site --user-base)
echo "$PYTHON_USER_BASE\Scripts" | Out-File -Append -FilePath $env:GITHUB_PATH
echo "python-user-base=$PYTHON_USER_BASE" | Out-File -Append -FilePath $env:GITHUB_OUTPUT
echo "pipx-home=$PIPX_HOME" | Out-File -Append -FilePath $env:GITHUB_OUTPUT
echo "pip-user-base=$PYTHON_USER_BASE" >> $GITHUB_OUTPUT
outputs:
python-user-base:
description: "The Python user base path"
value: ${{ steps.env-bash.outputs.python-user-base || steps.env-pwsh.outputs.python-user-base }}
pipx-home:
description: "Home directory of pipx"
value: ${{ steps.env-bash.outputs.pipx-home || steps.env-pwsh.outputs.pipx-home }}
pip-user-base:
value: ${{ steps.env-bash.outputs.pip-user-base }}
27 changes: 6 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,28 @@ jobs:
uses: ./.github/actions/setup-environment
id: environment

- name: Get pipx and poetry latest versions
- name: Get poetry latest version
id: latest-versions
shell: bash
run: |
pipx_version=$(curl -s https://pypi.org/pypi/pipx/json | jq -r .info.version)
poetry_version=$(curl -s https://pypi.org/pypi/poetry/json | jq -r .info.version)
echo "pipx=$pipx_version" >> $GITHUB_OUTPUT
echo "poetry=$poetry_version" >> $GITHUB_OUTPUT
echo "PIP_USER: $PIP_USER"
- uses: actions/cache@v4
name: Cache pipx
with:
path: ${{ steps.environment.outputs.python-user-base }}
key: >
${{ format('pip-user-{0}-{1}-{2}',
matrix.os,
matrix.python-version,
steps.latest-versions.outputs.pipx
) }}
echo "Python user base: $(python -m site --user-base)"
- uses: actions/cache@v4
name: Cache Poetry
with:
path: ${{ steps.environment.outputs.pipx-home }}
path: ${{ steps.environment.outputs.pip-user-base }}
key: >
${{ format('pipx-home-{0}-{1}-{2}',
${{ format('pip-user-{0}-{1}-{2}',
matrix.os,
matrix.python-version,
steps.latest-versions.outputs.poetry
) }}
- name: Install pipx
run: pip install --user --verbose pipx

- name: Install or update Poetry
run: pipx install poetry==${{ steps.latest-versions.outputs.poetry }}
run: |
pip install --user poetry==${{ steps.latest-versions.outputs.poetry }}
- name: Use local virtual environment
run: |
Expand Down

0 comments on commit 75c502f

Please sign in to comment.