question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What should I do if I want to make a library Brython-compatible?

See original GitHub issue

This is a subset of #491 that is focused specifically on libraries that might want to run on both Brython and CPython without much difference in functionality; things for implementing data structures, file formats, etc.

Writing Python code in the manner that I am accustomed to—particularly to take advantage of the “same language as the backend” feature that Brython offers—would require using tons of libraries that are currently broken on Brython. To get those fixed we’ll need to add continuous integration to tons of projects.

As an open-source library author, if I want to support a different runtime such as PyPy, I usually just drop a new environment into my tox.ini, then run my tests as I did previously, with the same runner.

However, the best practice for doing this on Brython is somewhat unclear - there have been a few interesting blog posts about testing an application using Selenium or whatever, but for libraries like automat https://github.com/glyph/automat/issues/124 that don’t have any UI features but might just be useful utilities within the browser… what’s the first step?

I tried to proof-of-concept this with a custom unittest runner via https://github.com/glyph/brytly/blob/0d7c313830e3fc1ddf71986dec1473df048b6ae4/brytly/phantestic.py / https://github.com/glyph/brytly/blob/0d7c313830e3fc1ddf71986dec1473df048b6ae4/brytly/phantestic.js but this was always a pretty brittle hack and was pretty invasive - it required using this specific test fixture class.

Getting something like pytest to work within brython I would imagine would be a major challenge in its own right, but even if we’re going to stick just to stdlib unittest for the sake of compatibility it seems like forcing users to use an incomplete reimplementation for their base class is going to be a non-starter for most projects.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
PierreQuentelcommented, May 6, 2020

@glyph I’m not sure to understand; unittest is actually supported by Brython. I have developed an interface to run some of the tests in the CPython test suite (at /tests/unittests/index.html), with an adapted version of HTMLTestRunner. It’s not super fast, but shows that a unittest-based test suite developed for a CPython application can be used unmodified in Brython.

0reactions
Frick-Davidcommented, Jun 14, 2020

+1 on question. Hoping to get brython working with plotly.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add Libraries in Kontakt when you get "no library found"
Your browser can 't play this video. Learn more. Switch camera.
Read more >
3 Ways to Build Partnerships at Your Small Library
Lest we forget, libraries have a lot to offer our partners, too; ... If you have limited resources and a small staff, partnerships...
Read more >
7 Reasons Why Businesses Need Python Web Development ...
3. Flexibility ... You can pick up any coding language you will found that It can work with simple integration with python-like,. CPython...
Read more >
Getting Your Book into Libraries - Article - Distribution & Sales
It's full of tips for how a self published author can get a book into a library. ... Some libraries even have a...
Read more >
Six Great Ideas for Library Partnerships
This is a partnership that can have a huge impact on your community at minimal cost to either organization. 2) Nonprofit Partnerships.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found