Repository: conda/conda-build

Issue:
skeleton parameter --pypi-url not passed to yaml file
When using the parameter `--pypi-url` with, the server is not passed to the yaml file built by the skeleton script.  

### Python script to replicate the problem (in Windows):
```
import requests
import os

os.mkdir('./serve')
os.mkdir('./serve/six')
os.mkdir('./skeleton')

url = 'https://pypi.python.org/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz'

with open('./serve/six/six-1.11.0.tar.gz', 'wb') as fp:
    fp.write(requests.get(url).content)

jsn = b'''{
    "info": {
        "author": "Benjamin Peterson", 
        "description": "It provides utility functions for smoothing over the differences between the Python versions with the goal of writing Python code that is compatible on both Python versions.", 
        "name": "six", 
        "license": "MIT", 
        "summary": "Python 2 and 3 compatibility utilities"
    }, 
    "releases": {
        "1.11.0": [
            {
                "python_version": "source", 
                "url": "http://localhost:8000/six/six-1.11.0.tar.gz", 
                "md5_digest": "d12789f9baf7e9fb2524c0c64f1773f8", 
                "filename": "six-1.11.0.tar.gz", 
                "packagetype": "sdist", 
                "size": 29860
            }
        ]
    }
}'''

with open('./serve/six/json', 'wb') as fp:
    fp.write(jsn)

os.chdir('./serve')
os.system("start cmd /K python -m http.server 8000")
```
now from the CMD terminal run:
```
conda skeleton pypi --pypi-url http://localhost:8000 six --output-dir ./skeleton
```

### Problem:
The problem is in the field at `source: url:`, which has the server 'https://pypi.io/' as the server instead of what is passed to `--pypi-url`.  
```
{% set name = "six" %}
{% set version = "1.11.0" %}
{% set file_ext = "tar.gz" %}
{% set hash_type = "sha256" %}
{% set hash_value = "70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9" %}

package:
  name: '{{ name|lower }}'
  version: '{{ version }}'

source:
  fn: '{{ name }}-{{ version }}.{{ file_ext }}'
  url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.{{ file_ext }}
  '{{ hash_type }}': '{{ hash_value }}'

build:
  number: 0
  script: python setup.py install --single-version-externally-managed --record=record.txt

requirements:
  build:
    - python
    - setuptools
  run:
    - python

about:
  home: http://pypi.python.org/pypi/six/
  license: MIT License
  license_family: MIT
  license_file: ''
  summary: Python 2 and 3 compatibility utilities
  description: It provides utility functions for smoothing over the differences between the Python versions with the goal of writing Python code that is compatible on both Python versions.
  doc_url: ''
  dev_url: ''

extra:
  recipe-maintainers: ''
```


##### `Output of conda info`
```
     active environment : None
       user config file : C:\Users\James\.condarc
 populated config files : C:\Users\James\.condarc
          conda version : 4.4.7
    conda-build version : 3.0.27
         python version : 3.6.3.final.0
       base environment : C:\Users\James\Anaconda3  (writable)
           channel URLs : http://conda.anaconda.org/james_dsci/win-64
                          http://conda.anaconda.org/james_dsci/noarch
                          https://repo.continuum.io/pkgs/main/win-64
                          https://repo.continuum.io/pkgs/main/noarch
                          https://repo.continuum.io/pkgs/free/win-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/win-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/win-64
                          https://repo.continuum.io/pkgs/pro/noarch
                          https://repo.continuum.io/pkgs/msys2/win-64
                          https://repo.continuum.io/pkgs/msys2/noarch
          package cache : C:\Users\James\Anaconda3\pkgs
                          C:\Users\James\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\James\Anaconda3\envs
                          C:\Users\James\AppData\Local\conda\conda\envs
                          C:\Users\James\.conda\envs
               platform : win-64
             user-agent : conda/4.4.7 requests/2.18.4 CPython/3.6.3 Windows/10 Windows/10.0.16299
          administrator : False
             netrc file : None
           offline mode : False
```




Discussion:
You're using a very old, unsupported conda-build version.  Nevertheless, I don't think this is fixed in the current code, either: https://github.com/conda/conda-build/blob/master/conda_build/skeletons/pypi.py#L97

I'll see about a fix.

Resolving patch:
diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py
--- a/conda_build/skeletons/pypi.py
+++ b/conda_build/skeletons/pypi.py
@@ -19,7 +19,7 @@
 import pkginfo
 import requests
 from requests.packages.urllib3.util.url import parse_url
-from six.moves.urllib.parse import urljoin
+from six.moves.urllib.parse import urljoin, urlsplit
 import yaml
 try:
     import ruamel_yaml
@@ -94,7 +94,7 @@
     ]),
     'source': ruamel_yaml.comments.CommentedMap([
         ('fn', '{{ name }}-{{ version }}.{{ file_ext }}'),
-        ('url', 'https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.{{ file_ext }}'),  # NOQA
+        ('url', '/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.{{ file_ext }}'),  # NOQA
         ('{{ hash_type }}', '{{ hash_value }}'),
     ]),
     'build': ruamel_yaml.comments.CommentedMap([
@@ -308,6 +308,12 @@ def skeletonize(packages, output_dir=".", version=None, recursive=False,
                 except KeyError:
                     ordered_recipe[key] = ruamel_yaml.comments.CommentedMap()
 
+            if '://' not in pypi_url:
+                raise ValueError("pypi_url must have protocol (e.g. http://) included")
+            base_url = urlsplit(pypi_url)
+            base_url = "://".join((base_url.scheme, base_url.netloc))
+            ordered_recipe['source']['url'] = urljoin(base_url, ordered_recipe['source']['url'])
+
             if d['entry_points']:
                 ordered_recipe['build']['entry_points'] = d['entry_points']
 


Test patch: