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

Support Python 3.12 on Cygwin #1988

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

EliahKagan
Copy link
Contributor

Cygwin has had Python 3.9 as its latest version for a while, with progress both on moving past 3.9.16 for Python 3.9, as well as on packaging Python 3.y for higher y, stalled due to the problem described in #1814. However, packaging work has resumed. This includes Cygwin builds of Python 3.12 (which is successfully packaged for the parallel/forked MSYS2 target). Such builds are marked "test" and do not work properly yet (reports and discussion can be seen in this month's list archive).

Since GitPython has long-standing support for Cygwin, which I suspect remains one of the important use cases of GitPython (with some alternatives not supporting Cygwin), it seems to me that it is worthwhile to support Python 3.12 on Cygwin, as well as to test it on CI. Since the Cygwin downstream build of Python 3.12 is currently experimental and not fully working, I don't expect GitPython to work with it yet. This PR is for testing that, and for keeping track of changes that are known to be wanted whenever Cygwin Python 3.12 is working. I have encountered substantial differences between CI and my local setup with Cygwin in the past, so testing this on CI now may help avoid surprises. It may also lead to the discovery of bugs, or information about known bugs, that could be useful to report on the Cygwin mailing list. This PR is definitely not ready to be merged.

This PR is separate from and in parallel to #1955 (which is about Python 3.13 and blocked due to a need to change some GitPython code to support that version on Windows), because they are conceptually separate with no known overlap in blockers or in changes that would fix them, and because it seems to me that having two PRs makes the situation clear, both to me and to other people who might wish to contribute.

Python 3.12 is currently marked "test" and should not be expected
to fully work. Assuming this successfully installs it, based on
local testing I expect two encounter two problems:

1. Currently, creating a venv with `pip` in Python 3.12 on Cygwin
   does not seem to be working, even though its own global `pip`
   exists. Running `python -m ensurepip` likewise does not work,
   reporting that the bundled `pip-24.3.1-py3-none-any.whl` does
   not exist. The https://bootstrap.pypa.io/get-pip.py script can
   be used as a workaround, assuming the problem also happens on
   CI (which I expect). Eventually, `pip` should be fully working.

2. Once that is worked around, there seem to be problems where
   Python processes terminate unexpectedly and wrongly report
   success, or where subprocess creation fails.

   When I ran `pytest` loading it as a module (`python -m pytest`),
   it collected tests and sometimes started running them, but then
   suddenly terminated with an exit status of 0. When I ran it via
   the `pytest` command (no `python -m`), that problem also usually
   happened, but one time I got an immediate termination instead,
   reporting the following errors, yet still with a 0 exit status:

       0 [main] python3.12 2724 C:\cygwin64\bin\python3.12.exe: *** fatal error in forked process - WFSO timed out performed fork fixups and dynamic dll loading
       0 [main] python3.12 2769 C:\cygwin64\bin\python3.12.exe: *** fatal error in forked process - WFSO timed out performed fork fixups and dynamic dll loading

   And one time I got an immediate termination reporting this
   slightly different error, also with an exit status of 0:

       0 [main] python3.12 3371 C:\cygwin64\bin\python3.12.exe: *** fatal error in forked process - WFSO timed out after longjmp

   This curious combination of errors (or the same error arising
   and being reported in different ways?) is my main motivation for
   testing GitPython on CI with Python 3.12 in Cygwin now, even
   though the Cygwin package `python312` and assocated packages are
   still marked "test". If the problems I observed locally can be
   reproduced, then this may help to find a minimal case that shows
   the problem (assuming that it is due to a Cygwin-related bug).

This commit contains no attempt to avoid or work around either of
those two anticipated problems.
This works around a problem in Python 3.12 on Cygwin where `pip`
fails to intall in a venv via `ensurepip` (both implicitly when the
venv is created normally, and explicitly when `python -m ensurepip`
is attempted), by creating the venv with `--without-pip` and then,
once the venv is set up, bootstrapping `pip` in it by running the
https://bootstrap.pypa.io/get-pip.py script.

Eventually, when `pip` is working automatically in a venv in
Python 3.12 on Cygwin (the problem is specific to that combination,
and the Cygwin `python312*` packages are still marked "test"), this
special-casing can be removed.
@EliahKagan
Copy link
Contributor Author

EliahKagan commented Jan 4, 2025

In both this older run before the #1989-related rebase, and this newer run, the Cygwin Python 3.12 job seems to stall either when attempting to download mypy or immediately afterward. (I can't tell from the logs if the download completes.)

This resembles the problem described for Cygwin python39 3.9.18-1 in #1814, so maybe it's simply that this problem is not solved yet--or maybe it is a different problem that only seems superficially the same. (The part of the download that blocked consistently had been drawing scroll bars, which does not seem to be happening here.)

I have not reproduced that problem locally. The problems I encounter locally--other than the venv pip issue, which is known, worked around in this PR, and which I work around locally--occur once I am actually trying to run the tests. pytest either runs, collects tests, then mysteriously terminates, yet with an exit status of 0; or pytest does not start at all, and an error message is shown, yet still the command has an exit status of 0. This is the second of the two anticipated problems described in 18c7b96; I don't know if they would happen on CI or not, since we don't get that far. Most details of what I observed locally can be seen in this gist.

Edit: I also tried locally running the tests with an MSYS2 build of Python 3.12. (That is, with the downstream Python 3.12 packaged by the MSYS2 project for the MSYS environment. Other environments are native Windows builds, while the MSYS environment is Cygwin-like due to MSYS and MSYS2 being forked from Cygwin. In the MSYS2 build of Python, sys.platform gives 'cygwin'.) This worked fairly well; it does not have the problems observed on the Cygwin Python 3.12. That makes sense, though, since the Cygwin Python 3.12 is experimental. Full details are in this other gist.

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

Successfully merging this pull request may close these issues.

1 participant