Repository: conda/conda-build

Issue:
conda skeleton crashes on Ubuntu 14.04
Skeleton fails when searching pypi repositories.

> conda skeleton pypi wikipedia

Stack trace:
Traceback (most recent call last):
  File "/home/qq/Applications/anaconda/bin/conda-skeleton", line 5, in <module>
    sys.exit(main())
  File "/home/qq/Applications/anaconda/lib/python2.7/site-packages/conda_build/main_skeleton.py", line 300, in main
    args_func(args, p)
  File "/home/qq/Applications/anaconda/lib/python2.7/site-packages/conda_build/main_build.py", line 389, in args_func
    args.func(args, p)
  File "/home/qq/Applications/anaconda/lib/python2.7/site-packages/conda_build/main_skeleton.py", line 315, in execute
    pypi.main(args, parser)
  File "/home/qq/Applications/anaconda/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 "/home/qq/Applications/anaconda/lib/python2.7/xmlrpclib.py", line 1243, in **call**
    return self.__send(self.__name, args)
  File "/home/qq/Applications/anaconda/lib/python2.7/xmlrpclib.py", line 1602, in __request
    verbose=self.__verbose
  File "/home/qq/Applications/anaconda/lib/python2.7/site-packages/conda_build/pypi.py", line 233, in request
    return self.parse_response(resp)
  File "/home/qq/Applications/anaconda/lib/python2.7/site-packages/conda_build/pypi.py", line 242, in parse_response
    return u.close()
  File "/home/qq/Applications/anaconda/lib/python2.7/xmlrpclib.py", line 800, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault -32500: 'application error'>

Current conda install:
             platform : linux-64
        conda version : 4.1.6
    conda-env version : 2.5.1
  conda-build version : 1.21.4
       python version : 2.7.12.final.0
     requests version : 2.9.1
     root environment : /home/qq/Applications/anaconda  (writable)
  default environment : /home/qq/Applications/anaconda
     envs directories : /home/qq/Applications/anaconda/envs
        package cache : /home/qq/Applications/anaconda/pkgs
         channel URLs : 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 : None
         offline mode : False
    is foreign system : False



Discussion:
Thanks for the report. I'll investigate this soon. Nothing obvious jumps out at me from the traceback. I'll try to reproduce, but may need your help. 

Of course, this doesn't happen for me.  Is it a repeatable error, or does it sometimes work?  Do you have any sort of firewall or proxy that may interfere?

I ran into this, but it is intermittent.  This indicates that it is a PyPI error.  Nothing we can do about those, but I'll try to add a nicer error message, at least.


Resolving patch:
diff --git a/conda_build/pypi.py b/conda_build/pypi.py
--- a/conda_build/pypi.py
+++ b/conda_build/pypi.py
@@ -35,9 +35,9 @@
 from conda_build.metadata import MetaData
 
 if sys.version_info < (3,):
-    from xmlrpclib import ServerProxy, Transport, ProtocolError
+    from xmlrpclib import ServerProxy, Transport, ProtocolError, Fault
 else:
-    from xmlrpc.client import ServerProxy, Transport, ProtocolError
+    from xmlrpc.client import ServerProxy, Transport, ProtocolError, Fault
 
 
 PYPI_META = """\
@@ -236,10 +236,15 @@ def parse_response(self, resp):
         """
         Parse the xmlrpc response.
         """
-        p, u = self.getparser()
-        p.feed(resp.text.encode("utf-8"))
-        p.close()
-        return u.close()
+        try:
+            p, u = self.getparser()
+            p.feed(resp.text.encode("utf-8"))
+            p.close()
+            ret = u.close()
+        except Fault:
+            raise RuntimeError("XMLRPC Fault while parsing PyPI response.  "
+                               "This is likely a transient error - please try again soon.")
+        return ret
 
     def _build_url(self, host, handler):
         """


Test patch:
diff --git a/tests/test_published_examples.py b/tests/test_published_examples.py
new file mode 100644
--- /dev/null
+++ b/tests/test_published_examples.py
@@ -0,0 +1,20 @@
+import os
+import subprocess
+
+from conda.compat import TemporaryDirectory
+
+
+def test_skeleton_pypi():
+    """published in docs at http://conda.pydata.org/docs/build_tutorials/pkgs.html"""
+    cwd = os.getcwd()
+    with TemporaryDirectory() as tmp:
+        os.chdir(tmp)
+        try:
+            cmd = 'conda skeleton pypi pyinstrument'
+            subprocess.check_call(cmd.split())
+            cmd = 'conda build pyinstrument'
+            subprocess.check_call(cmd.split())
+        except:
+            raise
+        finally:
+            os.chdir(cwd)