Skip to content

Fix import error on aarch64: define 'long' using ctypes.c_long #146

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vsevolod-misiul
Copy link

@vsevolod-misiul vsevolod-misiul commented May 19, 2025

Summary

On Linux ARM64 (aarch64) platforms, installing PyOpenGL_accelerate fails with the following error:

Error compiling Cython file:
...
    self.buffer = long( buffers )
                          ^
src/vbo.pyx:191:26: undeclared name not builtin: long

This happens because the built-in long type is not defined in Python 3 on ARM64 platforms, unlike some legacy Python 2 or x86-based assumptions. This breaks Cython compilation when trying to cast buffer identifiers.

This patch imports long from ctypes.c_long, which resolves the issue on these platforms.

Changes

  • Added from ctypes import c_long as long to handle missing long type on aarch64.

Platform tested

  • Linux on ARM64 (Ubuntu 22.04, aarch64)

cedrik-fuoco-adsk added a commit to AcademySoftwareFoundation/OpenRV that referenced this pull request May 23, 2025
### Fix issue with PyOpenGL-accelerate on MacOS x86_64

### Linked issues
n/a

### Summarize your change.

This PR adds a temporary changes to build PyOpenGL-accelerate from
source on MacOS x86_64. The source is patched with the changes from a
pending [PR](mcfletch/pyopengl#146) in the
PyOpenGL repository.

### Describe the reason for the change.

Cython was updated to version 3.1.0+ on May 8, causing compatibility
issues with PyOpenGL-accelerate on macOS x86_64. Until a pending
[PR](mcfletch/pyopengl#146) is merged in the
official PyOpenGL repository, PyOpenGL-accelerate will be built from
source on macOS x86_64.

### Describe what you have tested and on which operating system.

### Add a list of changes, and note any that might need special
attention during the review.

### If possible, provide screenshots.

Signed-off-by: Cédrik Fuoco <[email protected]>
richardssam pushed a commit to richardssam/OpenRV that referenced this pull request Jun 17, 2025
…undation#777)

### Fix issue with PyOpenGL-accelerate on MacOS x86_64

### Linked issues
n/a

### Summarize your change.

This PR adds a temporary changes to build PyOpenGL-accelerate from
source on MacOS x86_64. The source is patched with the changes from a
pending [PR](mcfletch/pyopengl#146) in the
PyOpenGL repository.

### Describe the reason for the change.

Cython was updated to version 3.1.0+ on May 8, causing compatibility
issues with PyOpenGL-accelerate on macOS x86_64. Until a pending
[PR](mcfletch/pyopengl#146) is merged in the
official PyOpenGL repository, PyOpenGL-accelerate will be built from
source on macOS x86_64.

### Describe what you have tested and on which operating system.

### Add a list of changes, and note any that might need special
attention during the review.

### If possible, provide screenshots.

Signed-off-by: Cédrik Fuoco <[email protected]>
Signed-off-by: [email protected] <[email protected]>
richardssam pushed a commit to richardssam/OpenRV that referenced this pull request Jun 17, 2025
…undation#777)

### Fix issue with PyOpenGL-accelerate on MacOS x86_64

### Linked issues
n/a

### Summarize your change.

This PR adds a temporary changes to build PyOpenGL-accelerate from
source on MacOS x86_64. The source is patched with the changes from a
pending [PR](mcfletch/pyopengl#146) in the
PyOpenGL repository.

### Describe the reason for the change.

Cython was updated to version 3.1.0+ on May 8, causing compatibility
issues with PyOpenGL-accelerate on macOS x86_64. Until a pending
[PR](mcfletch/pyopengl#146) is merged in the
official PyOpenGL repository, PyOpenGL-accelerate will be built from
source on macOS x86_64.

### Describe what you have tested and on which operating system.

### Add a list of changes, and note any that might need special
attention during the review.

### If possible, provide screenshots.

Signed-off-by: Cédrik Fuoco <[email protected]>
Signed-off-by: [email protected] <[email protected]>
@ChrisBarker-NOAA
Copy link

I think this is only an issue with Cython 3 -- but we should be using Cython 3 by now!

Does this seem to work with Cython3 across the board?

NOTE: I'm working on a conda-forge recipe -- so I may apply this as a patch to build .... (though pinning to Cython<3 may be the more expedient route...)

@ChrisBarker-NOAA
Copy link

Got it all working on conda-forge -- but I had to add this patch -- so it would be nice to get this merged.

I do wonder how the wheels got built ????

@vsevolod-misiul
Copy link
Author

I think this is only an issue with Cython 3 -- but we should be using Cython 3 by now!

Does this seem to work with Cython3 across the board?

NOTE: I'm working on a conda-forge recipe -- so I may apply this as a patch to build .... (though pinning to Cython<3 may be the more expedient route...)

Yes, this fix should work across the board with Cython 3. Using ctypes.c_long is the standard way to get a platform-appropriate C long type, so it should be safe on x86_64, and other platforms, preventing similar issues there as well.

@ChrisBarker-NOAA
Copy link

Indeed -- and it is working for me -- with this patch and Cython 3 -- and with Cython <3, I got segfaults.

I think -- numpy 2 changed a bit how it handles the C long types, which might explain the segfaults. I've had other issues with that).

I curse C for defining "short" and "long" way back when, rather than the modern int32 and int64, etc ... oh well.

Anyway, no need to understand all the details -- what I think we need isthis patch and also to pin Cython to >3

Maybe add that pin to this PR?

Also: I see in the MANIFEST.in file that the generated c files are still being included in the source distro -- that probably should change.

@vsevolod-misiul
Copy link
Author

Indeed -- and it is working for me -- with this patch and Cython 3 -- and with Cython <3, I got segfaults.

I think -- numpy 2 changed a bit how it handles the C long types, which might explain the segfaults. I've had other issues with that).

I curse C for defining "short" and "long" way back when, rather than the modern int32 and int64, etc ... oh well.

Anyway, no need to understand all the details -- what I think we need isthis patch and also to pin Cython to >3

Maybe add that pin to this PR?

Also: I see in the MANIFEST.in file that the generated c files are still being included in the source distro -- that probably should change.

As you requested, I've added the version pin to require cython>=3.0.0 in pyproject.toml and just pushed the change. This should ensure robust builds going forward.

@ChrisBarker-NOAA
Copy link

Thanks! now we just need a merge ...

@vsevolod-misiul
Copy link
Author

Thanks! now we just need a merge ...

I've been looking forward to this for a month. 😄

@ChrisBarker-NOAA
Copy link

@mcfletch: This is actually pretty bad -- pip install of accelerate on OS-X Intel fails for this reason.

There is no wheel for OS-X Intel -- so ti tries to build from source.

Also -- I'm curious how the wheels that are there were successfully built, and if they actually work (I could build with Cython < 3, but got segfaults when trying to run the tests).

BTW -- I'm sure there's a couple of us that would be glad to help with maintenance of you don't have the time.

@ChrisBarker-NOAA
Copy link

NOTE:

I've got a build for conda-forge working:

https://anaconda.org/conda-forge/pyopengl-accelerate

But I needed to apply this patch to get it to build -- see:

https://github.com/conda-forge/pyopengl-accelerate-feedstock

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.

2 participants