Skip to content

Commit

Permalink
Include '--index-url' argument for the pip install command for Test P…
Browse files Browse the repository at this point in the history
…yPI (#4941)

* 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.

* Shorten text by using `-i`
  • Loading branch information
yeraydiazdiaz authored and di committed Oct 28, 2018
1 parent 49fba01 commit bc45031
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions warehouse/templates/packaging/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ <h3 class="package-snippet__title">
</a>
{%- endmacro %}


{%- macro pip_command(release, request_route, test_environment) -%}
{%- if test_environment -%}
{% set index_url = " -i 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 %}
Expand All @@ -79,13 +92,8 @@ <h1 class="package-header__name">
</h1>

{% 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 %}
<p class="package-header__pip-instructions">
<span id="pip-command">{{ pip_command }}</span>
<span id="pip-command">{{ pip_command(release, request.matched_route.name, testPyPI) }}</span>
<button class="-js-copy-pip-command tooltipped tooltipped-s" data-clipboard-target="#pip-command" aria-label="Copy to clipboard" data-original-label="Copy to clipboard">
<i class="fa fa-copy" aria-hidden="true"></i>
<span class="sr-only">Copy PIP instructions<span>
Expand Down

0 comments on commit bc45031

Please sign in to comment.