-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix detection of dependencies where key and name differ #36
Conversation
I just learned that there appears to be one exception to how this all works, and that is
This is listed as a dependency with the name
After seeing this, I thought that maybe the module name (listed in |
It looks like package names should be handled in a case-insensitive manner, so I implemented that and it solves the jinja2/Jinja2 issue. |
Regarding posit-dev/py-shiny-site#186, this reduces the necessary code to the following: app.py from shiny.express import input, ui
from shinywidgets import render_altair
ui.input_selectize("var", "Select variable", choices=["bill_length_mm", "body_mass_g"])
@render_altair
def hist():
import altair as alt
from palmerpenguins import load_penguins
df = load_penguins()
return (
alt.Chart(df)
.mark_bar()
.encode(x=alt.X(f"{input.var()}:Q", bin=True), y="count()")
) requirements.txt
No more soft_dependencies.py, and most packages are removed from requirements.txt. If you run the following, and then visit the app, it works:
|
Note that we should have tests of dependency detection. |
if name not in _dep_name_to_dep_key_mappings(): | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this maybe throw a warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nvm, now I see the warning above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be fairly common to not have a package in the pyodide_lock.json file. In that case, micropip will go out and try to install it from PyPI.
This should fix posit-dev/py-shiny-site#186.
For some packages, the entry in pyodide-lock.json has a key like
jsonschema-specifications
, but in that entry, the valuename
field isjsonschema_specifications
. (And further note that these can differ from the module name, which is listed inimports
). As far as I can tell, there are no fixed rules for how these names relate.Here are some entries in pyodide-lock.json where these things are not consistent (I've removed extraneous information from these entries to make it easy to see the inconsistencies):
We already handled the differing module name before. This PR adds support for differences between the key and the name.