我正在尝试基于 these instructions 设置一个简单的 Python 存储库.
我已经创建了所需的目录结构,但是 pip
找不到任何版本。深入研究该主题并引用 PEP 503 - Simple Repository API 后我发现自动生成的HTML站点的结构应该是:
<!DOCTYPE html>
<html>
<body>
<a href="/frob/">frob</a>
<a href="/spamspamspam/">spamspamspam</a>
</body>
</html>
同一政治公众人物还说:
The text of the anchor tag MUST be the normalized name of the project and the href attribute MUST link to the URL for that particular project.
就我而言,它看起来像这样:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Index of /</title>
</head>
<body>
<h1>Index of /</h1>
<ul><li><a href="packet_name/"> packet_name/</a></li>
</ul>
</body></html>
注意 <a>
开头的空格和结尾的斜杠标签。这是
<a href="packet_name/"> packet_name/</a>
但应该是
<a href="packet_name/">packet_name</a>
.htaccess 文件当前如下所示:
Options +Indexes
IndexOptions SuppressColumnSorting -FancyIndexing
IndexIgnore ..
有没有办法指示 Apache 按照 PEP 503 的要求提供目录布局?
最佳答案
事实证明,问题不是链接的格式,而是规范化的文件夹结构。 PEP 503 期望根级别的文件夹能够标准化。将该项目的名称视为 foo_bar
。那么,目录布局必须是:
.
|- foo-bar
|-- foo_bar-0.1.tar.gz
请注意,通过用单个 -
替换 .、- 或 _
字符,该文件夹已“标准化”。之后 .htaccess
文件和自动生成的索引就可以正常工作了。
这是 PEP 503 的相关部分:
is PEP references the concept of a "normalized" project name. As per PEP 426 the only valid characters in a name are the ASCII alphabet, ASCII numbers, ., -, and _. The name should be lowercased with all runs of the characters ., -, or _ replaced with a single - character. This can be implemented in Python with the re module:
关于python - Apache AutoIndex 和 Python PEP 503,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55091949/