Skip to content

Conversation

evnchn
Copy link
Collaborator

@evnchn evnchn commented Sep 22, 2025

Motivation

As mentioned in zauberzeug/rosys#301 (comment), NiceGUI does not work under PyPy normally. I discovered the reason (at least one of it) being orjson, as "orjson does not and will not support PyPy" (https://github.com/ijl/orjson/blob/aa8c946cfbe2aba29016bc9c9ddc8713cb00173b/README.md?plain=1#L35)

It would be a pity if we can't use NiceGUI under PyPy since its garbage collector does not "stop the world" unlike CPython's, an awesome use case for the robots which RoSys may empower

Implementation

Add platform_python_implementation != 'PyPy' to the markers of orjson marking it out of 32-bit systems, such that if it is PyPy orjson will not be installed.

This is inspired from https://github.com/pyca/cryptography/blob/cac6426aafd989e4d8d9c4f6b920a332a5280bba/pyproject.toml#L8

Progress

  • I chose a meaningful title that completes the sentence: "If applied, this PR will..."
  • The implementation is complete.
  • Pytests have been are not necessary.
    • Original Pytests already handle missing orjson. Check
      try:
      # try to import module, only run test if succeeded
      import orjson # noqa: F401
      except ImportError:
      pass
      @pytest.mark.skipif('orjson' not in sys.modules, reason='requires the orjson library.')
  • Documentation is not necessary.
    • But do make it very clear that this is BETA or even ALPHA level support...

@evnchn
Copy link
Collaborator Author

evnchn commented Sep 22, 2025

It works. I tried it in the devcontainer.

@evnchn
Copy link
Collaborator Author

evnchn commented Sep 22, 2025

Feel like we should YOLO and merge this.

Originally:

  • Works for CPython.
  • Does NOT work for PyPy whatsover.

Now:

  • Still works for CPython, platform_python_implementation != 'PyPy' is true after all.
  • If it doesn't work for PyPy, we're not regressing; But if it does then great!

Tests pass, by the way (https://github.com/evnchn/nicegui/actions/runs/17919770924). Please ignore 3.9-3.12 results on my branch since their cache's messed up.

@evnchn evnchn mentioned this pull request Sep 22, 2025
4 tasks
@evnchn
Copy link
Collaborator Author

evnchn commented Sep 23, 2025

#5163 is better.

@evnchn evnchn marked this pull request as draft September 23, 2025 11:46
@evnchn
Copy link
Collaborator Author

evnchn commented Oct 9, 2025

I'm not up to resolving merge conflict for a partial PR...

@evnchn evnchn closed this Oct 9, 2025
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.

1 participant