Skip to content

detail how to deliver both JS and Python assets needed by a project #172

@ntoll

Description

@ntoll
Member

From discord:

https://discord.com/channels/972017612454232116/972020206538997822/1344294149922230364

For example, perhaps the README for my wheel should say:

To use libfoo in pyscript, you will need to declare the following in your pyscript.toml:

packages = ["libfoo@2.0.1"]
[js.modules]
"https://cdn.pyscript.com/serve-files-from-wheels/pypi/libfoo@2.0.1/subpath/shim.js" = "libfooshim"

that's how we basically use 3rd party and there's nothing wrong in there ... .js stuff gotta be published on .js places, .py and wheels stuff gotta be published on .py places ... so you publish your wheel and you publish on npm your wheel module ... you sync versioning between the two, you use one out of dozen CDN providers for your JS that ends up in the config. https://esm.run/ would be my suggestion as it's provided by JSDelivr which is likely the most used CDN out there on the web ... it automatically packages your stuff as ESM too so your config would look like:

packages = ["libfoo@2.0.1"]

[js_modules.main]
"https://esm.run/libfoo@2.0.1" = "libfooshim"

and ... that's it? 🤔

Activity

Neon22

Neon22 commented on Apr 18, 2025

@Neon22
Contributor

Would you mind including in this idea:

  • if using micropython - what is required to import a regular python module that is not already in micropython.
  • A good (IMHO) example is the Configparser module (which reads/writes ini files). This is importable in pyodide but not mpy.
  • However there is a pure python wheel on pypi which is 17kB long
  • What would the procedure be to import this and make it work.

Conversely how does a user discover that a given pure python module will not work,

  • and they would then decide to either do that task in a worker,
  • or move to py instead of mpy
ntoll

ntoll commented on Apr 21, 2025

@ntoll
MemberAuthor

@Neon22 yes, absolutely... this comes up regularly. I'm currently on holiday for a week (boy, do I need a holiday! 😄) but will get to all this on my return. Thanks (as ever) for continuing to prompt all these things. 👍

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ntoll@Neon22

        Issue actions

          detail how to deliver both JS and Python assets needed by a project · Issue #172 · pyscript/docs