From 86b25a4dde28f4e27a2a1a22974c3ffb11c44a90 Mon Sep 17 00:00:00 2001 From: Kevin Richardson Date: Sat, 19 May 2018 13:47:20 -0400 Subject: [PATCH 1/2] Include '--index-url' argument for the pip install command for Test PyPI The template logic for a package's pip installation command has been moved to a jinja macro called `pip_command`. This macro furthermore determines whether or not to add the Test PyPI's `--index-url` based on the existence of the *testPyPI* variable. --- warehouse/templates/packaging/detail.html | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/warehouse/templates/packaging/detail.html b/warehouse/templates/packaging/detail.html index 26754d72cbe0..2ac9639dbe26 100644 --- a/warehouse/templates/packaging/detail.html +++ b/warehouse/templates/packaging/detail.html @@ -64,6 +64,19 @@

{%- endmacro %} + +{%- macro pip_command(release, request_route, test_environment) -%} + {%- if test_environment -%} + {% set index_url = " --index-url https://test.pypi.org/simple/" %} + {%- endif -%} + + {%- if request_route == "packaging.release" -%} + {% set project_version = "==" + release.version %} + {%- endif -%} + + pip install{{ index_url }} {{ release.project.name }}{{ project_version }} +{%- endmacro -%} + {% block title %}{{ release.project.name }}{% endblock %} {% block description %}{{ release.summary }}{% endblock %} @@ -79,13 +92,8 @@

{% if files %} - {% if request.matched_route.name == "packaging.release" %} - {% set pip_command = "pip install {release.project.name}=={release.version}".format(release=release) %} - {% else %} - {% set pip_command = "pip install {release.project.name}".format(release=release) %} - {% endif %}

- {{ pip_command }} + {{ pip_command(release, request.matched_route.name, testPyPI) }}