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

Changed condition for package name to be considered a url to endswith(".whl") #872

Merged
merged 10 commits into from Dec 31, 2020

Conversation

hoodmane
Copy link
Member

@hoodmane hoodmane commented Dec 16, 2020

Resolves #867.
Some minor updates to loading_packages / micropip docs.
Docs are still confusing but I think that's not worth working on too much
until we deal with #870

Some minor updates to loading_packages / micropip docs.
Docs are still confusing but I think that's not worth working on too much
until we resolve pyodide#870
Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hoodmane ! A few comments below

docs/loading_packages.md Outdated Show resolved Hide resolved
docs/loading_packages.md Outdated Show resolved Hide resolved
packages/micropip/micropip/micropip.py Show resolved Hide resolved
packages/micropip/micropip/micropip.py Outdated Show resolved Hide resolved
packages/micropip/micropip/micropip.py Outdated Show resolved Hide resolved
@rth
Copy link
Member

rth commented Dec 17, 2020

Also please add an entry to the docs/changelog.md file with a link to this PR.

Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
@hoodmane
Copy link
Member Author

It would be good to add a test on selenium that actually loads a package from a wheel at a relative url. I wasn't sure how to do this though: I would probably want to take a trivial "hello world" wheel, but I have to get the wheel onto the url somehow. Even for documentation purposes it would be nice to have a test file that loads the same package using each method.

@hoodmane
Copy link
Member Author

Oh I see I can just use a tiny modification of the snowball stemmer test.

@rth
Copy link
Member

rth commented Dec 20, 2020

Please ping me when those tests are added.

@hoodmane
Copy link
Member Author

@rth Okay I added a couple of tests. One just tests add_requirement without selenium and it works, the other does a full test of micropip.install("./snowballstemmer-2.0.0-py2.py3-none-any.whl"). The second one doesn't work, but I've been having trouble debugging it because inside the promise of micropip.install writes to standard out seem to get thrown away. Or something.

I guess I should take this as encouragement to try more monkeypatching to test more than add-requirement. I found that to be surprisingly difficult when I tried it a few days ago.

@hoodmane
Copy link
Member Author

Okay I added another selenium-free test that monkey patches out micropip._get_url. Unfortunately it passes too.

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the failure for test_install_custom_relative_url is to be expected because the relative path is not correct. It is ./snowballstemmer.. when using the web_server_tst_data fixture (that serves files in src/tests/data/. However the selenium_standalone / selenium fixtures serve files in './build' so unless you temporarily copy the wheel there (and make sure it's later deleted including on test failure) that won't work. Since relative paths higher than the root dir for the webserver are disallowed.

I agree those errors are hard to debug, and I think we should try to use pytest-httpserver more (#823). However that won't help here, because we still serve packages for tests with a SimpleHTTPRequestHandler

Edit: once test_install_custom_relative_url passes, I think we can remove test_relative_url_2 (unless you want to spend more time investigating why it fails).

packages/micropip/test_micropip.py Outdated Show resolved Hide resolved
assert req["url"] == "./snowballstemmer-2.0.0-py2.py3-none-any.whl"


def test_relative_url_2():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_relative_url_2():
def test_relative_url():

@rth rth added this to the 0.16.0 milestone Dec 21, 2020
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
@dalcde
Copy link
Contributor

dalcde commented Dec 28, 2020

What is the status of this PR?

@hoodmane
Copy link
Member Author

I think the HTTP request is set up in way that does not handle relative urls correctly. I don't know why, I had a hard time diagnosing it. Maybe if I came back to it now I would have an easier time with it since I'm more familiar with the tools available.

While we're at it, could you weigh in on #870?

@dalcde
Copy link
Contributor

dalcde commented Dec 30, 2020

As rth mentioned, the easiest solution would be to symlink src/tests/data/snow... to build/ at the beginning of the test, and remove it afterwards.

@dalcde
Copy link
Contributor

dalcde commented Dec 31, 2020

In case you missed it I submitted a PR to your branch that fixes the tests

@hoodmane
Copy link
Member Author

Did not notice, thanks.

@dalcde
Copy link
Contributor

dalcde commented Dec 31, 2020

I don't think it matters much in this case but would be good to merge in master too

@hoodmane
Copy link
Member Author

@rth @dalcde I guess this is ready to merge now?

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hoodmane ! LGTM.

Just one last thing, could you please add a changelog entry to 0.17.0 (might need to merge master in to see that section).

@hoodmane
Copy link
Member Author

Isn't it traditional to call the changelog section [unreleased] and only change the name to a specific version number as part of the release process? This is at least the semver recommended approach.

@rth
Copy link
Member

rth commented Dec 31, 2020

Indeed feel free to change it. In general we should probably follow https://keepachangelog.com/en/1.0.0/ better.

@rth rth merged commit ba2d394 into pyodide:master Dec 31, 2020
@hoodmane hoodmane deleted the micropip-relative-uri branch December 31, 2020 18:07
joemarshall pushed a commit to joemarshall/pyodide that referenced this pull request Jan 3, 2021
Co-authored-by: Dexter Chua <dec41@srcf.net>
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 this pull request may close these issues.

Allow Micropip to download from relative urls
3 participants