Repository: pypa/pip

Issue:
'utf8' encoding not found
* Pip version: 9.0.0
* Python version: 2.7.12
* Operating System: Ubuntu 16.04.1 LTS xenial

### Description:

I tried to run Django makemessages with the latest version of pip and it gives me the following error
./lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.py:1: Unknown encoding "utf8". Proceeding with ASCII instead.


```
xgettext: ./lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.py:1: Unknown encoding "utf8". Proceeding with ASCII instead.
xgettext: Non-ASCII string at ./lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.py:64.
          Please specify the source encoding through --from-code or through a comment
          as specified in http://www.python.org/peps/pep-0263.html.
```



Discussion:
This appears to be a bug with https://github.com/gsnedders/python-webencodings.

Thanks, I opened an issue in there.
https://github.com/gsnedders/python-webencodings/issues/8

It seems like the problem is that `xgettext` does not assume `utf8` is an alias for `utf-8`.

@AurangZ, have you tried doing what the error message suggests? Specifically, passing `xgettext` a `--from-code=UTF-8` flag.

@di Thanks for your response.
xgettext is getting called inside django's `manage.py makemessages` command. I don't see how I can pass parameters to xgettext.

@AurangZ It seems like https://pypi.python.org/pypi/django-makemessages-xgettext might help you.

Thanks @di. I'll see how I can use the new makemessage package.

I don't have this issue with pip 8.1.2. Is there something changed related to xgettext?

@AurangZ The reason is because `pip` did not vendor `python-webencodings` before 9.0.0.

I see. Thanks @di.

I guess the ultimate fix is to fix this in webencoding and import the fix into the pip. Should we close this ticket? or keep it open until the new changes from webencoding is merged? I'll let you decide.

If django-makemessage-xgettext was successful I report back here on this ticket. 
Because I am very close to a deadline, for now I am going to keep using 8.1.2 though.

@AurangZ Sorry for the late reply. I made https://github.com/gsnedders/python-webencodings/pull/9 to fix this in `python-webencodings`, let's leave this issue open until that PR is merged, released, and vendored into pip.

Thanks @di
This appears to have been merged, and is now just waiting on a release.

Resolving patch:
diff --git a/pip/_vendor/webencodings/__init__.py b/pip/_vendor/webencodings/__init__.py
--- a/pip/_vendor/webencodings/__init__.py
+++ b/pip/_vendor/webencodings/__init__.py
@@ -1,4 +1,4 @@
-# coding: utf8
+# coding: utf-8
 """
 
     webencodings
@@ -19,7 +19,7 @@
 from .labels import LABELS
 
 
-VERSION = '0.5'
+VERSION = '0.5.1'
 
 
 # Some names in Encoding are not valid Python aliases. Remap these.
diff --git a/pip/_vendor/webencodings/x_user_defined.py b/pip/_vendor/webencodings/x_user_defined.py
--- a/pip/_vendor/webencodings/x_user_defined.py
+++ b/pip/_vendor/webencodings/x_user_defined.py
@@ -1,4 +1,4 @@
-# coding: utf8
+# coding: utf-8
 """
 
     webencodings.x_user_defined


Test patch:
diff --git a/pip/_vendor/webencodings/tests.py b/pip/_vendor/webencodings/tests.py
--- a/pip/_vendor/webencodings/tests.py
+++ b/pip/_vendor/webencodings/tests.py
@@ -1,4 +1,4 @@
-# coding: utf8
+# coding: utf-8
 """
 
     webencodings.tests