Repository: pex-tool/pex

Issue:
pex --index-url=... fails in 2.0.0
Hello,

In my team we have an issue since this morning with the new version of PEX

This is a big Django project but with simple configuration.

Here is an extract of the setup.py

```
setuptools.setup(
    name='rackguru-api',
    version=find_version(),
    install_requires=_INSTALL_REQUIRES,
    author='Criteo',
    author_email='infratools-team@criteo.com',
    description='Criteo datacenter assets manager',
    packages=setuptools.find_packages(),
    entry_points={
        'console_scripts': [
            'rackguru-run = marathon.run:main',
        ],
    },
    classifiers=CLASSIFIERS,
    include_package_data=True,
)
```

In the tox.ini :

```
# Bundle environment
[testenv:bundle]
deps = pex
setenv =
    LANG=en_US.UTF-8
commands =
    # Collect the statics to be embedded in the sdist and PEX file (via the MANIFEST)
    {envpython} manage.py collectstatic --noinput --clear
    # Creates a source archive in sdist/
    {envpython} setup.py sdist --dist-dir=sdist --format=gztar
    # Build exec file and save it in dist/
    {envpython} setup.py bdist_pex --bdist-dir=dist --pex-args='--disable-cache --not-zip-safe --index-url=http://build-nexus.crto.in/repository/pypi/simple' --bdist-all
```

And here is the build output :

```
bundle run-test: commands[2] | /tmp/.tox-rackguru-api-post-submit-3573/com.criteo.rackguru.rackguru-api/bundle/bin/python setup.py bdist_pex --bdist-dir=dist '--pex-args=--disable-cache --not-zip-safe --index-url=http://build-nexus.crto.in/repository/pypi/simple' --bdist-all
running bdist_pex
Writing rackguru-run to dist/rackguru-run
Failed to create pex via /tmp/.tox-rackguru-api-post-submit-3573/com.criteo.rackguru.rackguru-api/bundle/bin/python3.6 -s -m pex /home/jenkins/workspace/rackguru-api-post-submit --disable-cache --not-zip-safe --index-url=http://build-nexus.crto.in/repository/pypi/simple --output-file dist/rackguru-run --script rackguru-run:
Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/.tox-rackguru-api-post-submit-3573/com.criteo.rackguru.rackguru-api/bundle/lib/python3.6/site-packages/pex/__main__.py", line 8, in <module>
    __name__ == '__main__' and pex.main()
  File "/tmp/.tox-rackguru-api-post-submit-3573/com.criteo.rackguru.rackguru-api/bundle/lib/python3.6/site-packages/pex/bin/pex.py", line 628, in main
    pex_builder = build_pex(reqs, options)
  File "/tmp/.tox-rackguru-api-post-submit-3573/com.criteo.rackguru.rackguru-api/bundle/lib/python3.6/site-packages/pex/bin/pex.py", line 540, in build_pex
    indexes = [str(index) for index in options.indexes]
  File "/tmp/.tox-rackguru-api-post-submit-3573/com.criteo.rackguru.rackguru-api/bundle/lib/python3.6/site-packages/pex/bin/pex.py", line 540, in <listcomp>
    indexes = [str(index) for index in options.indexes]
TypeError: __str__ returned non-string (type NoneType)
```

Do you have any idea about the root issue ?


Discussion:
The issue looks like related to the `--index-url` options, will digg into

Resolving patch:
diff --git a/pex/bin/pex.py b/pex/bin/pex.py
--- a/pex/bin/pex.py
+++ b/pex/bin/pex.py
@@ -60,7 +60,7 @@ def process_disable_cache(option, option_str, option_value, parser):
 
 class PyPiSentinel(object):
   def __str__(self):
-    'https://pypi.org/simple'
+    return 'https://pypi.org/simple'
 
 
 _PYPI = PyPiSentinel()


Test patch: