Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-99948: Support ctypes.util.find_library in emscripten environment #138519

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
ryanking13 wants to merge 3 commits into python:main
base: main
Choose a base branch
Loading
from ryanking13:ctypes-emscripten

Conversation

Copy link
Contributor

@ryanking13 ryanking13 commented Sep 5, 2025
edited by bedevere-app bot
Loading

This PR adds ctypes.util.find_library support in Emscripten environment. I am resubmitting the patch that was closed around 3 years ago (#99950).

The previous pull request was closed at that time, as CPython did not have an official Emscripten build. But now it is back to tier-3 with buildbot support, so I think it makes sense to support this in CPython Emscripten builds.

Pyodide is applying this patch to support packages that rely on ctypes.util.find_library to locate packages.

Copy link
Contributor Author

!buildbot emscripten

Copy link

You don't have write permissions to trigger a build

ryanking13 reacted with eyes emoji

Copy link
Contributor

hoodmane commented Sep 5, 2025

!buildbot emscripten

Copy link

🤖 New build scheduled with the buildbot fleet by @hoodmane for commit 857b0fa 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F138519%2Fmerge

The command will test the builders whose names match following regular expression: emscripten

The builders matched are:

  • WASM Emscripten PR

Copy link
Contributor

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

A couple of comments/suggestions about the implementation and testing strategy.

I'd also like @hoodmane to confirm the emscripten details on this; this all makes sense assuming LD_LIBRARY_PATH exits in the environment - but my understanding was the there were very limited opportunities to actually manipulate environment variables in a runtime environment.

It's entirely possible I'm missing something here - and the fact this patch comes from Pyodide suggests I might be - I just want to make sure I understand the full context here, and this isn't encoding as Pyodide-ism that won't necessarily apply elsewhere.

Comment on lines +190 to +194
if os.path.isfile(libfile):
if not _is_wasm(libfile):
continue

return libfile
Copy link
Contributor

@freakboy3742 freakboy3742 Sep 8, 2025

Choose a reason for hiding this comment

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

This seems overly complicated; suggest:

Suggested change
if os.path.isfile(libfile):
if not _is_wasm(libfile):
continue
return libfile
if os.path.isfile(libfile) and _is_wasm(libfile):
return libfile

@unittest.skipUnless(test.support.is_emscripten,
'Test only valid for Emscripten')
class FindLibraryEmscripten(unittest.TestCase):
def test_find_on_libpath(self):
Copy link
Contributor

@freakboy3742 freakboy3742 Sep 8, 2025

Choose a reason for hiding this comment

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

There's a few cases missing from this test suite, including:

  • Ignoring non-WASM files
  • Finding a libdummy.wasm file
  • Finding nothing if LD_LIBRARY_PATH isn't defined
  • Finding nothing if LD_LIBRARY_PATH is defined, but doesn't include a WASM file.

It might be worth setting up a directory that contains libdummy.so and libother.wasm as a class-based startup fixture, and then adding tests that manipulate LD_LIBRARY_PATH to find (or not find) those two files.

Copy link

bedevere-app bot commented Sep 8, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@freakboy3742 freakboy3742 freakboy3742 requested changes

@hoodmane hoodmane Awaiting requested review from hoodmane

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /