You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like trivially use all of the installed Python versions (in full) in my cache keys (like "3.8.16" and "3.9.16 (PyPy 7.3.11)").
This could be implemented in several ways, including:
A python-versions (plural!) output that includes the full Python versions in full. (How it's delimited doesn't matter to me due to my use case.) For example, 3.8.10; 3.9.13; 3.9.16 (PyPy 7.3.11).
A file written at a known or configurable location that lists all of the install Python versions.
Justification:
I'm very pleased with the new ability to install multiple Python versions simultaneously! This pairs well with tox-based testing.
I'm wanting to cache and restore my .tox/ directories between runs, particularly on Windows hosts, because it's expensive to set up the tox environments for each Python version. In the past, with only one Python version installed, I would use the action output, python-version, as a part of the cache key.
However, when multiple versions are installed, if there is a cache hit but one of the Python versions that isn't the default has updated (say, if "3.11" is the default but "3.8" updates from "3.8.10" to "3.8.11") then tox will rebuild the 3.8 environment each time the cache is restored, the cache won't be invalidated, and test setup times will start to increase.
I don't know of a trivial, cross-platform way to write this myself that will work consistently as new Python versions and host platforms are added (like Pyston, as I saw in another ticket)...but I'd prefer to avoid crawling the filesystem and executing python -V on every executable that looks like a Python interpreter.
Therefore, I think that outputting this metadata from within the setup-python action would be the most ideal scenario.
Are you willing to submit a PR?
I'd love to try! I don't know TypeScript and it might take a bit to write something that fits the requirements and runs correctly.
I'll take a look at what that might look like (particularly by studying the existing python-version output) while awaiting feedback for this idea.
I've attempted to implement this. So far in my testing I'm not getting the additional python-versions output. I'm not sure what I'm doing wrong, but if someone could take a look, I'd like to get this ship-shape so I can submit a PR for this!
Hmm...it may be that I need to run ncc to build the project before it will run the new code. I'm having trouble doing that on Windows (I'm getting errors that paths containing backslashes and forward slashes don't exist, but they do if I manually normalize the paths), so I'll try building and testing the changes on Linux today.
Activity
kurtmckee commentedon Feb 10, 2023
I've attempted to implement this. So far in my testing I'm not getting the additional
python-versionsoutput. I'm not sure what I'm doing wrong, but if someone could take a look, I'd like to get this ship-shape so I can submit a PR for this!main...kurtmckee:setup-python:output-python-versions
e-korolevskii commentedon Feb 10, 2023
Hello @kurtmckee!
We will investigate the issue and get back to you.
kurtmckee commentedon Feb 10, 2023
Hmm...it may be that I need to run
nccto build the project before it will run the new code. I'm having trouble doing that on Windows (I'm getting errors that paths containing backslashes and forward slashes don't exist, but they do if I manually normalize the paths), so I'll try building and testing the changes on Linux today.Output `python-versions`, containing all Python versions
Output `python-versions`, containing all Python versions
Output `python-versions` for cache-busting
Output `python-versions` for cache-busting
kurtmckee commentedon May 13, 2024
Closing this.
For any others finding this: I wrote https://github.com/kurtmckee/detect-pythons to address this need, since #611 didn't get reviewed/merged.