Skip to content
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

Enable creation of venv with existing python version #217

Open
xmatthias opened this issue Dec 29, 2024 · 0 comments
Open

Enable creation of venv with existing python version #217

xmatthias opened this issue Dec 29, 2024 · 0 comments

Comments

@xmatthias
Copy link

xmatthias commented Dec 29, 2024

the FAQ specifically mentions:

Using actions/setup-python can be faster, because GitHub caches the Python versions alongside the runner.

So as a consequence - i'm trying to use that - but use the astral-sh/setup-uv function to install UV.
Unfortunately, there seems to be no way to have uv setup a virtual environment - all while reusing the existing python installation.

The only way i found was through passing in python-version: ${{ matrix.python-version }} - but that installs a 2nd copy of python alongside the one installed via actions/setup-python - so contradicts the above FAQ entry (i could remove the setup-python action as it's python ain't used).

    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install uv
      uses: astral-sh/setup-uv@v5
      with:
        python-version: ${{ matrix.python-version }}
current workaround

(note: the below is for the windows variant - others will need slightly different workarounds)

    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install uv
      uses: astral-sh/setup-uv@v5

    - name: Installation
      run: |
        uv venv
        .venv\Scripts\activate
        # persist the venv path for future steps
        "$(pwd)/.venv/Scripts" >> $env:GITHUB_PATH
 ... 

Desired solution:
A flag/parameter to allow UV to use the existing python installed via setup-python - but still do the venv magic (create venv, aktivate for the rest of the job, caching, ...)

    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install uv
      uses: astral-sh/setup-uv@v5
      with:
        create-venv: true
@xmatthias xmatthias changed the title Enable creation of venv with installed python version Enable creation of venv with existing python version Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant