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

Accelerate locking by fetching hash from url fragment #4500

Merged
merged 12 commits into from
Oct 28, 2020
Prev Previous commit
Next Next commit
Supply sha256 checksum to mocked PyPI
  • Loading branch information
frostming committed Oct 28, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 98fbe2fc5ae67430ff6879b2968cbeae29146fbc
2 changes: 1 addition & 1 deletion tests/pypi
Submodule pypi updated 276 files
8 changes: 6 additions & 2 deletions tests/pytest-pypi/pytest_pypi/app.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
from flask import Flask, redirect, abort, render_template, send_file, jsonify


ReleaseTuple = collections.namedtuple("ReleaseTuple", ["path", "requires_python"])
ReleaseTuple = collections.namedtuple("ReleaseTuple", ["path", "requires_python", "hash"])

app = Flask(__name__)
session = requests.Session()
@@ -86,13 +86,17 @@ def add_release(self, path_to_binary):
path_to_binary = os.path.abspath(path_to_binary)
path, release = os.path.split(path_to_binary)
requires_python = ""
hash_value = ""
if path_to_binary.endswith(".whl"):
pkg = distlib.wheel.Wheel(path_to_binary)
md_dict = pkg.metadata.todict()
requires_python = md_dict.get("requires_python", "")
if requires_python.count(".") > 1:
requires_python, _, _ = requires_python.rpartition(".")
self.releases[release] = ReleaseTuple(path_to_binary, requires_python)
if os.path.isfile(path_to_binary + ".sha256"):
with open(path_to_binary + ".sha256") as f:
hash_value = f.read().strip()
self.releases[release] = ReleaseTuple(path_to_binary, requires_python, hash_value)
self._package_dirs.add(ReleaseTuple(path, requires_python))


2 changes: 1 addition & 1 deletion tests/pytest-pypi/pytest_pypi/templates/package.html
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
<body>
<h1>Links for {{ package.name }}</h1>
{% for release, value in package.releases.items() %}
<a href="/{{ package.name }}/{{ release }}"{%- if value.requires_python %} data-requires-python="{{ value.requires_python }}"{% endif %}>{{ release }}</a>
<a href="/{{ package.name }}/{{ release }}{%- if value.hash %}#sha256={{ value.hash }}{% endif %}"{%- if value.requires_python %} data-requires-python="{{ value.requires_python }}"{% endif %}>{{ release }}</a>
<br>
{% endfor %}
</body>