Skip to content
This repository was archived by the owner on May 30, 2020. It is now read-only.

Commit 3e1ce8f

Browse files
Carreaumpacer
authored andcommitted
Implement pep 503 data-requires for simple repository.
end This exposes the data-requires-python field when the packages registers it.
1 parent 984f26b commit 3e1ce8f

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

store.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -718,15 +718,18 @@ def get_package_urls(self, name, relative=None):
718718
file_urls = []
719719

720720
# uploaded files
721-
safe_execute(cursor, '''select filename, python_version, md5_digest
722-
from release_files where name=%s''', (name,))
723-
for fname, pyversion, md5 in cursor.fetchall():
721+
safe_execute(cursor,
722+
'''
723+
SELECT filename, requires_python, md5_digest
724+
FROM release_files
725+
WHERE release_files.name=%s
726+
''', (name,))
727+
for fname, requires_python, md5 in cursor.fetchall():
724728
# Put files first, to have setuptools consider
725729
# them before going to other sites
726-
url = self.gen_file_url(pyversion, name, fname, relative) + \
730+
url = self.gen_file_url('<not used arg>', name, fname, relative) + \
727731
"#md5=" + md5
728-
file_urls.append((url, "internal", fname))
729-
732+
file_urls.append((url, "internal", fname, requires_python))
730733
return sorted(file_urls)
731734

732735
def get_uploaded_file_urls(self, name):

webui.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ def simple_body(self, path):
10421042
html.append("""<html><head><title>Links for %s</title><meta name="api-version" value="2" /></head>"""
10431043
% cgi.escape(path))
10441044
html.append("<body><h1>Links for %s</h1>" % cgi.escape(path))
1045-
for href, rel, text in urls:
1045+
for href, rel, text, requires_python in urls:
10461046
if href.startswith('http://cheeseshop.python.org/pypi') or \
10471047
href.startswith('http://pypi.python.org/pypi') or \
10481048
href.startswith('http://www.python.org/pypi'):
@@ -1054,7 +1054,10 @@ def simple_body(self, path):
10541054
rel = ''
10551055
href = cgi.escape(href, quote=True)
10561056
text = cgi.escape(text)
1057-
html.append("""<a href="%s"%s>%s</a><br/>\n""" % (href, rel, text))
1057+
data_attr = ''
1058+
if requires_python:
1059+
data_attr = ' data-requires-python="{}"'.format(cgi.escape(requires_python))
1060+
html.append('<a%s href="%s"%s>%s</a><br/>\n' % (data_attr, href, rel, text))
10581061
html.append("</body></html>")
10591062
html = ''.join(html)
10601063
return html

0 commit comments

Comments
 (0)