Repository: conda/conda-build

Issue:
conda skeleton pypi cf-python gives Unicode error u'\u2122' or  u'\xb5'
I didn't want to jump into issue #1089 in case this is an entirely unrelated issue.

I have updated conda with 
conda uopdate conda

and I'm trying to create a new Conda release for cf-python from pypi. The conda skeleton for this package has woked in the past but now I get a Uncode error:

conda skeleton pypi cf-python
Traceback (most recent call last):
  File "/panfs/jasmin/users/andy/anaconda2/bin/conda-skeleton", line 5, in <module>
    sys.exit(main())
  File "/panfs/jasmin/users/andy/anaconda2/lib/python2.7/site-packages/conda_build/main_skeleton.py", line 300, in main
    args_func(args, p)
  File "/panfs/jasmin/users/andy/anaconda2/lib/python2.7/site-packages/conda_build/main_build.py", line 389, in args_func
    args.func(args, p)
  File "/panfs/jasmin/users/andy/anaconda2/lib/python2.7/site-packages/conda_build/main_skeleton.py", line 315, in execute
    pypi.main(args, parser)
  File "/panfs/jasmin/users/andy/anaconda2/lib/python2.7/site-packages/conda_build/pypi.py", line 263, in main
    all_packages = [match["name"] for match in client.search({"name": args.packages}, "or")]
  File "/panfs/jasmin/users/andy/anaconda2/lib/python2.7/xmlrpclib.py", line 1243, in **call**
    return self.__send(self.__name, args)
  File "/panfs/jasmin/users/andy/anaconda2/lib/python2.7/xmlrpclib.py", line 1602, in __request
    verbose=self.__verbose
  File "/panfs/jasmin/users/andy/anaconda2/lib/python2.7/site-packages/conda_build/pypi.py", line 233, in request
    return self.parse_response(resp)
  File "/panfs/jasmin/users/andy/anaconda2/lib/python2.7/site-packages/conda_build/pypi.py", line 240, in parse_response
    p.feed(resp.text)
  File "/panfs/jasmin/users/andy/anaconda2/lib/python2.7/xmlrpclib.py", line 558, in feed
    self._parser.Parse(data, 0)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2122' in position 697992: ordinal not in range(128)

Sometimes the error given is 
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb5' in position 292891: ordinal not in range(128)

conda info gives:
Current conda install:

```
         platform : linux-64
    conda version : 4.1.6
conda-env version : 2.5.1
```

  conda-build version : 1.21.3
       python version : 2.7.12.final.0
     requests version : 2.9.1
     root environment : /panfs/jasmin/users/andy/anaconda2  (writable)
  default environment : /panfs/jasmin/users/andy/anaconda2
     envs directories : /panfs/jasmin/users/andy/anaconda2/envs
        package cache : /panfs/jasmin/users/andy/anaconda2/pkgs
         channel URLs : https://conda.anaconda.org/r/linux-64/
                        https://conda.anaconda.org/r/noarch/
                        https://conda.anaconda.org/ska/linux-64/
                        https://conda.anaconda.org/ska/noarch/
                        https://repo.continuum.io/pkgs/free/linux-64/
                        https://repo.continuum.io/pkgs/free/noarch/
                        https://repo.continuum.io/pkgs/pro/linux-64/
                        https://repo.continuum.io/pkgs/pro/noarch/
          config file : /home/swsheaps/.condarc
         offline mode : False
    is foreign system : False

Have I corrupted something locally or is this a central conda issue?

Thanks
Andy



Discussion:

Resolving patch:
diff --git a/conda_build/pypi.py b/conda_build/pypi.py
--- a/conda_build/pypi.py
+++ b/conda_build/pypi.py
@@ -237,7 +237,7 @@ def parse_response(self, resp):
         Parse the xmlrpc response.
         """
         p, u = self.getparser()
-        p.feed(resp.text)
+        p.feed(resp.text.encode("utf-8"))
         p.close()
         return u.close()
 
@@ -327,9 +327,9 @@ def main(args, parser):
                           package)
                     for ver in versions:
                         print(ver)
-                    print("Using %s" % versions[0])
+                    print("Using %s" % versions[-1])
                     print("Use --version to specify a different version.")
-                d['version'] = versions[0]
+                d['version'] = versions[-1]
 
         data, d['pypiurl'], d['filename'], d['md5'] = get_download_data(args,
                                                                         client,


Test patch: