Repository: conda/conda

Issue:
Python2.7: pip requirements.txt recursive requirements files fail to install
## Current Behavior
Installing an environment that has pip requirements such as:
```yml
pip:
  - -r requirements.txt
```
Where the `requirements.txt` file contains references to others:
```ini
# contents of requirements.txt
-r tools/requirements.txt
```
Yields an error resolving the referenced requirements files when running pip on the top file.

### Steps to Reproduce
Affects python2 only.

With the following repo structure:
```
myrepo
├── environment.yml
├── requirements.txt
└── tools
    └── requirements.txt
```
And `myrepo/requirements.txt` containing a line:
```ini
-r tools/requirements.txt
```
Creating the conda environment will give an error:
```
❯ conda env update -f environment.yml
Collecting package metadata: done
Solving environment: done
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Ran pip subprocess with arguments:
[u'/home/user/miniconda2/envs/Foo/bin/python', '-m', 'pip', 'install', '-r', '/tmp/tmpuQ5dFk.requirements.txt']
Pip subprocess output:

Pip subprocess error:
Could not open requirements file: [Errno 2] No such file or directory: '/tmp/tools/requirements.txt'
You are using pip version 9.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

#
# To activate this environment, use
#
#     $ conda activate Foo
#
# To deactivate an active environment, use
#
#     $ conda deactivate
```
Interestingly enough, it doesn't cause conda to return an error; it would seem prudent to raise the pip subprocess error too, since the result is a malformed environment.

## Expected Behavior
Recursive `requirements.txt` files should behave as normal.

## Environment Information
<details open><summary><code>`conda info`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda info' -->

```
     active environment : None
            shell level : 0
       user config file : /home/npendleton/.condarc
 populated config files : /home/npendleton/.condarc
          conda version : 4.6.12
    conda-build version : 3.17.8
         python version : 2.7.15.final.0
       base environment : /home/npendleton/miniconda2  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/npendleton/miniconda2/pkgs
                          /home/npendleton/.conda/pkgs
       envs directories : /home/npendleton/miniconda2/envs
                          /home/npendleton/.conda/envs
               platform : linux-64
             user-agent : conda/4.6.12 requests/2.18.4 CPython/2.7.15 Linux/4.18.0-17-generic ubuntu/18.10 glibc/2.28
                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' -->

```
==> /home/npendleton/.condarc <==
changeps1: False
```
</p></details>


<details><summary><code>`conda list --show-channel-urls`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda list --show-channel-urls' -->

```
# packages in environment at /home/npendleton/miniconda2:
#
# Name                    Version                   Build  Channel
asn1crypto                0.24.0                   py27_0    defaults
backports                 1.0                      py27_1    defaults
backports.functools_lru_cache 1.5                      py27_1    defaults
beautifulsoup4            4.7.1                    py27_1    defaults
bzip2                     1.0.6                h14c3975_5    defaults
ca-certificates           2019.1.23                     0    defaults
certifi                   2019.3.9                 py27_0    defaults
cffi                      1.11.5           py27h9745a5d_0    defaults
chardet                   3.0.4            py27hfa10054_1    defaults
cli-authenticate          1.1.1                    pypi_0    pypi
click                     7.0                      py27_0    defaults
conda                     4.6.12                   py27_1    defaults
conda-build               3.17.8                   py27_0    defaults
conda-env                 2.6.0                h36134e3_1    defaults
conda-verify              3.1.1                    py27_0    defaults
contextlib2               0.5.5            py27hbf4c468_0    defaults
cryptography              2.5              py27h1ba5d50_0    defaults
enum34                    1.1.6            py27h99a27e9_1    defaults
fb-site-query             0.0.4                    pypi_0    pypi
filelock                  3.0.10                   py27_0    defaults
future                    0.17.1                   py27_0    defaults
futures                   3.2.0            py27h7b459c0_0    defaults
glob2                     0.6                      py27_1    defaults
graphql-core              2.1                      pypi_0    pypi
graphql-relay             0.4.5                    pypi_0    pypi
icu                       58.2                 h9c2bf20_1    defaults
idna                      2.6              py27h5722d68_1    defaults
invoke                    1.2.0                    pypi_0    pypi
ipaddress                 1.0.22                   py27_0    defaults
jinja2                    2.10                     py27_0    defaults
libarchive                3.3.3                h5d8350f_5    defaults
libedit                   3.1.20181209         hc058e9b_0    defaults
libffi                    3.2.1                hd88cf55_4    defaults
libgcc-ng                 8.2.0                hdf63c60_1    defaults
liblief                   0.9.0                h7725739_2    defaults
libstdcxx-ng              8.2.0                hdf63c60_1    defaults
libxml2                   2.9.9                he19cac6_0    defaults
lz4-c                     1.8.1.2              h14c3975_0    defaults
lzo                       2.10                 h49e0be7_2    defaults
markupsafe                1.1.1            py27h7b6447c_0    defaults
ncurses                   6.1                  he6710b0_1    defaults
openssl                   1.1.1b               h7b6447c_1    defaults
patchelf                  0.9                  he6710b0_3    defaults
pip                       19.0.3                   py27_0    defaults
pkginfo                   1.5.0.1                  py27_0    defaults
promise                   2.2.1                    pypi_0    pypi
psutil                    5.6.1            py27h7b6447c_0    defaults
py-lief                   0.9.0            py27h7725739_2    defaults
pycosat                   0.6.3            py27ha4109ae_0    defaults
pycparser                 2.18             py27hefa08c5_1    defaults
pycryptodome              3.4.11+fb1               pypi_0    pypi
pyopenssl                 17.5.0           py27hcee3be0_0    defaults
pyserial                  3.4                      pypi_0    pypi
pysocks                   1.6.8                    py27_0    defaults
python                    2.7.15               h9bab390_6    defaults
python-libarchive-c       2.8                      py27_6    defaults
pytz                      2018.9                   py27_0    defaults
pyyaml                    3.13             py27h14c3975_0    defaults
readline                  7.0                  ha6073c6_4    defaults
requests                  2.18.4           py27hc5b0589_1    defaults
ruamel_yaml               0.15.35          py27h14c3975_1    defaults
rx                        1.6.1                    pypi_0    pypi
scandir                   1.10.0           py27h7b6447c_0    defaults
setuptools                39.0.1                   py27_0    defaults
six                       1.11.0           py27h5f960f1_1    defaults
soupsieve                 1.7.1                    py27_0    defaults
sqlite                    3.26.0               h7b6447c_0    defaults
tar-client                1.0.0                    pypi_0    pypi
tk                        8.6.8                hbc83047_0    defaults
tqdm                      4.31.1                     py_0    defaults
typing                    3.6.6                    pypi_0    pypi
urllib3                   1.22             py27ha55213b_0    defaults
wheel                     0.31.0                   py27_0    defaults
xz                        5.2.4                h14c3975_4    defaults
yaml                      0.1.7                had09818_2    defaults
zlib                      1.2.11               ha838bed_2    defaults
zstd                      1.3.7                h0b5b093_0    defaults
```
</p></details>



Discussion:

Resolving patch:
diff --git a/conda/_vendor/auxlib/compat.py b/conda/_vendor/auxlib/compat.py
--- a/conda/_vendor/auxlib/compat.py
+++ b/conda/_vendor/auxlib/compat.py
@@ -66,7 +66,7 @@ def Utf8NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="",
         if 'CONDA_TEST_SAVE_TEMPS' in os.environ:
             delete = False
         return codecs.getwriter('utf-8')(NamedTemporaryFile(mode=mode, bufsize=bufsize, suffix=suffix,
-                                 prefix=template, dir=None, delete=delete))
+                                 prefix=template, dir=dir, delete=delete))
 else:
     def Utf8NamedTemporaryFile(mode='w+b', buffering=-1, newline=None,
                                suffix=None, prefix=None, dir=None, delete=True):
diff --git a/conda_env/pip_util.py b/conda_env/pip_util.py
--- a/conda_env/pip_util.py
+++ b/conda_env/pip_util.py
@@ -35,6 +35,8 @@ def pip_subprocess(args, prefix, cwd):
     if rc != 0:
         print("Pip subprocess error:")
         print(stderr)
+        raise CondaEnvException("Pip failed")
+
     # This will modify (break) Context. We have a context stack but need to verify it works
     # stdout, stderr, rc = run_command(Commands.RUN, *run_args, stdout=None, stderr=None)
 


Test patch: