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

Update upstream URL for libjpeg. NFC #13869

Merged
merged 1 commit into from
Apr 12, 2021
Merged

Update upstream URL for libjpeg. NFC #13869

merged 1 commit into from
Apr 12, 2021

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Apr 12, 2021

The old URL seems to be generating Forbidden!.

I wonder if we should start maintaining our own mirror to avoid
this kind of thing.

The old URL seems to be generating `Forbidden!`.

I wonder if we should start maintaining our own mirror to avoid
this kind of thing.
@sbc100 sbc100 requested a review from kripken April 12, 2021 15:15
@sbc100 sbc100 enabled auto-merge (squash) April 12, 2021 15:36
@sbc100
Copy link
Collaborator Author

sbc100 commented Apr 12, 2021

Landing TBR to unblock CI

@sbc100 sbc100 disabled auto-merge April 12, 2021 16:26
@sbc100 sbc100 merged commit 2b49ba5 into main Apr 12, 2021
@sbc100 sbc100 deleted the update_libjpeg_url branch April 12, 2021 16:27
@kripken
Copy link
Member

kripken commented Apr 12, 2021

Yes, if there is no unreliable upstream repo for this, we should create a mirror in emscripten-ports and use that.

@rth
Copy link
Contributor

rth commented Apr 12, 2021

Thanks!

The actual error for this was,

system_libs:INFO: retrieving port: libjpeg from https://dl.bintray.com/homebrew/mirror/jpeg-9c.tar.gz
[...]
urllib.error.HTTPError: HTTP Error 403: Forbidden

in case someone searches for it on Github and is not able to find the relevant issue.

@rth
Copy link
Contributor

rth commented Apr 12, 2021

Are you sure this fixes it though @sbc100 ? I'm still getting the same error with the new URL if requests is not installed (which worked fine previously I think), and I can also reproduce it from a Python REPL directly,

>>> from tools import system_libs
>>> system_libs.Ports().fetch_project('libjpeg', 'https://www.ijg.org/files/jpegsrc.v9c.tar.gz', 'jpeg-9c')
system_libs:INFO: retrieving port: libjpeg from https://www.ijg.org/files/jpegsrc.v9c.tar.gz
Traceback (most recent call last):
  File "/src/emsdk/emsdk/upstream/emscripten/tools/system_libs.py", line 1707, in retrieve
    import requests
ModuleNotFoundError: No module named 'requests'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/src/emsdk/emsdk/upstream/emscripten/tools/system_libs.py", line 1756, in fetch_project
    retrieve()
  File "/src/emsdk/emsdk/upstream/emscripten/tools/system_libs.py", line 1712, in retrieve
    f = urlopen(url)
  File "/usr/local/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/local/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/local/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

If requests is installed this indeed fetches the .tar.gz correctly.

@sbc100
Copy link
Collaborator Author

sbc100 commented Apr 12, 2021

No requests is not needed.

The error here is "urllib.error.HTTPError: HTTP Error 403: Forbidden".

Can you run wget https://www.ijg.org/files/jpegsrc.v9c.tar.gz or curl https://www.ijg.org/files/jpegsrc.v9c.tar.gz or load that URL in your browser?

@rth
Copy link
Contributor

rth commented Apr 12, 2021

All of curl, wget and that URL in the browser work.

The issue seems to be with urllib specifically which is used in fetch_project,

>>> from urllib.request import urlopen
>>> res = urlopen("https://www.ijg.org/files/jpegsrc.v9c.tar.gz")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/local/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/local/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

This happens both in CI and locally so it shouldn't be location dependent.

If a different user-agent is passed in headers, then the download works. So they seem to be blocking the urllib user agent.

@sbc100
Copy link
Collaborator Author

sbc100 commented Apr 12, 2021

How odd... seems like maybe misconfigured webserver?

@sbc100
Copy link
Collaborator Author

sbc100 commented Apr 12, 2021

I'll mirror the archive on google cloud storage

@rth
Copy link
Contributor

rth commented Apr 12, 2021

They probably added it to the deny list for some reason mesonbuild/libjpeg#9 (comment) . Thanks!

sbc100 added a commit that referenced this pull request Apr 12, 2021
It turns out that the www.ijg.org refused requests from the urllib
library for some reason.

This issues was being masked by the fact that system_libs.py prefers to
use `requests` when it is installed.  This change undoes that.  This
feature was originally added in #8667 to deal with older python
installations but these days we supply our own python as part of emsdk
so we should be able to depend on a recent/correct version.  Having the
fallback here just makes testing harder.

Fixes: #13869
sbc100 added a commit that referenced this pull request Apr 12, 2021
It turns out that the www.ijg.org refused requests from the urllib
library for some reason.

This issues was being masked by the fact that system_libs.py prefers to
use `requests` when it is installed.  This change undoes that.  This
feature was originally added in #8667 to deal with older python
installations but these days we supply our own python as part of emsdk
so we should be able to depend on a recent/correct version.  Having the
fallback here just makes testing harder.

Fixes: #13869
sbc100 added a commit that referenced this pull request Apr 13, 2021
It turns out that the www.ijg.org refused requests from the urllib
library for some reason.

This issues was being masked by the fact that system_libs.py prefers to
use `requests` when it is installed.  This change undoes that.  This
feature was originally added in #8667 to deal with older python
installations but these days we supply our own python as part of emsdk
so we should be able to depend on a recent/correct version.  Having the
fallback here just makes testing harder.

Fixes: #13869
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.

None yet

3 participants