-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No VIRTUAL_ENV
variable available?
#359
Comments
Hello @jenstroeger |
Hi @jenstroeger We cannot set pre-defined If you use Windows and Linux runners in the single workflow file you can use if condition for Workflow example: jobs:
run_master:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python: [ '3.9', '3.10' ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- name: venv activate Linux
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: |
mkdir test-venv
cd test-venv
python -m venv .
source ./bin/activate
echo "VIRTUAL_ENV: $VIRTUAL_ENV"
- name: venv activate Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
mkdir test-venv
cd test-venv
python -m venv .
./Scripts/Activate.ps1
Write-Host "VIRTUAL_ENV: $env:VIRTUAL_ENV" It works as expected and |
Hmm, thank you @vsafonkin! I’m curious: why does the |
@jenstroeger, the setting up and activation of |
Thanks @vsafonkin, that makes sense. Ok to close this issue? |
@jenstroeger, yes, I believe this issue can be closed. |
@vsafonkin Following up on the above conversation. Is it correct that every jobs:
foo:
steps:
- name: This.
run: echo "This"
- name: That.
run: echo "That" The two |
@jenstroeger, it's correct. You can use - name: venv activate Linux
run: |
mkdir test-venv
cd test-venv
python -m venv .
source ./bin/activate
echo "VIRTUAL_ENV: $VIRTUAL_ENV"
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
- name: test
run: |
echo "VIRTUAL_ENV: $VIRTUAL_ENV" |
And regarding the |
Even running the |
Description:
In an activated Python virtual environment (venv), the environment variable
VIRTUAL_ENV
contains the path to the base of the venv. That variable doesn’t exists, and it doesn’t seem possible to activate the environment in the action either? I could pass in that variable but then I’d have to make an assumption about where this Action installs Python on the runner.Action version:
v3, latest
Platform:
Runner type:
Tools version:
I tried with 3.9 and 3.10 and it failed for both.
Repro steps:
Failed activate:
No
VIRTUAL_ENV
variable:Expected behavior:
Either being able to activate the environment (which is tricky from an Action considering the differences between Windows (
Scripts/
folder) and Linux/Mac (bin/
folder). Ideally, theVIRTUAL_ENV
would be set?Actual behavior:
The variable isn’t available.
The text was updated successfully, but these errors were encountered: