Skip to content

Conversation

@liaochris
Copy link
Collaborator

Opening pull so that github actions will run. Will assign reviewers once I confirm that tests pass.

@liaochris liaochris linked an issue Jan 7, 2026 that may be closed by this pull request
@liaochris liaochris self-assigned this Jan 7, 2026
@liaochris
Copy link
Collaborator Author

liaochris commented Jan 7, 2026

@jmshapir

The changes to this pull ended up being more substantial than I originally anticipated. Below, I describe what happened and the fix I made.

Our lab template has different unit tests for windows and unix operating systems. In the past, to get windows unit tests to pass on an unix OS, we would "pretend" to be on a windows platform for those tests. That was the purpose of the platform_patch function.

At a high level, as of Python 3.12, that no longer works, because the behavior of windows commands on a windows system no longer aligns with actual windows commands on a linux system pretending to be a windows platform.
I fixed this by changing the code so that we only run unix-specific unit tests on unix OS's, and same for windows (and non-Windows/Unix OS's).

Hence, in addition to updating the python versions the template officially supports, I had to modify our unit tests slightly.

Technical details

Python 3.12 included this PR (python/cpython#103179), which modified the shutil.which command (which is called by one of the functions in our unit tests).
The command now checks the value of the attribute NeedCurrentDirectoryForExePath.
This is a problem because the attribute NeedCurrentDirectoryForExePath in the Windows platform API object is only present on Windows platform API objects on actual windows OS's, not unix OS's pretending to be windows platforms.

The least intrusive change would be to add this attribute to the Windows platform API objects for unix OS's. However, it seems a little odd to pretend to be a windows platform on a unix OS (and vice versa) for the sake of passing unit tests, instead of just skipping the unit tests that aren't relevant to the OS. In this pull, I updated the code to do just that - we only run windows-specific unit tests on windows OS's and the same for unix etc.

If we look at the Test with pytest dropdown of any of the unit tests, we now see that we're skipping a few of the unit tests.

On an unrelated note, this was fun to learn about.

@liaochris liaochris requested a review from jmshapir January 7, 2026 19:23
@jmshapir jmshapir requested a review from jinfu93 January 7, 2026 20:21
Copy link
Contributor

@jmshapir jmshapir left a comment

Choose a reason for hiding this comment

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

@liaochris looks good to me!

@jinfu93 would you be up for taking a quick pass over the changes to confirm they look ok to you too?

Thanks both!

@jinfu93
Copy link
Collaborator

jinfu93 commented Jan 8, 2026

@liaochris @jmshapir reviewed and changes make sense to me too!

@liaochris liaochris merged commit 73fefa0 into main Jan 9, 2026
15 checks passed
@liaochris
Copy link
Collaborator Author

summary comment

@liaochris liaochris deleted the 137-update-python-versions-in-actions branch January 9, 2026 16:38
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

Successfully merging this pull request may close these issues.

Update python versions in actions

4 participants