{"action":"created","issue":{"url":"https://api.github.com/repos/conda/conda-build/issues/667","labels_url":"https://api.github.com/repos/conda/conda-build/issues/667/labels{/name}","comments_url":"https://api.github.com/repos/conda/conda-build/issues/667/comments","events_url":"https://api.github.com/repos/conda/conda-build/issues/667/events","html_url":"https://github.com/conda/conda-build/pull/667","id":115379441,"number":667,"title":"Provide parsed metadata from first pass as context to second pass","user":{"login":"stuarteberg","id":1655821,"avatar_url":"https://avatars.githubusercontent.com/u/1655821?v=3","gravatar_id":"","url":"https://api.github.com/users/stuarteberg","html_url":"https://github.com/stuarteberg","followers_url":"https://api.github.com/users/stuarteberg/followers","following_url":"https://api.github.com/users/stuarteberg/following{/other_user}","gists_url":"https://api.github.com/users/stuarteberg/gists{/gist_id}","starred_url":"https://api.github.com/users/stuarteberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stuarteberg/subscriptions","organizations_url":"https://api.github.com/users/stuarteberg/orgs","repos_url":"https://api.github.com/users/stuarteberg/repos","events_url":"https://api.github.com/users/stuarteberg/events{/privacy}","received_events_url":"https://api.github.com/users/stuarteberg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-05T21:33:54Z","updated_at":"2015-12-07T18:58:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/conda/conda-build/pulls/667","html_url":"https://github.com/conda/conda-build/pull/667","diff_url":"https://github.com/conda/conda-build/pull/667.diff","patch_url":"https://github.com/conda/conda-build/pull/667.patch"},"body":"**Note:** The \"Files changed\" tab here on github makes this PR seem bigger than it really is.  If you review these commits individually, you'll see that each one is small.\r\n\r\n---\r\n\r\nconda-build defines a number of [environment variables][1] that can be used within `build.sh`.  Using jinja templates, you can also use *most* these variables within `meta.yaml`.  I say *most* because some of those variables come from `meta.yaml` itself, such as `PKG_BUILDNUM`.\r\n\r\nFor instance, this recipe attempts to include the build number as part of the build string, but it won't work:\r\n\r\n```\r\nbuild:\r\n  number: 99\r\n  string: special_build_n{{PKG_BUILDNUM}}\r\n```\r\n\r\nWe can fix this.  Since conda-build parses `meta.yaml` in *two passes*, there's no reason we can't make those variables available in the second pass.  That way, there is no longer a discrepancy between the set of variables available in `meta.yaml` and those available in `build.sh`.\r\n\r\nIt's a pretty easy fix: Just provide the `MetaData` contents (after the first pass) to the jinja context of the second pass.\r\n\r\n[1]: http://conda.pydata.org/docs/building/environment-vars.html\r\n\r\n--\r\n**Edit:**\r\n\r\nI can think of another potential use for this feature.  In `meta.yaml` the [`build: script_env:` section][2] allows the user to provide a list of \"inherited\" environment variables, which can be used in `build.sh`.  With this PR, those same variables can also be used within `meta.yaml` itself!  For example:\r\n\r\n[2]: http://conda.pydata.org/docs/building/environment-vars.html#inherited-environment-variables\r\n\r\n```\r\nbuild:\r\n  script_env:\r\n   - USER\r\n  string: {{USER}}_{{PKG_BUILDNUM}}\r\n```\r\n\r\n...ok, I'm not sure how useful that is; it just seemed worth mentioning.  The main thing I'm interested in is still the `PKG_BUILDNUM` syntax shown above.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/conda/conda-build/issues/comments/162624041","html_url":"https://github.com/conda/conda-build/pull/667#issuecomment-162624041","issue_url":"https://api.github.com/repos/conda/conda-build/issues/667","id":162624041,"user":{"login":"stuarteberg","id":1655821,"avatar_url":"https://avatars.githubusercontent.com/u/1655821?v=3","gravatar_id":"","url":"https://api.github.com/users/stuarteberg","html_url":"https://github.com/stuarteberg","followers_url":"https://api.github.com/users/stuarteberg/followers","following_url":"https://api.github.com/users/stuarteberg/following{/other_user}","gists_url":"https://api.github.com/users/stuarteberg/gists{/gist_id}","starred_url":"https://api.github.com/users/stuarteberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stuarteberg/subscriptions","organizations_url":"https://api.github.com/users/stuarteberg/orgs","repos_url":"https://api.github.com/users/stuarteberg/repos","events_url":"https://api.github.com/users/stuarteberg/events{/privacy}","received_events_url":"https://api.github.com/users/stuarteberg/received_events","type":"User","site_admin":false},"created_at":"2015-12-07T18:58:08Z","updated_at":"2015-12-07T18:58:08Z","body":"So.... any verdict here?"}}