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

Auto activate venv when python-version is set #194

Merged
merged 1 commit into from
Dec 20, 2024
Merged

Conversation

eifinger
Copy link
Collaborator

Closes: #124

@eifinger eifinger force-pushed the auto-environment branch 17 times, most recently from 9595274 to 1dd7e4b Compare December 16, 2024 19:09
@eifinger eifinger force-pushed the auto-environment branch 2 times, most recently from ccecdb8 to 84c49d2 Compare December 16, 2024 19:24
Copy link

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! I'm coming from #124 (comment), and I think this should resolve most of our problems with using setup-uv in pyodide/pyodide#5255.

However, additionally, I was also testing this action on HIPS/autograd#659, and I found that it was difficult to get uv to pick the correct Python version I have set up using the actions/setup-python action, and what this action is doing here seems to resolve the problem by using its own setup-python variable and using https://github.com/indygreg/python-build-standalone to grab Python binaries. Is there a way for uv to "infer" the version of Python I set using actions/setup-python without hacking my way with its outputs? That is, I'd love to be able to use the GHA Python builds seamlessly instead of using uv's Python builds, since the latter still have some rough edges when working with compiled projects – where building from source has been battle-tested on Python binaries from GHA (or other sources, such as conda-forge).

Edit: sorry, I should have checked the FAQ as well :) https://github.com/astral-sh/setup-uv#do-i-still-need-actionssetup-python-alongside-setup-uv. To elaborate a bit further: I think it's fine to use the standalone builds for pure Python projects and not recommend using actions/setup-python, but here was a recent case where there were troubles with NumPy: astral-sh/python-build-standalone#374

@eifinger
Copy link
Collaborator Author

eifinger commented Dec 19, 2024

@agriyakhetarpal I think the following should work:

test-python-version:
  runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.12", "3.13"]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install latest version
        uses: astral-sh/setup-uv@auto-environment
        with:
          python-version: ${{ matrix.python-version }}

uv should then pickup the already configured system python by GHA and use it

@agriyakhetarpal
Copy link

agriyakhetarpal commented Dec 19, 2024

Ah, good idea – I will try that after this PR makes it to a release, so that I don't need to pass --system to the install command. Thanks!

@eifinger eifinger added enhancement New feature or request and removed breaking-change labels Dec 20, 2024
@eifinger eifinger merged commit dd57877 into main Dec 20, 2024
50 checks passed
@eifinger eifinger deleted the auto-environment branch December 20, 2024 07:24
@ngoldbaum
Copy link

I should probably say that the weird floating point exception issues I saw with the python-build-standalone python I ultimately was able to reproduce with the python.org Python, so it probably has something to do with the system I was testing on.

The issues with INCLUDEPY should be resolved in uv.

I'm hoping to try converting some of the numpy and pyo3 CI jobs to use uv's python-build-standalone python soon and will follow up with any issues.

Thanks so much for working to improve Python packaging and distribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confused about how to use without a virtualenv
3 participants