Repository: conda/conda-build

Issue:
`script_env` values not recorded in hash
The presence of a `script_env` declared variable is recorded in the hash but the value of the variable is not, is this desirable? Reproducer:
`meta.yaml`:
```yaml
package:
       name: foopkg
source:
     path: .
build:
    script_env:
        - FOO
```
Building:
```bash
$ conda build . --output
<anaconda_path>/lib/python3.5/site-packages/conda_build/environ.py:368: UserWarning: The environment variable 'FOO' is undefined.
  UserWarning
<anaconda_path>/conda-bld/linux-64/foopkg--h216e30b_0.tar.bz2

$ conda build .
<anaconda_path>/lib/python3.5/site-packages/conda_build/environ.py:368: UserWarning: The environment variable 'FOO' is undefined.
  UserWarning
Attempting to finalize metadata for foopkg
INFO:conda_build.metadata:Attempting to finalize metadata for foopkg
BUILD START: ['foopkg--h216e30b_0.tar.bz2']
Copying /tmp/foo10 to <anaconda_path>/conda-bld/foopkg_1510741027197/work
source tree in: <anaconda_path>/conda-bld/foopkg_1510741027197/work
Packaging foopkg
INFO:conda_build.build:Packaging foopkg
Packaging foopkg--h216e30b_0
INFO:conda_build.build:Packaging foopkg--h216e30b_0
number of files: 0
Fixing permissions
Fixing permissions
updating: foopkg--h216e30b_0.tar.bz2
Updating index at <anaconda_path>/conda-bld/linux-64 to make package installable with dependencies
INFO:conda_build.build:Updating index at <anaconda_path>/conda-bld/linux-64 to make package installable with dependencies
Updating index at <anaconda_path>/conda-bld/noarch to make package installable with dependencies
INFO:conda_build.build:Updating index at <anaconda_path>/conda-bld/noarch to make package installable with dependencies
Nothing to test for: <anaconda_path>/conda-bld/linux-64/foopkg--h216e30b_0.tar.bz2
# Automatic uploading is disabled
# If you want to upload package(s) to anaconda.org later, type:

anaconda upload <anaconda_path>/conda-bld/linux-64/foopkg--h216e30b_0.tar.bz2

# To have conda build upload to anaconda.org automatically, use
# $ conda config --set anaconda_upload yes

anaconda_upload is not set.  Not uploading wheels: []



####################################################################################
Source and build intermediates have been left in <anaconda_path>/conda-bld.
There are currently 9 accumulated.
To remove them, you can run the ```conda build purge``` command

$ conda inspect hash-inputs `conda build . --output`
<anaconda_path>/lib/python3.5/site-packages/conda_build/environ.py:368: UserWarning: The environment variable 'FOO' is undefined.
  UserWarning
Package foopkg--h216e30b_0 does not include recipe.  Full hash information is not reproducible.
WARNING:conda_build.inspect:Package foopkg--h216e30b_0 does not include recipe.  Full hash information is not reproducible.
{'foopkg--h216e30b_0': {'files': [],
                        'recipe': {'build': {'script_env': ['FOO']},
                                   'extra': {'copy_test_source_files': True},
                                   'source': {'path': '/tmp/foo10'}}}}

$ FOO='somestring' conda build .
Attempting to finalize metadata for foopkg
INFO:conda_build.metadata:Attempting to finalize metadata for foopkg
BUILD START: ['foopkg--h216e30b_0.tar.bz2']
Copying /tmp/foo10 to <anaconda_path>/conda-bld/foopkg_1510741210387/work
source tree in: <anaconda_path>/conda-bld/foopkg_1510741210387/work
Packaging foopkg
INFO:conda_build.build:Packaging foopkg
Packaging foopkg--h216e30b_0
INFO:conda_build.build:Packaging foopkg--h216e30b_0
number of files: 0
Fixing permissions
Fixing permissions
updating: foopkg--h216e30b_0.tar.bz2
Updating index at <anaconda_path>/conda-bld/linux-64 to make package installable with dependencies
INFO:conda_build.build:Updating index at <anaconda_path>/conda-bld/linux-64 to make package installable with dependencies
Updating index at <anaconda_path>/conda-bld/noarch to make package installable with dependencies
INFO:conda_build.build:Updating index at <anaconda_path>/conda-bld/noarch to make package installable with dependencies
Nothing to test for: <anaconda_path>/conda-bld/linux-64/foopkg--h216e30b_0.tar.bz2
# Automatic uploading is disabled
# If you want to upload package(s) to anaconda.org later, type:

anaconda upload <anaconda_path>/conda-bld/linux-64/foopkg--h216e30b_0.tar.bz2

# To have conda build upload to anaconda.org automatically, use
# $ conda config --set anaconda_upload yes

anaconda_upload is not set.  Not uploading wheels: []



####################################################################################
Source and build intermediates have been left in <anaconda_path>/conda-bld.
There are currently 10 accumulated.
To remove them, you can run the ```conda build purge``` command

$ conda inspect hash-inputs `FOO='somestring' conda build . --output`
Package foopkg--h216e30b_0 does not include recipe.  Full hash information is not reproducible.
WARNING:conda_build.inspect:Package foopkg--h216e30b_0 does not include recipe.  Full hash information is not reproducible.
{'foopkg--h216e30b_0': {'files': [],
                        'recipe': {'build': {'script_env': ['FOO']},
                                   'extra': {'copy_test_source_files': True},
                                   'source': {'path': '/tmp/foo10'}}}}
```





Discussion:
Because it is potentially hazardous to record all env vars passed into recipes, it is infeasible to add these values into the hash.  The danger is that people might unexpectedly include private information in packages they build.

The requirement is that when using ``--no-test`` to split build and test, you must set any script_env environment variables similarly in both build and test phases.  This is being added to the docs, and also added as a warning whenever any script_env variable is passed in.

Resolving patch:
diff --git a/conda_build/environ.py b/conda_build/environ.py
--- a/conda_build/environ.py
+++ b/conda_build/environ.py
@@ -369,6 +369,12 @@ def meta_vars(meta, config):
             )
         else:
             d[var_name] = value
+            warnings.warn(
+                "The environment variable '%s' is being passed through with value %s."
+                "If you are splitting build and test phases with --no-test, please ensure "
+                "that this value is also set similarly at test time." % (var_name, value),
+                UserWarning
+            )
 
     folder = meta.get_value('source/0/folder', '')
     repo_dir = join(config.work_dir, folder)


Test patch: