{"action":"created","comment":{"url":"https://api.github.com/repos/conda/conda-build/pulls/comments/46323531","id":46323531,"diff_hunk":"@@ -308,6 +309,13 @@ def execute(args, parser):\n                 raise RuntimeError(\"%s must be major.minor, not %s\" %\n                     (conda_version[lang], version))\n \n+    # Using --python, --numpy etc. is equivalent to using CONDA_PY, CONDA_NPY, etc.\n+    # Auto-set those env variables\n+    for var in conda_version.values():\n+        if getattr(config, var):","path":"conda_build/main_build.py","position":15,"original_position":15,"commit_id":"8b6b8b7ebe2a3bb5ae28056b611eb396addcdf3f","original_commit_id":"8b6b8b7ebe2a3bb5ae28056b611eb396addcdf3f","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},"body":"That was already the case.  The original behavior was equivalent to the following pseudo-code:\r\n\r\n```python\r\n# By default, use os.environ\r\nconda_build.config.Config.CONDA_PY = os.environ['CONDA_PY']\r\n\r\n# Override with --python=foo.bar, if available\r\nif args.python:\r\n    conda_build.config.Config.CONDA_PY = args.python\r\n```\r\n\r\nI just want `os.environ` to *also* reflect the change.  In the pseudo-code, I'm adding a line to the if-block:\r\n\r\n```python\r\n# By default, use os.environ\r\nconda_build.config.Config.CONDA_PY = os.environ['CONDA_PY']\r\n\r\n# Override with --python=foo.bar, if available\r\nif args.python:\r\n    conda_build.config.Config.CONDA_PY = args.python\r\n    # Also, update os.environ\r\n    os.environ['CONDA_PY'] = args.python\r\n```","created_at":"2015-12-01T19:12:57Z","updated_at":"2015-12-01T19:12:57Z","html_url":"https://github.com/conda/conda-build/pull/662#discussion_r46323531","pull_request_url":"https://api.github.com/repos/conda/conda-build/pulls/662","_links":{"self":{"href":"https://api.github.com/repos/conda/conda-build/pulls/comments/46323531"},"html":{"href":"https://github.com/conda/conda-build/pull/662#discussion_r46323531"},"pull_request":{"href":"https://api.github.com/repos/conda/conda-build/pulls/662"}}},"pull_request":{"url":"https://api.github.com/repos/conda/conda-build/pulls/662","id":49770230,"html_url":"https://github.com/conda/conda-build/pull/662","diff_url":"https://github.com/conda/conda-build/pull/662.diff","patch_url":"https://github.com/conda/conda-build/pull/662.patch","issue_url":"https://api.github.com/repos/conda/conda-build/issues/662","number":662,"state":"open","locked":false,"title":"main: If user supplies --python, auto-set CONDA_PY environment variable.","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},"body":"To build with a specific python version, the user can try two things:\r\n\r\n1. The `CONDA_PY` environment variable, e.g. `CONDA_PY=27 conda build my-package`\r\n\r\n    OR\r\n2. The `--python` option on the command-line, e.g. `conda build --python=2.7 my-package`\r\n\r\nInternally, both mechanisms set `CONDA_PY` within `conda.config`.  Additionally, `os.environ[\"CONDA_PY\"]` can also be used, but **only** if the user used the first mechanism.  It would be nice if that also worked in the second case.  (For example, that would make the value consistently available to `jinja2` templates within `meta.yaml`, as well as the `build.sh` environment.)\r\n\r\nThis little PR just copies `config.CONDA_PY` (and `config.CONDA_NPY`, etc.) into `os.environ`, so the two modules are in sync for these variables.\r\n\r\nIt allows `meta.yaml` syntax like this, which doesn't always work in the current version of `conda-build`:\r\n\r\n```\r\nbuild:\r\n  string: np{{CONDA_NPY}}py{{CONDA_PY}}_0_foo_bar\r\n```\r\n","created_at":"2015-11-05T01:13:37Z","updated_at":"2015-12-01T19:12:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c395025cf8ab4a401f9fdd04d08a61cb694ad55","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/conda/conda-build/pulls/662/commits","review_comments_url":"https://api.github.com/repos/conda/conda-build/pulls/662/comments","review_comment_url":"https://api.github.com/repos/conda/conda-build/pulls/comments{/number}","comments_url":"https://api.github.com/repos/conda/conda-build/issues/662/comments","statuses_url":"https://api.github.com/repos/conda/conda-build/statuses/8b6b8b7ebe2a3bb5ae28056b611eb396addcdf3f","head":{"label":"stuarteberg:auto-set-CONDA_PY","ref":"auto-set-CONDA_PY","sha":"8b6b8b7ebe2a3bb5ae28056b611eb396addcdf3f","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},"repo":{"id":37874194,"name":"conda-build","full_name":"stuarteberg/conda-build","owner":{"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},"private":false,"html_url":"https://github.com/stuarteberg/conda-build","description":"Commands and tools for building conda packages","fork":true,"url":"https://api.github.com/repos/stuarteberg/conda-build","forks_url":"https://api.github.com/repos/stuarteberg/conda-build/forks","keys_url":"https://api.github.com/repos/stuarteberg/conda-build/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stuarteberg/conda-build/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stuarteberg/conda-build/teams","hooks_url":"https://api.github.com/repos/stuarteberg/conda-build/hooks","issue_events_url":"https://api.github.com/repos/stuarteberg/conda-build/issues/events{/number}","events_url":"https://api.github.com/repos/stuarteberg/conda-build/events","assignees_url":"https://api.github.com/repos/stuarteberg/conda-build/assignees{/user}","branches_url":"https://api.github.com/repos/stuarteberg/conda-build/branches{/branch}","tags_url":"https://api.github.com/repos/stuarteberg/conda-build/tags","blobs_url":"https://api.github.com/repos/stuarteberg/conda-build/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stuarteberg/conda-build/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stuarteberg/conda-build/git/refs{/sha}","trees_url":"https://api.github.com/repos/stuarteberg/conda-build/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stuarteberg/conda-build/statuses/{sha}","languages_url":"https://api.github.com/repos/stuarteberg/conda-build/languages","stargazers_url":"https://api.github.com/repos/stuarteberg/conda-build/stargazers","contributors_url":"https://api.github.com/repos/stuarteberg/conda-build/contributors","subscribers_url":"https://api.github.com/repos/stuarteberg/conda-build/subscribers","subscription_url":"https://api.github.com/repos/stuarteberg/conda-build/subscription","commits_url":"https://api.github.com/repos/stuarteberg/conda-build/commits{/sha}","git_commits_url":"https://api.github.com/repos/stuarteberg/conda-build/git/commits{/sha}","comments_url":"https://api.github.com/repos/stuarteberg/conda-build/comments{/number}","issue_comment_url":"https://api.github.com/repos/stuarteberg/conda-build/issues/comments{/number}","contents_url":"https://api.github.com/repos/stuarteberg/conda-build/contents/{+path}","compare_url":"https://api.github.com/repos/stuarteberg/conda-build/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stuarteberg/conda-build/merges","archive_url":"https://api.github.com/repos/stuarteberg/conda-build/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stuarteberg/conda-build/downloads","issues_url":"https://api.github.com/repos/stuarteberg/conda-build/issues{/number}","pulls_url":"https://api.github.com/repos/stuarteberg/conda-build/pulls{/number}","milestones_url":"https://api.github.com/repos/stuarteberg/conda-build/milestones{/number}","notifications_url":"https://api.github.com/repos/stuarteberg/conda-build/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stuarteberg/conda-build/labels{/name}","releases_url":"https://api.github.com/repos/stuarteberg/conda-build/releases{/id}","created_at":"2015-06-22T18:49:19Z","updated_at":"2015-06-22T18:49:21Z","pushed_at":"2015-12-01T18:39:00Z","git_url":"git://github.com/stuarteberg/conda-build.git","ssh_url":"git@github.com:stuarteberg/conda-build.git","clone_url":"https://github.com/stuarteberg/conda-build.git","svn_url":"https://github.com/stuarteberg/conda-build","homepage":null,"size":1866,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"conda:master","ref":"master","sha":"0b5ebdba904760181eb22dbfd0d2552aca2f6b70","user":{"login":"conda","id":6392739,"avatar_url":"https://avatars.githubusercontent.com/u/6392739?v=3","gravatar_id":"","url":"https://api.github.com/users/conda","html_url":"https://github.com/conda","followers_url":"https://api.github.com/users/conda/followers","following_url":"https://api.github.com/users/conda/following{/other_user}","gists_url":"https://api.github.com/users/conda/gists{/gist_id}","starred_url":"https://api.github.com/users/conda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conda/subscriptions","organizations_url":"https://api.github.com/users/conda/orgs","repos_url":"https://api.github.com/users/conda/repos","events_url":"https://api.github.com/users/conda/events{/privacy}","received_events_url":"https://api.github.com/users/conda/received_events","type":"Organization","site_admin":false},"repo":{"id":16008423,"name":"conda-build","full_name":"conda/conda-build","owner":{"login":"conda","id":6392739,"avatar_url":"https://avatars.githubusercontent.com/u/6392739?v=3","gravatar_id":"","url":"https://api.github.com/users/conda","html_url":"https://github.com/conda","followers_url":"https://api.github.com/users/conda/followers","following_url":"https://api.github.com/users/conda/following{/other_user}","gists_url":"https://api.github.com/users/conda/gists{/gist_id}","starred_url":"https://api.github.com/users/conda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conda/subscriptions","organizations_url":"https://api.github.com/users/conda/orgs","repos_url":"https://api.github.com/users/conda/repos","events_url":"https://api.github.com/users/conda/events{/privacy}","received_events_url":"https://api.github.com/users/conda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/conda/conda-build","description":"Commands and tools for building conda packages","fork":false,"url":"https://api.github.com/repos/conda/conda-build","forks_url":"https://api.github.com/repos/conda/conda-build/forks","keys_url":"https://api.github.com/repos/conda/conda-build/keys{/key_id}","collaborators_url":"https://api.github.com/repos/conda/conda-build/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/conda/conda-build/teams","hooks_url":"https://api.github.com/repos/conda/conda-build/hooks","issue_events_url":"https://api.github.com/repos/conda/conda-build/issues/events{/number}","events_url":"https://api.github.com/repos/conda/conda-build/events","assignees_url":"https://api.github.com/repos/conda/conda-build/assignees{/user}","branches_url":"https://api.github.com/repos/conda/conda-build/branches{/branch}","tags_url":"https://api.github.com/repos/conda/conda-build/tags","blobs_url":"https://api.github.com/repos/conda/conda-build/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/conda/conda-build/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/conda/conda-build/git/refs{/sha}","trees_url":"https://api.github.com/repos/conda/conda-build/git/trees{/sha}","statuses_url":"https://api.github.com/repos/conda/conda-build/statuses/{sha}","languages_url":"https://api.github.com/repos/conda/conda-build/languages","stargazers_url":"https://api.github.com/repos/conda/conda-build/stargazers","contributors_url":"https://api.github.com/repos/conda/conda-build/contributors","subscribers_url":"https://api.github.com/repos/conda/conda-build/subscribers","subscription_url":"https://api.github.com/repos/conda/conda-build/subscription","commits_url":"https://api.github.com/repos/conda/conda-build/commits{/sha}","git_commits_url":"https://api.github.com/repos/conda/conda-build/git/commits{/sha}","comments_url":"https://api.github.com/repos/conda/conda-build/comments{/number}","issue_comment_url":"https://api.github.com/repos/conda/conda-build/issues/comments{/number}","contents_url":"https://api.github.com/repos/conda/conda-build/contents/{+path}","compare_url":"https://api.github.com/repos/conda/conda-build/compare/{base}...{head}","merges_url":"https://api.github.com/repos/conda/conda-build/merges","archive_url":"https://api.github.com/repos/conda/conda-build/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/conda/conda-build/downloads","issues_url":"https://api.github.com/repos/conda/conda-build/issues{/number}","pulls_url":"https://api.github.com/repos/conda/conda-build/pulls{/number}","milestones_url":"https://api.github.com/repos/conda/conda-build/milestones{/number}","notifications_url":"https://api.github.com/repos/conda/conda-build/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/conda/conda-build/labels{/name}","releases_url":"https://api.github.com/repos/conda/conda-build/releases{/id}","created_at":"2014-01-17T18:46:21Z","updated_at":"2015-10-05T17:52:35Z","pushed_at":"2015-12-01T18:39:00Z","git_url":"git://github.com/conda/conda-build.git","ssh_url":"git@github.com:conda/conda-build.git","clone_url":"https://github.com/conda/conda-build.git","svn_url":"https://github.com/conda/conda-build","homepage":null,"size":3327,"stargazers_count":28,"watchers_count":28,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":267,"forks":75,"open_issues":267,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/conda/conda-build/pulls/662"},"html":{"href":"https://github.com/conda/conda-build/pull/662"},"issue":{"href":"https://api.github.com/repos/conda/conda-build/issues/662"},"comments":{"href":"https://api.github.com/repos/conda/conda-build/issues/662/comments"},"review_comments":{"href":"https://api.github.com/repos/conda/conda-build/pulls/662/comments"},"review_comment":{"href":"https://api.github.com/repos/conda/conda-build/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/conda/conda-build/pulls/662/commits"},"statuses":{"href":"https://api.github.com/repos/conda/conda-build/statuses/8b6b8b7ebe2a3bb5ae28056b611eb396addcdf3f"}}}}