Skip to content
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

pyodide xbuildenv search --json option #26

Closed
agriyakhetarpal opened this issue Sep 10, 2024 · 3 comments · Fixed by #28
Closed

pyodide xbuildenv search --json option #26

agriyakhetarpal opened this issue Sep 10, 2024 · 3 comments · Fixed by #28
Assignees

Comments

@agriyakhetarpal
Copy link
Member

Description

The pyodide xbuildenv search command currently prints out a formatted table of values:

❯ pyodide xbuildenv search

currently returns

Starting new HTTPS connection (1): raw.githubusercontent.com:443
https://raw.githubusercontent.com:443 "GET /pyodide/pyodide/main/pyodide-cross-build-environments.json HTTP/11" 200 917
Version         Python          Emscripten      pyodide-build                   Compatible
----------      ----------      ----------      -------------------------       ----------
0.27.0a2        3.12.1          3.1.58          0.26.0 -                        Yes       
0.26.2          3.12.1          3.1.58          0.26.0 -                        Yes       
0.26.1          3.12.1          3.1.58          0.26.0 -                        Yes       
0.26.0          3.12.1          3.1.58          0.26.0 -                        Yes    

(Side note: is the pyodide-build version wrong? It's returning 0.26.0 - for all the versions, and not the latest pyodide-build version at the time of writing – which is version 0.28.0?)

It would be great to get the same output in JSON – for example, something like

{
  "environments": [
    {
      "version": "0.27.0a2",
      "python": "3.12.1",
      "emscripten": "3.1.58",
      "pyodide_build": "0.26.0",
      "compatible": true
    },
    {
      "version": "0.26.2",
      "python": "3.12.1",
      "emscripten": "3.1.58",
      "pyodide_build": "0.26.0",
      "compatible": true
    },
    {
      "version": "0.26.1",
      "python": "3.12.1",
      "emscripten": "3.1.58",
      "pyodide_build": "0.26.0",
      "compatible": true
    },
    {
      "version": "0.26.0",
      "python": "3.12.1",
      "emscripten": "3.1.58",
      "pyodide_build": "0.26.0",
      "compatible": true
    }
  ]
}

Motivation

A JSON-based output would be machine-readable and serialisable into a Python script at runtime. This might be useful for cibuildwheel, where currently it is assumed that the Pyodide version and the pyodide-build version go hand-in-hand (it has to be updated since the unvendoring, which I'm working on).

@agriyakhetarpal
Copy link
Member Author

agriyakhetarpal commented Sep 10, 2024

Another thing I noticed is that https://raw.githubusercontent.com/pyodide/pyodide/main/pyodide-cross-build-environments.json notes the existence of a "min_pyodide_build_version" key, which is where we check for compatibility of the Pyodide version with the pyodide-build version.

However, pyodide xbuildenv search for any given pyodide-build installation (whether that is for v0.28.0 or any upcoming versions) will print just the compatible Pyodide versions anyway and not the incompatible ones, so that column in the table seems redundant – unless I am missing something here?

Edit: just noticed that we have an --all sub-option, too, which is the one that returns incompatible versions.

@agriyakhetarpal
Copy link
Member Author

We already have the structure for this feature in place, so this should be doable. I'll take a look at it.

@ryanking13
Copy link
Member

Sounds good. Thanks for working on this!

agriyakhetarpal added a commit that referenced this issue Sep 18, 2024
…ut (#28)

## Description

This PR closes #26. It adds a `pyodide xbuildenv search --json` option
to print a JSON-based output, along with associated tests. The advantage
is that it can be saved to a file, piped to `jq` or shell functions (or
any equivalent tools), or simply imported into a Pythonic interface.

Additionally, I added a small context manager that does not do anything
but stop printing the following lines:
```
Starting new HTTPS connection (1): raw.githubusercontent.com:443
https://raw.githubusercontent.com:443 "GET /pyodide/pyodide/main/pyodide-cross-build-environments.json HTTP/11" 200 917
```

in the output, because it conflicts with receiving valid JSON. Please
let me know if this would be undesirable. If yes, I'll try to work
around it so that it gets printed for the non-JSON output (table).
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 a pull request may close this issue.

2 participants