Skip to content

Add pythonrelease and pythonrelease_info grains - #70070

Open
xhon-pelushi wants to merge 1 commit into
saltstack:3008.xfrom
xhon-pelushi:fix/59594-pythonrelease-grains
Open

Add pythonrelease and pythonrelease_info grains#70070
xhon-pelushi wants to merge 1 commit into
saltstack:3008.xfrom
xhon-pelushi:fix/59594-pythonrelease-grains

Conversation

@xhon-pelushi

Copy link
Copy Markdown

What does this PR do?

Adds pythonrelease and pythonrelease_info grains.

What issues does this PR fix or reference?

Fixes #59594

Background

pythonversion is a list rather than a dotted string:

pythonversion:
    - 3
    - 11
    - 0
    - final
    - 0

which breaks the <foo>release / <foo>release_info convention the other version grains follow (osrelease is 7.9.2009 with osrelease_info carrying the tuple; likewise kernelrelease).

The issue suggested adding pythonrelease / pythonrelease_info and deprecating pythonversion at some documented future point. This PR does only the additive half — it deliberately does not touch or deprecate pythonversion, so it carries no backwards-compatibility risk. The deprecation is a separate decision for the maintainers.

Result

pythonversion:      [3, 12, 3, 'final', 0]   # unchanged
pythonrelease:      '3.12.3'
pythonrelease_info: [3, 12, 3, 'final', 0]

pythonrelease uses platform.python_version(), which is defined as major.minor.micro and so matches the shape of osrelease.

Tests written?

Yes — added test_pythonrelease to tests/pytests/unit/grains/test_core.py, asserting the dotted form matches both platform.python_version() and major.minor.micro, that pythonrelease_info matches sys.version_info, and that it stays in sync with the pre-existing pythonversion grain.

Verified locally:

  • Both test_pythonversion (pre-existing, confirming the old grain is untouched) and the new test_pythonrelease pass against the real salt.grains.core module.
  • Checked the two other tests that reference this grain — tests/pytests/integration/modules/grains/test_module.py and tests/pytests/pkg/integration/test_salt_grains.py — both assert membership (assert grain in ret.data) rather than an exact grain set, so adding grains does not affect them.
  • black==24.2.0 (the version pinned in .pre-commit-config.yaml) reports both changed files unchanged.

I was not able to run the full tests/pytests/unit/grains/test_core.py suite locally — the salt-factories conftest setup didn't complete in this environment — so CI is the real check on the rest of that file.

Commits signed with GPG?

No

@xhon-pelushi
xhon-pelushi requested a review from a team as a code owner August 17, 2026 03:33
@twangboy twangboy added test:full Run the full test suite Abandoned and removed Abandoned labels Aug 18, 2026
@twangboy
twangboy force-pushed the fix/59594-pythonrelease-grains branch from dd2dea6 to 832d9f6 Compare August 18, 2026 14:09
@twangboy

Copy link
Copy Markdown
Contributor

We'll run these test once the nightlies master branch tests are green. Otherwise they have no hope of passing. Or you could rebase this on the 3008.x branch.

The pythonversion grain is a list, which breaks the
<foo>release / <foo>release_info convention used by the other version
grains such as osrelease / osrelease_info.

Add pythonrelease (the dotted version string, e.g. 3.11.0) and
pythonrelease_info (the equivalent list) alongside it. The change is
purely additive: pythonversion keeps its existing value and type, so
nothing that reads it today is affected.

Fixes saltstack#59594
@xhon-pelushi
xhon-pelushi changed the base branch from master to 3008.x August 20, 2026 02:47
@xhon-pelushi
xhon-pelushi force-pushed the fix/59594-pythonrelease-grains branch from 832d9f6 to ffad2b9 Compare August 20, 2026 02:48
@xhon-pelushi

Copy link
Copy Markdown
Author

Thanks @twangboy — the master nightlies still aren't green, so I've taken the second option: this is now rebased onto 3008.x and the PR base has been retargeted to 3008.x.

For reference, every Nightly (branch: master) run has failed for the last 10 days, including the most recent one against the current master tip (8c502c0b):

Date (UTC) master 3008.x
2026-08-20 failure in progress
2026-08-19 failure success
2026-08-18 failure success
2026-08-17 failure success
2026-08-16 failure success
2026-08-15 failure success

The rebase was clean — this is a single, purely additive commit and pythonversion() is identical on both branches, so it applied with no conflicts and the diff is unchanged (3 files, +39/-1). platform and sys were already imported in both salt/grains/core.py and tests/pytests/unit/grains/test_core.py on 3008.x, so no new imports were needed.

Happy to move it back to master if you'd rather wait for the nightlies there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pythonversion breaks "_info" pattern of other grains.

2 participants