From fa03a2189895b4491fc27ecad47e3dc5924814fe Mon Sep 17 00:00:00 2001
From: Paul Belanger <pabelanger@redhat.com>
Date: Wed, 27 Jul 2016 15:28:28 +0000
Subject: [PATCH] Revert "Revert "Work around bandersnatch not supporting
 pep503""

It looks like this is breaking tox jobs on ubuntu-precise, which is used by openstack-infra. We are reverting until we can better debug the issues.

This reverts commit 10b0305fe275f4225eb635f0e71128ed5cd22950.

Change-Id: I1f64e8e83ed08fd358ccf5fcd2fffdbe9215966a
---
 .../templates/mirror.vhost.erb                | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/modules/openstack_project/templates/mirror.vhost.erb b/modules/openstack_project/templates/mirror.vhost.erb
index 9e7452e21f..9cbed20d33 100644
--- a/modules/openstack_project/templates/mirror.vhost.erb
+++ b/modules/openstack_project/templates/mirror.vhost.erb
@@ -51,6 +51,26 @@ NameVirtualHost <%= @vhost_name %>:<%= @port %>
     RewriteCond %{DOCUMENT_ROOT}/npm/$1/$1$2 -d
     RewriteRule ^/npm/([^/])([^/]*)(/.*)?$ /npm/$1/$1$2$3 [L]
 
+    # TODO(jhesketh): Remove this after bandersnatch implements pep503
+    # https://bitbucket.org/pypa/bandersnatch/pull-requests/20/fully-implement-pep-503-normalization/diff
+
+    # Special cases for openstack.nose_plugin & backports.*
+    RewriteRule ^(.*)/openstack-nose-plugin(.*)$ $1/openstack.nose_plugin$2
+    RewriteRule ^(.*)/backports-(.*)$ $1/backports.$2
+
+    RewriteCond %{REQUEST_URI} ^/pypi/simple/([^/])([^/]*)
+    RewriteCond %{DOCUMENT_ROOT}/pypi/simple/$1/$1$2 -d
+    RewriteRule ^/pypi/simple/([^/])([^/]*)(/.*)?$ /pypi/simple/$1/$1$2$3 [L]
+
+    # Try again but replacing -'s with .'s
+    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
+    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
+    RewriteRule (.*)-(.*) $1.$2 [N]
+
+    RewriteCond %{REQUEST_URI} ^/pypi/simple/([^/])([^/]*)
+    RewriteCond %{DOCUMENT_ROOT}/pypi/simple/$1/$1$2 -d
+    RewriteRule ^/pypi/simple/([^/])([^/]*)(/.*)?$ /pypi/simple/$1/$1$2$3 [L]
+
     <DirectoryMatch "<%= @docroot %>\/npm\/[^/]+\/.*">
       DirectoryIndex index.json
       AddOutputFilterByType SUBSTITUTE application/json