eifinger / setup-rye

Set up your GitHub Actions workflow with a specific version of Rye
MIT License
68 stars 3 forks source link

How to force rye to use gh matrix's python version? #232

Closed ManiMozaffar closed 6 months ago

ManiMozaffar commented 6 months ago

Hey, I'm running to an issue that rye is using python 3.8, disrespecting matrix's python version.

For detailed insight: https://github.com/pydantic/FastUI/pull/287#discussion_r1582518466

Any idea how can i match these two? perhaps something to be mentioned in readme?

eifinger commented 6 months ago

Hi, rye will look for the pinned version in .python_version to have to set it as the very first rye command. Here is an example how I use it in one of my repos: https://github.com/eifinger/pywaze/blob/main/.github/workflows/ci.yml

The clear drawback here is, that it is not using the lock files you have on your local setup since it runs sync again.

You can try to change that to sync --no-lock but I had a few problems with that approach. Some dependencies have transitive dependencies depending on the current python version. If you create the lock files with one python version but run it with another this might cause problems. Try it out, depending on your dependencies it might work.

This is an open issue with rye itself I have not found a way yet to work around that.

See: https://github.com/astral-sh/rye/discussions/438 https://github.com/astral-sh/rye/discussions/411

EDIT: I changed the example linked. The previous link was not using multiple python versions (anymore). It is the example also linked in the README

eifinger commented 6 months ago

As FastUI (big fan btw) itself is a library I would argue that its not that big a deal. The final dependency versions which get resolved are defined by the project using it as a dependency. Only pyproject.toml contents will count.

It might cause flaky and hard to debug CI pipelines still...

ManiMozaffar commented 6 months ago

Hi thanks for the quick answer!

Hi, rye will look for the pinned version in .python_version to have to set it as the very first rye command. Here is an example how I use it in one of my repos: https://github.com/eifinger/pywaze/blob/main/.github/workflows/ci.yml

Yes but I didn't push it, because i didn't want it to run only one version.

You can try to change that to sync --no-lock but I had a few problems with that approach. Some dependencies have transitive dependencies depending on the current python version. If you create the lock files with one python version but run it with another this might cause problems. Try it out, depending on your dependencies it might work.

Oh didn't know that! Hmm that makes it even harder to use it on ci with multiple version pythons

Thanks for the example, it was very useful. so rye pin does the job! 👍 I'm still newbie in rye, never used it in any actual project.