Repository: conda/conda

Issue:
conda cannot create an environment with only a constrained virtual package

## Current Behavior
Conda fails when asked to create a environment containing only a virtual package with a version constraint.  Adding an additional spec to the environment or removing the constraint works.


### Steps to Reproduce
<!-- If the current behavior is a bug, please provide specific, minimal steps to independently reproduce.
     Include the exact conda commands that reproduce the issue and their output between the ticks below. -->
```
$ conda create -n example __glibc --dry-run  # works
$ conda create -n example "__glibc>=0` openssl --dry-run # works
$ conda create -n example "__glibc>=0" --dry-run
Collecting package metadata (current_repodata.json): done        
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
                                                   
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
                                                   
    Traceback (most recent call last):                  
      File "/home/jhelmus/conda/lib/python3.7/site-packages/conda/exceptions.py", line 1079, in __call__              
        return func(*args, **kwargs)
      File "/home/jhelmus/conda/lib/python3.7/site-packages/conda/cli/main.py", line 84, in _main
        exit_code = do_call(args, p)                                                            
      File "/home/jhelmus/conda/lib/python3.7/site-packages/conda/cli/conda_argparse.py", line 82, in do_call
        return getattr(module, func_name)(args, parser)                                         
      File "/home/jhelmus/conda/lib/python3.7/site-packages/conda/cli/main_create.py", line 37, in execute
        install(args, parser, 'create') 
      File "/home/jhelmus/conda/lib/python3.7/site-packages/conda/cli/install.py", line 265, in install
        should_retry_solve=(_should_retry_unfrozen or repodata_fn != repodata_fns[-1]),
      File "/home/jhelmus/conda/lib/python3.7/site-packages/conda/core/solve.py", line 117, in solve_for_transaction
        should_retry_solve)
      File "/home/jhelmus/conda/lib/python3.7/site-packages/conda/core/solve.py", line 158, in solve_for_diff
        force_remove, should_retry_solve)
      File "/home/jhelmus/conda/lib/python3.7/site-packages/conda/core/solve.py", line 289, in solve_final_state
        self.determine_constricting_specs(spec, ssc.solution_precs)
      File "/home/jhelmus/conda/lib/python3.7/site-packages/conda/core/solve.py", line 315, in determine_constricting_specs
        if sp.name == spec.name][0]
    IndexError: list index out of range

`$ /home/jhelmus/conda/bin/conda create -n example __glibc>=0 --dry-run`

  environment variables:
                 CIO_TEST=<not set>
   CONDA_BACKUP_JAVA_HOME=
CONDA_BACKUP_JAVA_LD_LIBRARY_PATH=
        CONDA_DEFAULT_ENV=base
                CONDA_EXE=/home/jhelmus/conda/bin/conda
             CONDA_PREFIX=/home/jhelmus/conda
    CONDA_PROMPT_MODIFIER=
   CONDA_PYTHONBREAKPOINT=
         CONDA_PYTHON_EXE=/home/jhelmus/conda/bin/python
               CONDA_ROOT=/home/jhelmus/conda
              CONDA_SHLVL=1
     JAVA_LD_LIBRARY_PATH=/home/jhelmus/conda/jre/lib/amd64/server
                     PATH=/home/jhelmus/conda/bin:/home/jhelmus/bin:/home/jhelmus/conda/bin:/hom
                          e/jhelmus/conda/condabin:/home/jhelmus/bin:/usr/local/sbin:/usr/local/
                          bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bi
                          n
         PYTHONBREAKPOINT=ipdb.set_trace
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>
               WINDOWPATH=2

     active environment : base
    active env location : /home/jhelmus/conda
            shell level : 1
       user config file : /home/jhelmus/.condarc
 populated config files : /home/jhelmus/.condarc
          conda version : 4.8.3
    conda-build version : 3.18.11
         python version : 3.7.7.final.0
       virtual packages : __cuda=10.1
                          __glibc=2.27
       base environment : /home/jhelmus/conda  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/jhelmus/conda/pkgs
                          /home/jhelmus/.conda/pkgs
       envs directories : /home/jhelmus/conda/envs
                          /home/jhelmus/.conda/envs
               platform : linux-64
             user-agent : conda/4.8.3 requests/2.21.0 CPython/3.7.7 Linux/4.15.0-109-generic ubuntu/18.04.4 glibc/2.27
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

```


## Expected Behavior
Provided that the virtual package spec is valid conda should create an empty environment in the same manner as when an un-restrained virtual package is specified.

## Environment Information
<details open><summary><code>`conda info`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda info' -->

```
$ conda info

     active environment : base
    active env location : /home/jhelmus/conda
            shell level : 1
       user config file : /home/jhelmus/.condarc
 populated config files : /home/jhelmus/.condarc
          conda version : 4.8.3
    conda-build version : 3.18.11
         python version : 3.7.7.final.0
       virtual packages : __cuda=10.1
                          __glibc=2.27
       base environment : /home/jhelmus/conda  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/jhelmus/conda/pkgs
                          /home/jhelmus/.conda/pkgs
       envs directories : /home/jhelmus/conda/envs
                          /home/jhelmus/.conda/envs
               platform : linux-64
             user-agent : conda/4.8.3 requests/2.21.0 CPython/3.7.7 Linux/4.15.0-109-generic ubuntu/18.04.4 glibc/2.27
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False
```
</p></details>


<details open><summary><code>`conda config --show-sources`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda config --show-sources' -->

```
$ conda config --show-sources
==> /home/jhelmus/.condarc <==
add_pip_as_python_dependency: False
changeps1: False
ssl_verify: True
channels:
  - defaults
show_channel_urls: True
report_errors: False
```
</p></details>



Discussion:
I'm curious if #10057 changes this behavior
#10057 does not change this behavior.

Resolving patch:
diff --git a/conda/core/solve.py b/conda/core/solve.py
--- a/conda/core/solve.py
+++ b/conda/core/solve.py
@@ -369,6 +369,8 @@ def empty_package_list(pkg):
             return update_constrained
 
         for pkg in self.specs_to_add:
+            if pkg.name.startswith('__'):  # ignore virtual packages
+                continue
             current_version = max(i[1] for i in pre_packages[pkg.name])
             if current_version == max(i.version for i in index_keys if i.name == pkg.name):
                 continue


Test patch:
diff --git a/tests/test_create.py b/tests/test_create.py
--- a/tests/test_create.py
+++ b/tests/test_create.py
@@ -2881,6 +2881,12 @@ def test_neutering_of_historic_specs(self):
             #    If this command runs successfully (does not raise), then all is well.
             stdout, stderr, _ = run_command(Commands.INSTALL, prefix, "imagesize")
 
+    # https://github.com/conda/conda/issues/10116
+    @pytest.mark.skipif(not context.subdir.startswith('linux'), reason="__glibc only available on linux")
+    def test_install_bound_virtual_package(self):
+        with make_temp_env("__glibc>0") as prefix:
+            pass
+
     @pytest.mark.integration
     def test_remove_empty_env(self):
         with make_temp_env() as prefix: