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

Patching pypy venv #502

Merged
merged 11 commits into from
Dec 31, 2020
Merged

Patching pypy venv #502

merged 11 commits into from
Dec 31, 2020

Conversation

Czaki
Copy link
Contributor

@Czaki Czaki commented Dec 27, 2020

Fix for the problem reported in #501

@Czaki
Copy link
Contributor Author

Czaki commented Dec 28, 2020

@henryiii @mattip
Could you check this?

I do not understand why windows build pass, maybe my modification of the test is not enough?

@mattip
Copy link
Contributor

mattip commented Dec 28, 2020

These changes are only needed for posix.

@Czaki Czaki marked this pull request as ready for review December 28, 2020 17:37
@henryiii
Copy link
Contributor

I think we should have a reminder somewhere that this can be reverted after the next PyPy release. @joerick?

@Czaki
Copy link
Contributor Author

Czaki commented Dec 28, 2020

I think we should have a reminder somewhere that this can be reverted after the next PyPy release. @joerick?

one of the problem of this PR is that this code fails when cannot apply the patch. So It will fail when the user does not use pinned images, but will signal that there is need to remove patch after update.

Or I should ignore fail of patch?

@henryiii
Copy link
Contributor

Can it check PyPy version?

@Czaki
Copy link
Contributor Author

Czaki commented Dec 28, 2020

Can it check PyPy version?

maybe it could parse pypy string.

@mattip
Copy link
Contributor

mattip commented Dec 28, 2020

pypy -c "import sys; print(sys.pypy_version_info < (7,3,4))" prints True for versions needing the patch

@joerick
Copy link
Contributor

joerick commented Dec 29, 2020

I think we should have a reminder somewhere that this can be reverted after the next PyPy release. @joerick?

Let's open a draft PR that reverts these changes once this is merged, that way we won't forget about it

@henryiii
Copy link
Contributor

pypy -c "import sys; print(sys.pypy_version_info < (7,3,4))" prints True for versions needing the patch

You could use a sys.exit return value, but anyway this probably should be the thing the patch triggers on.

Let's open a draft PR that reverts these changes once this is merged, that way we won't forget about it

Most users will use latest versions or the pinned versions, I think, so there would be no reason to still support 7.3.3 after we have a version pinning 7.3.4?

@Czaki
Copy link
Contributor Author

Czaki commented Dec 29, 2020

Most users will use latest versions or the pinned versions, I think, so there would be no reason to still support 7.3.3 after we have a version pinning 7.3.4?

I one project I use prebuild docker images because build libraries take ~0.5h. Of course, I will know that I need immediately rebuild docker images, but maybe some other users decide for the same workflow.

@joerick
Copy link
Contributor

joerick commented Dec 29, 2020

Ah, right. Well maybe we can leave it around until the next minor point release.

@YannickJadoul
Copy link
Member

Sorry, @Czaki, I was trying something, but by accident pushed to your branch instead of my local one!

@YannickJadoul
Copy link
Member

Not sure why GHA wasn't triggered, but this seems to work, and is a dramatic simplification: YannickJadoul@615e905.
Here's the manual GHA run: https://github.com/YannickJadoul/cibuildwheel/runs/1622585851

Mind if I push to your branch, @Czaki, or do you prefer to pull from my branch yourself?

@Czaki
Copy link
Contributor Author

Czaki commented Dec 29, 2020

Mind if I push to your branch, @Czaki, or do you prefer to pull from my branch yourself?

-d allows to patch the whole directory?

@YannickJadoul
Copy link
Member

-d allows to patch the whole directory?

Officially, it says that flag changes to that directory before applying the patch. Then if you only pass one file, that's the patch file, and it will go looking for which files to patch (since they are in the diff, anyway)

@henryiii
Copy link
Contributor

Patches are not per-file, add “.patch” to the url of any pull request and you get a single file that describes the whole PR.

@YannickJadoul
Copy link
Member

@Czaki, so I'm pushing?

@Czaki
Copy link
Contributor Author

Czaki commented Dec 29, 2020

Push. I do not know why I have a problem with patch the whole directory (so I split on two files).

@YannickJadoul
Copy link
Member

YannickJadoul commented Dec 29, 2020

I sneaked in another commit, removing the pypy_patch function, since it has become so small, and isn't really very informative to read (to me, at least; it doesn't say what patch or anything).

Feel free to discuss/remove, if necessary.

I also added a small test to test_testing.py:

    def test_time_to_remove_the_pypy_venv_patch(self):
        assert not hasattr(sys, "pypy_version_info") or sys.pypy_version_info < (7,3,4)

Not sure if this is a great plan, but it could work as this reminder? (We can't just easily test that in cibuildwheel, because we're not running on PyPy, there; at least, we don't know what we're running on, so probably CPython.)

EDIT: Please review/discuss this hack; I'm not convinced about it myself ;-)

@joerick
Copy link
Contributor

joerick commented Dec 29, 2020

I also added a small test to test_testing.py:

Good idea! But I think we were planning to leave the patch in for a couple releases, even after our pinned version has upgraded, because users might still choose to specify an older version via a docker image. So it's perhaps not appropriate. Anyway, since we can check sys.pypy_version_info before applying the patch, it's not causing much harm being there for a little while.

@YannickJadoul
Copy link
Member

Anyway, since we can check sys.pypy_version_info before applying the patch, it's not causing much harm being there for a little while.

Well, that's the part that's not obvious to do, because you need to check the version of the "guess" PyPy, rather than of the host Python.

@Czaki
Copy link
Contributor Author

Czaki commented Dec 29, 2020

Right, but shouldn't we just say that the future version of cibuildwheel that support PyPy 7.3.4 doesn't support PyPy 7.3.3 anymore? If we don't support it on mac anymore, why would we support the docker image for Linux?

There are two questions. If version supporting 7.3.3 should support 7.3.4 (someone updates his docker image without the update of cibuildwheel, because of the rebuild of some dependency). And current implementation supports it.

The second question is what to do when changing the base version of PyPy to 7.3.4. I personally prefer to not break compatibility immediately. Especially in the context of the last Cent Os changes.

@YannickJadoul
Copy link
Member

There are two questions. If version supporting 7.3.3 should support 7.3.4 (someone updates his docker image without the update of cibuildwheel, because of the rebuild of some dependency). And current implementation supports it.

That's a good point though; I had only thought about backwards compatibility.

The second question is what to do when changing the base version of PyPy to 7.3.4. I personally prefer to not break compatibility immediately. Especially in the context of the last Cent Os changes.

Well, but then you should stay on an older version of cibuildwheel, I'd say. It's pretty bad practice to build on a different PyPy version on macOS than on Linux, no?
But fair enough.

@Czaki
Copy link
Contributor Author

Czaki commented Dec 29, 2020

Well, but then you should stay on an older version of cibuildwheel, I'd say. It's pretty bad practice to build on a different PyPy version on macOS than on Linux, no?
But fair enough.

Maybe a fast drop is a good decision when adding proper information to the documentation.

@joerick
Copy link
Contributor

joerick commented Dec 29, 2020

It's pretty bad practice to build on a different PyPy version on macOS than on Linux, no?

Good point, I had not considered this. In that case I'd also be in favour of a quick drop once we have the bug fix in pypy.

@YannickJadoul
Copy link
Member

@Czaki, I think you're looking for

assert sys.platform != "darwin" or not hasattr(sys, "pypy_version_info") or sys.pypy_version_info < (7,3,4)

if you only want the last two parts tested on macOS.

@YannickJadoul
Copy link
Member

Something seems to be going horribly wrong, though? Tests just stall after printing test/test_0_basic.py :-(

@Czaki
Copy link
Contributor Author

Czaki commented Dec 29, 2020

Something seems to be going horribly wrong, though? Tests just stall after printing test/test_0_basic.py :-(

I suggest wait. Maybe some download fail. I suggest restart tomorrow morning. Last changes does not affect test_0_basic.

@henryiii
Copy link
Contributor

All linux builds on all CIs are stalling out still. :(

@henryiii henryiii closed this Dec 30, 2020
@henryiii henryiii reopened this Dec 30, 2020
@Czaki
Copy link
Contributor Author

Czaki commented Dec 31, 2020

The bug comes from @YannickJadoul patch.

patch -N -d /opt/python/pp27-pypy_73 -i /pypy_venv.patch 
can't find file to patch at input line 3
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|--- a/lib-python/2.7/sysconfig.py
|+++ b/lib-python/2.7/sysconfig.py
--------------------------
File to patch: 
Skip this patch? [y] n 
File to patch: 

Pure call CLI

patch -N -d /opt/python/pp27-pypy_73 /pypy_venv.patch

Block execution waiting on stdinput.

So this is the problem why I split the patch into two files.

It looks like macOS patch works differently than Linux one. Did we revert @YannickJadoul changes?

@Czaki
Copy link
Contributor Author

Czaki commented Dec 31, 2020

I have hope that I fix it. I suggest keeping pytest-timeout for better debug.

@YannickJadoul
Copy link
Member

YannickJadoul commented Dec 31, 2020

This is weird. I tried this out, and things passed. What has changed meanwhile?

EDIT: Aha, seems they also timed out; I saw macOS passing and I didn't see Linux failing, so I thought it was OK...

patch_docker_path = PurePath('/pypy_venv.patch')
docker.copy_into(patch_path, patch_docker_path)
try:
docker.call(['patch', '-N', '-p1', '-d', config.path, '-i', patch_docker_path])
Copy link
Member

Choose a reason for hiding this comment

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

Why -N, why -i?

-N --forward Ignore patches that appear to be reversed or already applied.

I don't see the point of this? We know our patches should apply forward?

-i PATCHFILE --input=PATCHFILE Read patch from PATCHFILE instead of stdin.

This was also not the issue in what you showed. The issue seems to have been the leading a/b?

Better apply one of these, then?

-t --batch Ask no questions; skip bad-Prereq patches; assume reversed.
-f --force Like -t, but ignore bad-Prereq patches, and assume unreversed.

Copy link
Contributor

Choose a reason for hiding this comment

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

The leading a/b character should be fixed by -p1. The -i (or --input) is correct, we want to specify an input patch, even if it works without it. I think --force is probably what you want here, though, since you never want it to ask questions, which I think -N still could do if it's not one of {unpatched, already patched}.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
docker.call(['patch', '-N', '-p1', '-d', config.path, '-i', patch_docker_path])
docker.call(['patch', '--force', '-p1', '-d', config.path, '--input', patch_docker_path])

Perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

-i is needed to specify the patch file. Patch on Linux assumes that the first file is one to patch.

I see no difference in behavior between -N and --force. We have properly formated patch files.

@YannickJadoul
Copy link
Member

I suggest keeping pytest-timeout for better debug.

That's going to be annoying for the occasional slow test? Why not just add it when debugging?

@henryiii
Copy link
Contributor

That's going to be annoying for the occasional slow test? Why not just add it when debugging?

If a test suddenly takes 3x longer, isn't that a bug? As long as the timeout isn't too short so that it triggers on reasonable runs, there's no reason we need to wait 1-6 hours (depending on the CI) to fail?

@YannickJadoul
Copy link
Member

If a test suddenly takes 3x longer, isn't that a bug? As long as the timeout isn't too short so that it triggers on reasonable runs, there's no reason we need to wait 1-6 hours (depending on the CI) to fail?

Probably. I was just thinking that we now already get the occasional spurious CI failure (just restarted a Travis job), so... myeah

@Czaki
Copy link
Contributor Author

Czaki commented Dec 31, 2020

The main difference is that job killed by CI timeout does not provide any information. We do not know in which phase it stuck. Maybe timeout should be increased, but for me, it is better to get a job killed by pytest-timeout than CI timeout. I got more information.

@YannickJadoul
Copy link
Member

The main difference is that job killed by CI timeout does not provide any information. We do not know in which phase it stuck. Maybe timeout should be increased, but for me, it is better to get a job killed by pytest-timeout than CI timeout. I got more information.

That's true, that's why I suggested to keep it as way of debugging. But fair enough, if the timeout is long enough, it can stay as well

@joerick
Copy link
Contributor

joerick commented Dec 31, 2020

I'm happy with keeping the timeout. I'm not particularly familiar with patch, but --force seems more appropriate in our situation? Other than that this looks good 👍

@henryiii henryiii merged commit 99203a8 into pypa:master Dec 31, 2020
@Czaki Czaki deleted the pypy_patch_venv branch December 31, 2020 16:55
@YannickJadoul YannickJadoul mentioned this pull request Jan 1, 2021
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.

5 participants