holoviz / panel

Panel: The powerful data exploration & web app framework for Python

Home Page:https://panel.holoviz.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pyodide Conversion: requirements.txt not able to deal with wheel-urls

flxmr opened this issue · comments

ALL software version info

panel@900fb095b4dfe7c3500321ba7fe84f188b08721a on Python 3.12.2

Description of expected behavior and the observed behavior

I would like to specify a custom url for a wheel in pyiodide conversion. In standard Python I can just put the url in the requirements.txt. As panel uses packaging.requirements.Requirement this doesn't work, because the URL is not a valid requirement. This would not be bad if one could use package @ wheelurl. However this fails, because panel passes this as a string to micropip, which doesn't understand this spec and tries to get http://localhost:8000/mywheel@https://localhost:8000/myhweel.whl.

According to micropip one should https://micropip.pyodide.org/en/stable/project/api.html#micropip.install only pass package names, http or emfs-urls.

Complete, minimal, self-contained example code that reproduces the issue

panel convert mypanel.py --compiled --to pyodide-worker --out pyodide-excel --requirements reqs.txt

where reqs.txt looks like

http://localhost:8000/mywheel.whl

results in:

Failed to convert mypanel.py to pyodide target: Requirements parser raised following error: Expected end or semicolon (after name and no valid version specifier)
    https://localhost:8000/mywheel.whl
  • [x ] I may be interested in making a pull request to address this. Likely I will try to convert the Requirements to package specifications accepted by micropip

also:
#6170 (fix the requirements-heuristic)
#5700 (and this bug somewhere)

As pyodide does only provide one set of emscripten-wheels for every version (...) it doesn't make a lot of sense to use formal Requirements at all I would say. Also the "requirements"-files as read by pip don't have to have a Requirement in every line. This is funny and despite the polish shown by the various "you can run Python in the browser"-projects, this seems very toy-like. (also pip is the only implementation of a proper dependency resolver - and that without an API)