-
Notifications
You must be signed in to change notification settings - Fork 760
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
use struct.calcsize("P") rather than platform.machine() #830
Conversation
This should fix the issue described at #779 (comment). |
It would be ideal to have CI test this case for us. Would you guys be open to adding test targets like what I've got in https://github.com/oconnor663/blake3-py/blob/master/.github/workflows/push.yml? |
Thanks very much for this. I would be in favour of having both 32-bit and 64-bit Python in CI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR!
My requests are:
- Now we can remove
machine
. Could you please enable x86 tests for Windows CI?
It would work to add an architecture section to.github/workflows/test.yml
like
strategy:
max-parallel: 4 # Also we should change this line to 8?
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
architecture: [x86, x64] # <- New line
build.rs
Outdated
@@ -33,6 +33,7 @@ struct InterpreterConfig { | |||
base_prefix: String, | |||
executable: String, | |||
machine: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please remove machine
?
I'm going to prepare x86/x64 tests for macOS and Win. |
I enabled x64 + macOS and x86 + Windows tests in #831. |
9f41393
to
7e291ea
Compare
I've tried to add Linux CI testing, but it's failing with this error: /home/runner/work/pyo3/pyo3/target/debug/deps/pyo3-1c9bfe8599f85944: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory Is that a known problem? |
@oconnor663 PYTHON_LIB=$($PYTHON_BINARY -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PYTHON_LIB:$HOME/rust/lib" would solve the problem. But I don't think we need Ubuntu CI on Actions unless it can test something different from what we do on travis. |
Oh that makes sense. I missed the Travis runs. I'll just remove the |
Looks like I'm hitting some |
@oconnor663 I haven't seen this error 🤔 cc: @pganssle The failing test uses |
That's consistent with the admonition here, which I mention in the code comments in this PR:
Let me see if I can switch it over to the same |
Actually I hadn't seen this comment before. It sounds like |
884db67 doesn't seem to have helped. I'm going to keep staring at it. |
It looks like the test failure is only on macOS, and only on Python 3.5 specifically. I don't know what could've changed here between 3.5 and 3.6. (Doesn't seem related to the "fold" field added in 3.6.) |
The exception pathway being hit looks like it exists on python 3.5 but was removed from 3.6. https://github.com/python/cpython/blob/3.5/Modules/_datetimemodule.c#L4936 |
Cool, that's definitely what we're seeing. But I don't know enough about this test to interpret whether we want it to fail here or not. Is it that 3.5 is failing for a dumb obsolete reason, or is it that 3.6-3.8 happen to silently succeed when we wish they would fail? Edit: Similarly, I don't understand why this wasn't failing before. |
I'm going to defer to you all on this one. I'll remove my temporary debugging commits. If you want to see the debugging output (commit 57a03ad), it's visible in this run: https://github.com/PyO3/pyo3/actions/runs/63179251 |
@oconnor663 I think it's better for us to wait for @pganssle, who is the author of our datetime binding. |
Is 32-bit Mac OS still a used platform? Even numpy doesn't have 32-bit Mac OS wheels on pypi (https://pypi.org/project/numpy/#files). If I remember correctly there isn't a wheel tag for 32-bit Mac OS. This is what the blog post of rust demoting apple 32-bit targets:
|
platform.machine() gives the wrong answer if you're running 32-bit Python on a 64-bit machine. The reason we don't use platform.architecture() here is that it's not reliable on macOS. See https://stackoverflow.com/a/1405971/823869. Similarly, sys.maxsize is not reliable on Windows. See https://stackoverflow.com/questions/1405913/how-do-i-determine-if-my-python-shell-is-executing-in-32bit-or-64bit-mode-on-os/1405971#comment6209952_1405971 and https://stackoverflow.com/a/3411134/823869. Also use CARGO_CFG_TARGET_POINTER_WIDTH rather than inferring the Rust target pointer width from CARGO_CFG_TARGET_ARCH.
… tests Same reasoning as the previous commit.
Made the comment change requested above. I want to emphasize that this bug is causing build failures with the current release version, for example https://github.com/oconnor663/blake3-py/runs/534852943. If you guys can think of a way to reduce the scope of this change, so that we can release a fix quickly without the risk of breaking anything, that might be worth doing. |
It's all a bit arcane. I couldn't find anything about this specifically in the cpython changelog. I did find the commit in cpython which reworked the implementation removing this python/cpython@5d0c598#diff-0090febf24974047330d8a02d4dbdc79 Prior to those changes the implementation used That would at least be consistent with the error we're seeing on that CI. So I suggest you mark that test as xfail for macOS on 3.5. |
(Sorry for not being more helpful on this one, I haven't had much free time recently!) |
I just xfailed the tests on macOS, but now something else datetime+3.5 related is failing on Windows?That's odd to me, because everything else passed on this run: https://github.com/PyO3/pyo3/actions/runs/63179251 |
@oconnor663
I'm not strongly against using xfail, but please let me debug this for a while. |
Gotcha, I've removed the commit. |
Note: I put In particular, one of the things we could be missing here (speculation on my part) is flaky test failures. One of the possible causes of flakiness in this environment is a heterogeneous CI fleet. I've seen issues before where e.g. some Windows machines supported AVX-512, and some didn't, and that turned what should've been a deterministic test failure into a flaky one. |
@oconnor663 |
I've added back e44e4ce. |
We need to do this until PyO3/pyo3#830 is resolved.
Thank you! |
platform.machine() gives the wrong answer if you're running 32-bit
Python on a 64-bit machine.
sys.maxsizestruct.calcsize("P") (EDITED based on #830 (comment)) gives the answer we want. Seealso https://stackoverflow.com/a/1405971/823869.
Also use CARGO_CFG_TARGET_POINTER_WIDTH rather than inferring the
pointer width from CARGO_CFG_TARGET_ARCH.