{"action":"created","comment":{"url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/comments/190551223","pull_request_review_id":122945025,"id":190551223,"diff_hunk":"@@ -0,0 +1,266 @@\n+package runner\n+\n+import (\n+\t\"bytes\"\n+\t\"crypto/sha256\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"io/ioutil\"\n+\t\"net/http\"\n+\t\"os\"\n+\t\"os/exec\"\n+\t\"path/filepath\"\n+\n+\t\"github.com/stoic-cli/stoic-cli-core\"\n+)\n+\n+const (\n+\tgetPipCacheKey = \"run-python/get-pip.py\"\n+\tgetPipURL      = \"https://bootstrap.pypa.io/get-pip.py\"\n+\n+\tpipCacheBase     = \".pip-cache\"\n+\treadyBase        = \".ready\"\n+\trequirementsBase = \".requirements\"\n+\n+\tpipRequirements = \"\" +\n+\t\t\"pip==10.0.1 --hash=sha256:717cdffb2833be8409433a93746744b59505f42146e8d37de6c62b430e25d6d7\\n\" +\n+\t\t\"setuptools==39.1.0 --hash=sha256:0cb8b8625bfdcc2d43ea4b9cdba0b39b2b7befc04f3088897031082aa16ce186\\n\" +\n+\t\t\"virtualenv==15.2.0 --hash=sha256:e8e05d4714a1c51a2f5921e62f547fcb0f713ebbe959e0a7f585cc8bef71d11f\\n\" +\n+\t\t\"wheel==0.31.0 --hash=sha256:9cdc8ab2cc9c3c2e2727a4b67c22881dbb0e1c503d592992594c5e131c867107\\n\" +\n+\t\t\"\"\n+)\n+\n+func getPipScript(cache stoic.Cache) (string, error) {\n+\tvar err error\n+\n+\tscript, err := ioutil.TempFile(\"\", \"get-pip-*.py\")\n+\tif err != nil {\n+\t\treturn \"\", fmt.Errorf(\n+\t\t\t\"unable to set up temp file for get-pip.py: %v\", err)\n+\t}\n+\tdefer func() {\n+\t\tif err != nil {\n+\t\t\tos.Remove(script.Name())\n+\t\t}\n+\t\tscript.Close()\n+\t}()\n+\n+\tif cacheReader := cache.Get(getPipCacheKey); cacheReader != nil {\n+\t\tdefer cacheReader.Close()\n+\n+\t\t_, err = io.Copy(script, cacheReader)\n+\t\tif err != nil {\n+\t\t\treturn \"\", fmt.Errorf(\n+\t\t\t\t\"unable to read get-pip.py from cache: %v\", err)\n+\t\t}\n+\t} else {\n+\t\tresp, err := http.Get(getPipURL)\n+\t\tif err != nil {\n+\t\t\treturn \"\", fmt.Errorf(\n+\t\t\t\t\"unable to download get-pip.py script from upstream: %v\", err)\n+\t\t}\n+\t\tdefer resp.Body.Close()\n+\n+\t\terr = cache.Put(getPipCacheKey, io.TeeReader(resp.Body, script))\n+\t\tif err != nil {\n+\t\t\treturn \"\", fmt.Errorf(\n+\t\t\t\t\"unable to download get-pip.py script from upstream: %v\", err)\n+\t\t}\n+\t}\n+\n+\treturn script.Name(), nil\n+}\n+\n+func newPythonEnvironment(root string, python string, cache stoic.Cache) (pythonEnvironment, error) {\n+\tbuf := bytes.NewBuffer(nil)\n+\tfmt.Fprintf(buf, \"# Python: %s\\n%s\", python, pipRequirements)\n+\n+\tpipCache := filepath.Join(root, \"pip-cache\")\n+\tpythonName := filepath.Base(python)\n+\n+\trequirements := buf.Bytes()\n+\tenvHash := sha256.Sum256(requirements)\n+\tenvRoot := filepath.Join(root, fmt.Sprintf(\"%s-%.4x\", pythonName, envHash))\n+\n+\tpe := pythonEnvironment{python, pipCache, envRoot}\n+\n+\tmarker := filepath.Join(pe.root, readyBase)\n+\tif fileExists(marker) {\n+\t\treturn pe, nil\n+\t}\n+\n+\tif err := os.MkdirAll(pe.Scripts(), os.ModePerm); err != nil {\n+\t\treturn pythonEnvironment{}, fmt.Errorf(\n+\t\t\t\"unable to setup directory for python environmnent: %v\", err)\n+\t}\n+\n+\tenvRequirements := filepath.Join(pe.root, requirementsBase)\n+\tif err := ioutil.WriteFile(envRequirements, requirements, 0644); err != nil {\n+\t\treturn pythonEnvironment{}, fmt.Errorf(\n+\t\t\t\"unable to write requirements for python environment: %v\", err)\n+\t}\n+\n+\t///...\n+\tgetPip, err := getPipScript(cache)\n+\tif err != nil {\n+\t\treturn pythonEnvironment{}, err\n+\t}\n+\tdefer os.Remove(getPip)\n+\n+\tcmd := exec.Command(python, getPip,","path":"run-python/python.go","position":110,"original_position":110,"commit_id":"6152434c8be54107b4c232d89a9f82deb7ffc531","original_commit_id":"6152434c8be54107b4c232d89a9f82deb7ffc531","user":{"login":"paulbes","id":154348,"avatar_url":"https://avatars2.githubusercontent.com/u/154348?v=4","gravatar_id":"","url":"https://api.github.com/users/paulbes","html_url":"https://github.com/paulbes","followers_url":"https://api.github.com/users/paulbes/followers","following_url":"https://api.github.com/users/paulbes/following{/other_user}","gists_url":"https://api.github.com/users/paulbes/gists{/gist_id}","starred_url":"https://api.github.com/users/paulbes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulbes/subscriptions","organizations_url":"https://api.github.com/users/paulbes/orgs","repos_url":"https://api.github.com/users/paulbes/repos","events_url":"https://api.github.com/users/paulbes/events{/privacy}","received_events_url":"https://api.github.com/users/paulbes/received_events","type":"User","site_admin":false},"body":"How do you find `python` here?","created_at":"2018-05-24T11:24:03Z","updated_at":"2018-05-24T11:44:19Z","html_url":"https://github.com/stoic-cli/stoic-cli-core/pull/4#discussion_r190551223","pull_request_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/4","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/comments/190551223"},"html":{"href":"https://github.com/stoic-cli/stoic-cli-core/pull/4#discussion_r190551223"},"pull_request":{"href":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/4","id":190251212,"html_url":"https://github.com/stoic-cli/stoic-cli-core/pull/4","diff_url":"https://github.com/stoic-cli/stoic-cli-core/pull/4.diff","patch_url":"https://github.com/stoic-cli/stoic-cli-core/pull/4.patch","issue_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/issues/4","number":4,"state":"open","locked":false,"title":"Introducing the Python runner","user":{"login":"biochimia","id":1369,"avatar_url":"https://avatars2.githubusercontent.com/u/1369?v=4","gravatar_id":"","url":"https://api.github.com/users/biochimia","html_url":"https://github.com/biochimia","followers_url":"https://api.github.com/users/biochimia/followers","following_url":"https://api.github.com/users/biochimia/following{/other_user}","gists_url":"https://api.github.com/users/biochimia/gists{/gist_id}","starred_url":"https://api.github.com/users/biochimia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biochimia/subscriptions","organizations_url":"https://api.github.com/users/biochimia/orgs","repos_url":"https://api.github.com/users/biochimia/repos","events_url":"https://api.github.com/users/biochimia/events{/privacy}","received_events_url":"https://api.github.com/users/biochimia/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-05-24T11:07:11Z","updated_at":"2018-05-24T11:44:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a60cc782795d626fec442b363cd924f22f6d3d66","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/4/commits","review_comments_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/4/comments","review_comment_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/issues/4/comments","statuses_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/statuses/6152434c8be54107b4c232d89a9f82deb7ffc531","head":{"label":"stoic-cli:python-runner","ref":"python-runner","sha":"6152434c8be54107b4c232d89a9f82deb7ffc531","user":{"login":"stoic-cli","id":38696056,"avatar_url":"https://avatars1.githubusercontent.com/u/38696056?v=4","gravatar_id":"","url":"https://api.github.com/users/stoic-cli","html_url":"https://github.com/stoic-cli","followers_url":"https://api.github.com/users/stoic-cli/followers","following_url":"https://api.github.com/users/stoic-cli/following{/other_user}","gists_url":"https://api.github.com/users/stoic-cli/gists{/gist_id}","starred_url":"https://api.github.com/users/stoic-cli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stoic-cli/subscriptions","organizations_url":"https://api.github.com/users/stoic-cli/orgs","repos_url":"https://api.github.com/users/stoic-cli/repos","events_url":"https://api.github.com/users/stoic-cli/events{/privacy}","received_events_url":"https://api.github.com/users/stoic-cli/received_events","type":"Organization","site_admin":false},"repo":{"id":130868341,"name":"stoic-cli-core","full_name":"stoic-cli/stoic-cli-core","owner":{"login":"stoic-cli","id":38696056,"avatar_url":"https://avatars1.githubusercontent.com/u/38696056?v=4","gravatar_id":"","url":"https://api.github.com/users/stoic-cli","html_url":"https://github.com/stoic-cli","followers_url":"https://api.github.com/users/stoic-cli/followers","following_url":"https://api.github.com/users/stoic-cli/following{/other_user}","gists_url":"https://api.github.com/users/stoic-cli/gists{/gist_id}","starred_url":"https://api.github.com/users/stoic-cli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stoic-cli/subscriptions","organizations_url":"https://api.github.com/users/stoic-cli/orgs","repos_url":"https://api.github.com/users/stoic-cli/repos","events_url":"https://api.github.com/users/stoic-cli/events{/privacy}","received_events_url":"https://api.github.com/users/stoic-cli/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/stoic-cli/stoic-cli-core","description":"Stoic CLI Hub","fork":false,"url":"https://api.github.com/repos/stoic-cli/stoic-cli-core","forks_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/forks","keys_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/teams","hooks_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/hooks","issue_events_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/issues/events{/number}","events_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/events","assignees_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/assignees{/user}","branches_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/branches{/branch}","tags_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/tags","blobs_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/statuses/{sha}","languages_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/languages","stargazers_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/stargazers","contributors_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/contributors","subscribers_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/subscribers","subscription_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/subscription","commits_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/contents/{+path}","compare_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/merges","archive_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/downloads","issues_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/issues{/number}","pulls_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls{/number}","milestones_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/milestones{/number}","notifications_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/labels{/name}","releases_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/releases{/id}","deployments_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/deployments","created_at":"2018-04-24T14:36:49Z","updated_at":"2018-05-23T12:05:04Z","pushed_at":"2018-05-24T11:07:11Z","git_url":"git://github.com/stoic-cli/stoic-cli-core.git","ssh_url":"git@github.com:stoic-cli/stoic-cli-core.git","clone_url":"https://github.com/stoic-cli/stoic-cli-core.git","svn_url":"https://github.com/stoic-cli/stoic-cli-core","homepage":null,"size":2178,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"stoic-cli:master","ref":"master","sha":"f26d0477499260ac335bc46a537750c2e55dd1a6","user":{"login":"stoic-cli","id":38696056,"avatar_url":"https://avatars1.githubusercontent.com/u/38696056?v=4","gravatar_id":"","url":"https://api.github.com/users/stoic-cli","html_url":"https://github.com/stoic-cli","followers_url":"https://api.github.com/users/stoic-cli/followers","following_url":"https://api.github.com/users/stoic-cli/following{/other_user}","gists_url":"https://api.github.com/users/stoic-cli/gists{/gist_id}","starred_url":"https://api.github.com/users/stoic-cli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stoic-cli/subscriptions","organizations_url":"https://api.github.com/users/stoic-cli/orgs","repos_url":"https://api.github.com/users/stoic-cli/repos","events_url":"https://api.github.com/users/stoic-cli/events{/privacy}","received_events_url":"https://api.github.com/users/stoic-cli/received_events","type":"Organization","site_admin":false},"repo":{"id":130868341,"name":"stoic-cli-core","full_name":"stoic-cli/stoic-cli-core","owner":{"login":"stoic-cli","id":38696056,"avatar_url":"https://avatars1.githubusercontent.com/u/38696056?v=4","gravatar_id":"","url":"https://api.github.com/users/stoic-cli","html_url":"https://github.com/stoic-cli","followers_url":"https://api.github.com/users/stoic-cli/followers","following_url":"https://api.github.com/users/stoic-cli/following{/other_user}","gists_url":"https://api.github.com/users/stoic-cli/gists{/gist_id}","starred_url":"https://api.github.com/users/stoic-cli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stoic-cli/subscriptions","organizations_url":"https://api.github.com/users/stoic-cli/orgs","repos_url":"https://api.github.com/users/stoic-cli/repos","events_url":"https://api.github.com/users/stoic-cli/events{/privacy}","received_events_url":"https://api.github.com/users/stoic-cli/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/stoic-cli/stoic-cli-core","description":"Stoic CLI Hub","fork":false,"url":"https://api.github.com/repos/stoic-cli/stoic-cli-core","forks_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/forks","keys_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/teams","hooks_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/hooks","issue_events_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/issues/events{/number}","events_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/events","assignees_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/assignees{/user}","branches_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/branches{/branch}","tags_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/tags","blobs_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/statuses/{sha}","languages_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/languages","stargazers_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/stargazers","contributors_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/contributors","subscribers_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/subscribers","subscription_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/subscription","commits_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/contents/{+path}","compare_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/merges","archive_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/downloads","issues_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/issues{/number}","pulls_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls{/number}","milestones_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/milestones{/number}","notifications_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/labels{/name}","releases_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/releases{/id}","deployments_url":"https://api.github.com/repos/stoic-cli/stoic-cli-core/deployments","created_at":"2018-04-24T14:36:49Z","updated_at":"2018-05-23T12:05:04Z","pushed_at":"2018-05-24T11:07:11Z","git_url":"git://github.com/stoic-cli/stoic-cli-core.git","ssh_url":"git@github.com:stoic-cli/stoic-cli-core.git","clone_url":"https://github.com/stoic-cli/stoic-cli-core.git","svn_url":"https://github.com/stoic-cli/stoic-cli-core","homepage":null,"size":2178,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/4"},"html":{"href":"https://github.com/stoic-cli/stoic-cli-core/pull/4"},"issue":{"href":"https://api.github.com/repos/stoic-cli/stoic-cli-core/issues/4"},"comments":{"href":"https://api.github.com/repos/stoic-cli/stoic-cli-core/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stoic-cli/stoic-cli-core/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/stoic-cli/stoic-cli-core/statuses/6152434c8be54107b4c232d89a9f82deb7ffc531"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"paulbes"}}